Hotboards MX / Mbed 2 deprecated Hotboards_SpiLcd_AutoScroll

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 - Autoscroll
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 demonstrates the use of the autoscroll()
00007  and noAutoscroll() functions to make new text scroll or not.
00008  The circuit:
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 by
00020  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  This example code is in the public domain.
00028  */
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 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          // set the cursor to (0,0):
00048          display.setCursor(0, 0);
00049          // print from 0 to 9:
00050          for(int thisChar = 0; thisChar < 10; thisChar++) 
00051          {
00052            display.printf("%d",thisChar);
00053            wait(0.5);
00054          }
00055          
00056          // set the cursor to (16,1):
00057          display.setCursor(16, 1);
00058          // set the display to automatically scroll:
00059         display.autoscroll();
00060         // print from 0 to 9:
00061         for (int thisChar = 0; thisChar < 10; thisChar++) 
00062         {
00063            display.printf("%d",thisChar);
00064            wait(0.5);
00065         }
00066         // turn off automatic scrolling
00067         display.noAutoscroll();
00068 
00069         // clear screen for the next loop:
00070         display.clear();
00071         // reset the display shift for the next loop
00072         display.home();
00073      }
00074 }    
00075