A simple Tessel library for interacting with the Nokia 5110 display. The library is a port of the LCD5110_Graph library by Henning Karlsen. Most of the functions are supported with the exception ofprintNumF and printNumI. Performance is generally good except for printing characters. It seems that the math involved with rendering characters is slow on the Tessel. Entire screen updates take about 53ms on average.
The module uses the double-wide proto-module and can be installed on either side of the Tessel. It occupies two ports but only uses one of them (A or D).
The module uses the Nokia 5110 display which can be easily acquired online. A few options are:
For connection information I followed the wiring guide from Sparkfun.
npm install tessel-nokia5110
var tessel = require('tessel');
// Screen is connected to port D
var nokia5110 = require('tessel-nokia5110').use(tessel.port['D']);
var CENTER = 9998;
nokia5110.print("Hello Tessel!", CENTER, 20);
console.log("Your text is ready.");
Nokia5110.on('ready', callback(err, screen)) - Emitted when the screen object is first initialized
Nokia5110.update([callback(err)]) - Updates the display with the contents of scrbuf
Nokia5110.clear([callback(err)]) - Clears the display
Nokia5110.fill() - Turns on every pixel in scrbuf
Nokia5110.setContrast(contrast, [callback(err)]) - Adjust contrast of screen. contrast can be any value between 0x00 and 0x7F
Nokia5110.setPixel(x, y) - Sets pixel at location (x,y)
Nokia5110.clrPixel(x, y) - Clears the pixel at location (x,y)
Nokia5110.invPixel(x, y) - Invert the state of the pixel at location (x,y)
Nokia5110.print(str, x, y) - Write the string str at location (x,y). The default font is SmallFont.
Nokia5110.setFont(font) - Sets the current font. See Members below for more info on using the fontsmember of the screen object.
Nokia5110.drawHLine(x, y, len) - Draws a horizontal line starting at location (x,y) that is len pixels long.
Nokia5110.clrHLine(x, y, len) - Removes len pixels of the horizontal line that starts at location (x,y).
Nokia5110.drawVLine(x, y, len) - Draws a vertical line starting at location (x,y) that is len pixels long.
Nokia5110.clrVLine(x, y, len) - Removes len pixels of the horizontal line that starts at location (x,y).
Nokia5110.drawLine(x1, y1, x2, y2) - Draws a line from location (x1,y1) to (x2,y2).
Nokia5110.clrLine(x1, y1, x2, y2) - Clears a line on the screen from location (x1,y1) to (x2,y2).
Nokia5110.drawRect(x1, y1, x2, y2) - Draws a rectangle that has a top left corner at (x1,y1) and a lower right corner at (x2,y2).
Nokia5110.clrRect(x1, y1, x2, y2) - Removes a rectangle that has a top left corner at (x1,y1) and a lower right corner at (x2,y2).
Nokia5110.drawRoundRect(x1, y1, x2, y2) - Same as drawRect but adds a rounded look to the rectangle corners.
Nokia5110.clrRoundRect(x1, y1, x2, y2) - Removes a rounded rectangle that has a top left corner at (x1,y1) and a lower right corner at (x2,y2).
Nokia5110.drawCircle(x, y, radius) - Draws a circle that is centered at location (x,y) with radius.
Nokia5110.clrCircle(x, y, radius) - Removes a circle that is centered at location (x,y) with radius.
Nokia5110.drawBitmap(x, y, bitmap, sx, sy) - Draw bitmap(defined as byte array) at location (x,y). sxand sy define the size.
Nokia5110.drawPreSizedBitmap(bitmap) - Draw bitmap by simply copying the bits onto the screen. This is much faster than drawBitmap but does not allow you to change the location.
Nokia5110.setBacklight(state) - Turns the backlight on if state is truthy, off otherwise.
Nokia5110.fonts - Contains definitions of the supported fonts. SmallFont, TinyFont, MediumNumbers, BigNumbers.
Nokia5110.scrbuf - The 504 byte raw buffer that is used to update the screen.
Nokia5110.CENTER - Can be used in calls to print to center text
Nokia5110.LEFT - Can be used in calls to print to left-align text
Nokia5110.RIGHT - Can be used in calls to print to right-align text
Almost all of the library calls simply update a display buffer without actually updating the screen. This is useful for making multiple changes to the screen at once without the overhead of actually redrawing the screen. To help with performance only call update() when you are actually ready for the screen to refresh.
- Full Graphic Demo. Demonstrates all display capabilities.
- Tiny Font. Demonstrates how to change the font and what the TinyFont looks like.
- Scrolling Text. Demonstrates how to get scrolling text. Runs very slow
- Bitmap Display. Demonstrates how to display a monochrome bitmap on the lcd.
- Static Display. Demonstrates some of basic graphic calls to create a static screen.
v2.0.0 - Complete rewrite to port LCD5110_Graph library.
- Rewrote SPI interface code for major performance boost
- Removed async library to improve performance
- Added additional examples
v1.0.1 - Updated examples to remove async calls
v1.0.0 - Initial version
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!