This is a compact display driver for the LS013B4DN04 display from Sharp. It is text based and writes 8×8 pixel characters on the screen, which allows 12×12 characters.

There is a library with automatic refresh using timer 2 here:

Sharp Display Driver 8×8 Timer 2

DEMO

This demo is an example of the Arduino library.

Requirements

  • Library for Arduino IDE 1.6 or newer
  • Assuming a ATmega328P microcontroller running at 16MHz
    You can use it with other microcontroller, but probably have to adjust the timing manually.

Usage

After creating a global instance of the driver class and pass the used pins for the SPI communication to the driver, you have to initialise the driver with begin() and setFont().

This minimal example is showing all required steps. You find the complete example, including the font, in the example folder of the library.

// Include the header file of the driver.
#include <LRSharpDisplay.h>

// Include the header file of the font.
#include "Fonts.h"

// Create a global instance of the display driver.
//
// Add the chip select, clock and data pins which are connected to the
// display as arguments to the constructor in this order. In this
// example, we use pin 11 for chip select, pin 9 for the clock and
// pin 10 for the data in.
//
lr::SharpDisplay sharpDisplay(11, 9, 10);

void setup() {
  // In the setup method, you have to call begin() to initialize the
  // library and setup communication.
  sharpDisplay.begin();

  // A font is required, you can use the example font for your own
  // project. Just add the "Fonts.h" and "Fonts.cpp" to your project.
  sharpDisplay.setFont(Fonts::a);

  // The display is automatically cleared at the start, so you can
  // start writing text to the display:
  sharpDisplay.writeText(F("Hello World!"));

  // The text is _not_ visible at this point, you have to call
  // refresh() to make the current text buffer visible on the display.

  // Make the text visible on the display.
  sharpDisplay.refresh();
}

void loop() {
  // You must call the refresh method at least once per second to
  // keep a latent charge from building up within the Liquid Crystal cells.
  sharpDisplay.refresh();
  delay(500);
}

Method Documentation

SharpDisplay(uint8_t chipSelectPin, uint8_t clockPin, uint8_t dataPin)

The constructor. Specify the pins for the SPI communication with the display.

void begin()

This method initialises the display. Call this as first method in your setup() method. It will setup the communication and clear the display.

void setFont(const uint8_t *fontData)

This method sets the current used font for the display. You have to set an initial font before you can use the display driver. It is possible to call this method later again to change the font.

uint8_t getScreenWidth()

Use this method to get the screen width in characters.

uint8_t getScreenHeight()

Use this method to get the screen height in characters.

void clear()

This method clears the display. It will also clear the text buffer and fill the buffer with space (0x20) and sets the cursor at position 0, 0.

void refresh()

Refresh the display. This will make the current text buffer visible on the display. You have to call this method after each modification of the screen to make this modification visible.

You can call the refresh method as often you like, it only depends how fast you like to display the changes on the screen.

void setTextInverse(bool enable)

Enable/Disable inverse future text. If you enable inverse text, any subsequent call of text writing methods will write inverse text or characters.

void setCharacter(uint8_t row, uint8_t column, uint8_t character)

This will set a single character on the screen at the specified location.

char getCharacter(uint8_t row, uint8_t column)

Get the character at the specified location.

void setLineText(uint8_t row, const String &text)

This will replace a line on the screen with the given text. If the text is longer than the screen it will cut off and if the text is smaller than the screen, the rest of the line is filled with space characters.

void setLineInverted(uint8_t row, bool inverted)

This will make a line inverse or not inverse. E.g. you can use this method for the selected item in a menu.

void setCursorPosition(uint8_t row, uint8_t column)

This sets the position of the virtual cursor. It will change the location where the writeCharacter() and writeText() methods will start writing text.

void getCursorPosition(uint8_t &row, uint8_t &column)

Use this method to get the location of the virtual cursor.

void writeCharacter(uint8_t c)

This writes a single character on the screen at the current cursor position. You can also send a newline character ‘\n’ to start a new line.

void writeText(const String &text)

This writes test on the screen at the current cursor position. You can use the newline ‘\n’ character to begin a new line. If the text reaches the bottom of the screen, the contents of the screen is scrolled up to make space for the new text.

void scrollScreen(ScrollDirection direction)

You can use this method to scroll the contents of the screen into all four directions.

Important Notes

Important: You must call the refresh() method at least once per second to keep a latent charge from building up within the Liquid Crystal cells.

You can turn the display completely off by setting the DISP pin on the display to low. In this case the refresh is not required anymore.

Important: When displaying static images, Sharp recommends refreshing the image data every two hours to prevent stuck pixels.

Font Format

The font is a simple array of bytes. There are eight bytes per character, each byte is a row in the character from top to down. Each 0-bit in the byte is a black pixel, the font have to be inverted.

Use the Font to Byte application to convert bitmaps into byte arrays for this display driver.

The font can cover 128 characters maximum, but you can provide a shorter font with e.g. only 64 characters without problems.

Download

Download the driver using the following link. Extract the directory and move it into the “library” directory.

Lucky Resistor’s Sharp Display 8×8 Library

Visit the GITHub page for older versions.