serLCD - custom characters

I’m trying to figure out how to write custom characters to a serial enabled LCD. I am using the serLCD class with a Sparkfun 16x2 LCD, but I’m not sure how to write the data to the port. Do I create a blob and write that? Hope someone can give me a hand. My intent is to create a WiFi signal strength indicator (bars) and display it on my temperature monitor.

Have you been able to write “Hello World” on the display using the Imp?
So now you’re just stuck on the custom character part?

Yep, I’ve been looking at Arduino examples, but not sure how to do it in Squirrel.

I had a deal where I had to write a series of 18 bits at one time. Hugo helped me with some uart.write instructions …
http://forums.electricimp.com/discussion/1630/ti-sn74lv8153-serial-to-parallel#Item_15

It looks like they have some arrays of binary bits that get sent out serially? I wonder if Hugo might have some ideas on how to duplicate that.

Joel, you may have discovered all of this…

The standard Sparkfun documentation doesn’t give much of a hint, but whilst looking at some HD44780 (LCD Controller) info I stumbled across this:

http://www.quinapalus.com/hd44780udg.html

Seems you can create up to 8 custom characters. I then found this Arduino implementation:

https://github.com/nemith/serLCD

Nice find Dave! That javascript character generator is awesome. :slight_smile: I pulled out what I think are the pertinent bits of the C++ code and am trying to convert that to squirrel…

–Edit… just deleting all this so it doesn’t take up space.

That looks great. Could you make the code fragment available that pushes the ‘bars’ to the LCD.

I was able to get custom character functions ported over to Squirrel. I’ll put a pull request on the serLCD repo. I’ve got sweet WiFi signal strength bars on my LCD! Woohoo!

Excellent. Looking forward to an image of the signal strength bars…!

Here they are…

and here is a function with the code:

function ReportRSSI() { local rssi = imp.rssi(); if (rssi < -87) { signal = "None"; bars = [0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0]; } else if (rssi < -82) { signal = "Very Poor"; bars = [0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0]; } else if (rssi < -77) { signal = "Poor"; bars = [0x0,0x0,0x0,0x0,0x0,0x8,0x18,0x0]; } else if (rssi < -72) { signal = "Good"; bars = [0x0,0x0,0x0,0x0,0x4,0xc,0x1c,0x0]; } else if (rssi < -67) { signal = "Very Good"; bars = [0x0,0x0,0x0,0x2,0x6,0xe,0x1e,0x0]; } else { signal = "Excellent"; bars = [0x0,0x0,0x1,0x3,0x7,0xf,0x1f,0x0]; } }

The two bars values might not be right, but I need to look into it more…

Sure. The full class with the new functions is here:

And then, you just need to store and print. If you have “bars” defined then:
screen.createChar(1, bars); screen.printCustomChar(1);