Demonstrates de setCursor funcion of Hotboards_SpiLcd Library

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 function setCursor.
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 "Row 1" in the upper row of the LCD
00009   & prints "Row 2" in the lower row of the LCD
00010   
00011   The circuit:
00012   *  BKL   -->  GND
00013   *  VDD   -->  3.3v
00014   *  GND   -->  GND
00015   *  SCK   -->  PA_5
00016   *  SI    -->  PA_6
00017   *  CS    -->  PB_15
00018   *  RS    -->  PB_14
00019   *  RST   -->  PB_13
00020  
00021   Library ported by Diego from Hotboards and originally created by
00022   David A. Mellis
00023   library modified 5 Jul 2009
00024   by Limor Fried (http://www.ladyada.net)
00025   example added 
00026   by Pedro from Hotboards
00027   This example code is in the public domain.
00028  */
00029 #include "mbed.h"
00030 #include "Hotboards_SpiLcd.h"
00031 
00032 /* initialize an instance of SPI bus,setting the SPI pins*/
00033 SPI device(PA_7,PA_6,PA_5); /* SO, SI, SCK*/
00034 /* initialize the library with the numbers of the interface pins*/
00035 Hotboards_SpiLcd display( device, PB_15, PB_14, PB_13 ); /* SPI, CS, RS, RST */
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     /* Set Cursor on column 2 and Row 0*/
00044     display.setCursor(2,0);
00045     /* Print a message */
00046     display.printf( "Row 1" );
00047     /* Set Cursor on column 4 and Row 1*/
00048     display.setCursor(4,1);
00049     /* Print another message */
00050     display.printf( "Row 2" );
00051     
00052     while(1) 
00053     {
00054        /* infinite loop, doing nothing*/
00055     }
00056 }