This example scroll the message "[Hola]" on Hotboards SpiLcd

Dependencies:   Hotboards_SpiLcd mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002   Hotboards_SpiLcd Library - Writing in diferent rows
00003   
00004   Demonstrates the use a 16x2 LCD display, specially the functions for scrolling text.
00005   The Hotboards_SpiLcd library works with all LCD displays that are compatible with the
00006   ST7032 driver presented on Spi Lcd board (http://www.hotboards.org).
00007   
00008   This sketch prints "[HOLA]" in the upper row of the LCD and then scroll it to the right,
00009   then to the left.
00010   
00011   
00012   The circuit:
00013   *  BKL   -->  GND
00014   *  VDD   -->  3.3v
00015   *  GND   -->  GND
00016   *  SCK   -->  PA_5
00017   *  SI    -->  PA_6
00018   *  CS    -->  PB_15
00019   *  RS    -->  PB_14
00020   *  RST   -->  PB_13
00021  
00022   Library ported by Diego from Hotboards and originally created by
00023   David A. Mellis
00024   library modified 5 Jul 2009
00025   by Limor Fried (http://www.ladyada.net)
00026   example added 
00027   by Pedro from Hotboards
00028   This example code is in the public domain.
00029  */
00030 #include "mbed.h"
00031 #include "Hotboards_SpiLcd.h"
00032 
00033 /* initialize an instance of SPI bus,setting the SPI pins*/
00034 SPI device(PA_7,PA_6,PA_5); /* SO, SI, SCK*/
00035 /* initialize the library with the numbers of the interface pins*/
00036 Hotboards_SpiLcd display( device, PB_15, PB_14, PB_13 ); /* SPI, CS, RS, RST */
00037 
00038 
00039 int main() 
00040 {
00041     /* set the spi frequency to 5MHz*/
00042     device.frequency(5000000);
00043     /* initialize internal lcd controller:*/
00044     display.init();
00045     
00046     while(1) 
00047     {
00048       /* Set Cursor on column 0 and Row 0*/
00049       display.setCursor(0,0);
00050       /* Print a message */
00051       display.printf("[Hola]" );
00052       
00053       
00054       /* scroll text 10 positions to the right once at time*/
00055       for(int j=0;j<10;j++)
00056       {
00057         display.scrollDisplayRight();
00058         wait(0.3);
00059       }
00060       
00061      /* scroll text 10 positions to the left once at time*/
00062       for(int j=0;j<10;j++)
00063       {
00064         display.scrollDisplayLeft();
00065         wait(0.3);
00066       }
00067       
00068       /*clear lcd and start again*/
00069       display.clear();
00070     }
00071 }