Git Product home page Git Product logo

leddisplay's Introduction

LedDisplay Library

For details, see http://www.arduino.cc/playground/Main/LedDisplay

This library allows you to send text to an Avago HCMS-29xx LED display. The HCMS 29xx displays are pretty little displays that contain a row of 5x7 LED matrices. 

The displays have a synchronous serial interface. You'll need five digital output lines to control them. The pins are as follows:

    * data - bits in from the microcontroller
    * register select - selects whether you're sending display data or control data
    * clock - timing clock from the microcontroller
    * enable - enables or disables the display
    * reset - resets the display 

The library manages all the necessary pin control and data shifting for you.

Methods:

LedDisplay(int dataPin, int registerSelect, int clockPin, int chipEnable, int resetPin, int displayLength) - instantiates the library. The first five parameters are the Arduino pin numbers that are connected to the display. The last sets the length of the display (8 for the HCMS-291x and HCMS-297x, 4 for the HCMS-290x and 296x).

example:

   LedDisplay myDisplay = LedDisplay(2,3,4,5,6,8);

begin() - initializes and resets the display.

example: 

	myDisplay.begin();

Printing methods

write(char whatCharacter, byte whatPosition) - writes a single character to the display at a particular position

example:

	myDisplay.write('A', 4);

LedDisplay inherits all the print() and println() methods from the Print library, so you can use those methods to print to the display, as long as what you print fits within the display. For example here's how to print the millis and a title string to the display:

   myDisplay.print("ms:");
   myDisplay.print(millis());

You can also do the usual Print things, like:

   int myInt = 12;
   myDisplay.print(myInt, DEC);
   // or
   myDisplay.print(myInt, HEX);

Scrolling methods

If you want to be able to automatically scroll a string of text, you need to use the setString() method first. This method stores a character string in the library instance, so you can then use the scroll() method to move it left and right.

setString(char* stringToDisplay) - displays a string on the display. If the string is longer than the display, the beginning of the string is displayed. You can use the scroll() method to step the string forward on the display.

getString() - returns the string to display.

example:

     // print out the display string for debugging:
     Serial.println(myDisplay.getString());

stringLength() - returns the length of the display string. See the scrolling example below for usage.

scroll(int direction) - scrolls the display using the string set by setString(). Negative numbers scroll left, positive numbers scroll right.

example:

...

void setup() { 

...

  // scroll a string that's longer than the display:
   myDisplay.setString("This is a very long string");
}

void loop() {

  // when the string scrolls off the display, reverse scroll direction.
  // On the right, it scrolls off at position 8.
  // on the left, it scrolls off when the cursor is less than -(the length of the string):

  if ((myDisplay.cursorPosition() > displayLength) ||
    (myDisplay.cursorPosition() <= -(myDisplay.stringLength()))) {
    myDirection = -myDirection;
    delay(1000);
  }

  // scroll:
  myDisplay.scroll(myDirection);
  delay(100);
}


Cursor control methods

clear() - clear the display.

example:

   myDisplay.clear();

home() - set cursor to far left hand position.

example:

   myDisplay.home();

setCursor(int whichPosition) - set cursor to any position.

example:

   myDisplay.serCursor(4);

getCursor() - get the cursor position.

example:

   int cursorPosition = myDisplay.getCursor();

Display Control methods

setBrightness(int bright) - lets you set the brightness from 0 to 15.

example:

   myDisplay.setBrightness(15);

If you want to set the opcodes of the display directly (you can learn them from the data sheet), the following methods will do the trick.

loadControlRegister(int dataByte) - sends 8 bits to one of the control registers.

loadDotRegister() - sends 320 bits to the dot register

Version method

version() - returns the version number of the library. 

leddisplay's People

Contributors

amiller27 avatar paulstoffregen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

leddisplay's Issues

Update for compiling for Linux

Description

With a few changes, it would be possible to use this code from Linux as well, namely by changing how the I/O is being done by overloading digitalWrite (GPIO Write) and ShiftOut (SPI Write).

With this, it would be possible to write a wrapper around this library when using Linux which would allow it to be built as a shared library. This opens the possibility of linking against the library (through the wrapper) which would allow using with proprietary code.

Let me know what you think

Esp32 ISSUE

Hi,
I tried this library with HCMS 2915 and ESP32.
I complied without errors, i uploaded it on ESP32 but the display don't power on.
I verify the wiring and works.
Same display with teency3.2 works perfectly.
Have you any ideas what i need to change with ESP32?
Thanks.
Best regards,
Daniel

Library does not function when display length greater than 32

When _displayLength (sixth argument to constructor) is greater than 32, the library sends gibberish to the attached string of HCMS-2915 display modules.

I have a string of eight HCMS-2915 modules, daisy-chained in a chain of 8 modules, for 64 characters. When I call the constructor, with a _displayLength of 64, the displays show gibberish in the first 4 modules, and nothing (blank) in the following 4 modules. The gibberish is fixed in that it does not change over time (the code driving these displays was derived from the scroll_multiple example, and should be scrolling, but the gibberish does not change over time).
img_1053

Brightness not working for multiple HCMS 29xx display

Brightness not set for multiple displays

I'm using 3x HCMS 2912 display. When reducing the brightness of the displays only the display on the far right is covered. The other two display remain the same.

Steps To Reproduce Problem

Assemble the three displays according to the following description: https://playground.arduino.cc/Main/LedDisplay/

Execute the Arduino Sketch attached below.

Hardware & Software

Board: Arduino Mega 2560
Shields / modules used: none
Arduino IDE version: v1.8.12
Operating system & version: Windows 10 Pro, v1909

Arduino Sketch

#include <LedDisplay.h>
LedDisplay myDisplay = LedDisplay(2,3,4,5,6,24);

void setup() {
  myDisplay.begin();
  myDisplay.setCursor(0);
  myDisplay.print("123456789012345678901234");
  myDisplay.setBrightness(7);
}

void loop() {
}

Errors or Incorrect Output

No errors shown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.