Hotboards MX / Mbed 2 deprecated Hotboards_SpiLcd_setCursor

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 - setCursor
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 to all the positions of the LCD using the
00007  setCursor() method:
00008   
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 
00019  Library and example ported by Diego from Hotboards and originally created 
00020  by David A. Mellis
00021  library modified 5 Jul 2009
00022  by Limor Fried (http://www.ladyada.net)
00023  example added 9 Jul 2009
00024  by Tom Igoe
00025  modified 22 Nov 2010
00026  by Tom Igoe
00027  */
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 
00038 int main() 
00039 {
00040     /* set the spi frequency to 5MHz*/
00041     device.frequency(5000000);
00042     /* initialize internal lcd controller:*/
00043     display.init();
00044     
00045     while(1) 
00046     {
00047       // loop from ASCII 'a' to ASCII 'z':
00048       for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) 
00049       {
00050         // loop over the columns:
00051         for (int  thisRow = 0; thisRow < 2; thisRow++) 
00052         {
00053          // loop over the rows:
00054          for (int thisCol = 0; thisCol < 16; thisCol++) 
00055          {
00056           // set the cursor position:
00057           display.setCursor(thisCol, thisRow);
00058           // print the letter:
00059           display.printf("%c",thisLetter);
00060           wait(0.2);
00061          }
00062         }
00063       }
00064     }
00065 }