Hotboards MX / Mbed 2 deprecated Hotboards_SpiLcd_Scroll

Dependencies:   Hotboards_SpiLcd mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002   LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight()
00003  Demonstrates the use a 16x2 LCD display.  The Hotboards_SpiLcd
00004  library works with all LCD displays that are compatible with the
00005  ST7032 driver presented on Spi Lcd board (http://www.hotboards.org).
00006  This sketch prints "Hello World!" to the LCD and uses the
00007  scrollDisplayLeft() and scrollDisplayRight() methods to scroll
00008  the text.
00009   The circuit:
00010   *  BKL   -->  GND
00011   *  VDD   -->  3.3v
00012   *  GND   -->  GND
00013   *  SCK   -->  PA_5
00014   *  SI    -->  PA_6
00015   *  CS    -->  PB_15
00016   *  RS    -->  PB_14
00017   *  RST   -->  PB_13
00018  Library and example ported by Diego from Hotboards and originally created 
00019  by David A. Mellis
00020  library modified 5 Jul 2009
00021  by Limor Fried (http://www.ladyada.net)
00022  example added 9 Jul 2009
00023  by Tom Igoe
00024  modified 22 Nov 2010
00025  by Tom Igoe
00026  */
00027 
00028 #include "mbed.h"
00029 #include "Hotboards_SpiLcd.h"
00030 
00031 /* initialize an instance of SPI bus,setting the SPI pins*/
00032 SPI device(PA_7,PA_6,PA_5); /* SO, SI, SCK*/
00033 /* initialize the library with the numbers of the interface pins*/
00034 Hotboards_SpiLcd display( device, PB_15, PB_14, PB_13 ); /* SPI, CS, RS, RST */
00035 
00036 
00037 int main() 
00038 {
00039     /* set the spi frequency to 5MHz*/
00040     device.frequency(5000000);
00041     /* initialize internal lcd controller:*/
00042     display.init();
00043     // Print a message to the LCD.
00044     display.printf("hello, world!");
00045     wait(1);
00046     
00047     while(1) 
00048     {
00049       // scroll 13 positions (string length) to the left
00050       // to move it offscreen left:
00051       for (int positionCounter = 0; positionCounter < 13; positionCounter++) 
00052       {
00053         // scroll one position left:
00054         display.scrollDisplayLeft();
00055         // wait a bit:
00056         wait(0.2);
00057       }
00058 
00059       // scroll 29 positions (string length + display length) to the right
00060       // to move it offscreen right:
00061       for (int positionCounter = 0; positionCounter < 29; positionCounter++) 
00062       {
00063         // scroll one position right:
00064         display.scrollDisplayRight();
00065         // wait a bit:
00066         wait(0.2);
00067       }
00068 
00069       // scroll 16 positions (display length + string length) to the left
00070       // to move it back to center:
00071       for (int positionCounter = 0; positionCounter < 16; positionCounter++) 
00072       {
00073        // scroll one position left:
00074        display.scrollDisplayLeft();
00075        // wait a bit:
00076        wait(0.2);
00077       }
00078       
00079       // delay at the end of the full loop:
00080      wait(1);
00081    }
00082 }