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

Dependencies:   Hotboards_SpiLcd mbed

Committer:
Hotboards
Date:
Tue Feb 02 18:38:39 2016 +0000
Revision:
0:3bcbe6532e83
First release of example Scrolling_Text

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Hotboards 0:3bcbe6532e83 1 /*
Hotboards 0:3bcbe6532e83 2 Hotboards_SpiLcd Library - Writing in diferent rows
Hotboards 0:3bcbe6532e83 3
Hotboards 0:3bcbe6532e83 4 Demonstrates the use a 16x2 LCD display, specially the functions for scrolling text.
Hotboards 0:3bcbe6532e83 5 The Hotboards_SpiLcd library works with all LCD displays that are compatible with the
Hotboards 0:3bcbe6532e83 6 ST7032 driver presented on Spi Lcd board (http://www.hotboards.org).
Hotboards 0:3bcbe6532e83 7
Hotboards 0:3bcbe6532e83 8 This sketch prints "[HOLA]" in the upper row of the LCD and then scroll it to the right,
Hotboards 0:3bcbe6532e83 9 then to the left.
Hotboards 0:3bcbe6532e83 10
Hotboards 0:3bcbe6532e83 11
Hotboards 0:3bcbe6532e83 12 The circuit:
Hotboards 0:3bcbe6532e83 13 * BKL --> GND
Hotboards 0:3bcbe6532e83 14 * VDD --> 3.3v
Hotboards 0:3bcbe6532e83 15 * GND --> GND
Hotboards 0:3bcbe6532e83 16 * SCK --> PA_5
Hotboards 0:3bcbe6532e83 17 * SI --> PA_6
Hotboards 0:3bcbe6532e83 18 * CS --> PB_15
Hotboards 0:3bcbe6532e83 19 * RS --> PB_14
Hotboards 0:3bcbe6532e83 20 * RST --> PB_13
Hotboards 0:3bcbe6532e83 21
Hotboards 0:3bcbe6532e83 22 Library ported by Diego from Hotboards and originally created by
Hotboards 0:3bcbe6532e83 23 David A. Mellis
Hotboards 0:3bcbe6532e83 24 library modified 5 Jul 2009
Hotboards 0:3bcbe6532e83 25 by Limor Fried (http://www.ladyada.net)
Hotboards 0:3bcbe6532e83 26 example added
Hotboards 0:3bcbe6532e83 27 by Pedro from Hotboards
Hotboards 0:3bcbe6532e83 28 This example code is in the public domain.
Hotboards 0:3bcbe6532e83 29 */
Hotboards 0:3bcbe6532e83 30 #include "mbed.h"
Hotboards 0:3bcbe6532e83 31 #include "Hotboards_SpiLcd.h"
Hotboards 0:3bcbe6532e83 32
Hotboards 0:3bcbe6532e83 33 /* initialize an instance of SPI bus,setting the SPI pins*/
Hotboards 0:3bcbe6532e83 34 SPI device(PA_7,PA_6,PA_5); /* SO, SI, SCK*/
Hotboards 0:3bcbe6532e83 35 /* initialize the library with the numbers of the interface pins*/
Hotboards 0:3bcbe6532e83 36 Hotboards_SpiLcd display( device, PB_15, PB_14, PB_13 ); /* SPI, CS, RS, RST */
Hotboards 0:3bcbe6532e83 37
Hotboards 0:3bcbe6532e83 38
Hotboards 0:3bcbe6532e83 39 int main()
Hotboards 0:3bcbe6532e83 40 {
Hotboards 0:3bcbe6532e83 41 /* set the spi frequency to 5MHz*/
Hotboards 0:3bcbe6532e83 42 device.frequency(5000000);
Hotboards 0:3bcbe6532e83 43 /* initialize internal lcd controller:*/
Hotboards 0:3bcbe6532e83 44 display.init();
Hotboards 0:3bcbe6532e83 45
Hotboards 0:3bcbe6532e83 46 while(1)
Hotboards 0:3bcbe6532e83 47 {
Hotboards 0:3bcbe6532e83 48 /* Set Cursor on column 0 and Row 0*/
Hotboards 0:3bcbe6532e83 49 display.setCursor(0,0);
Hotboards 0:3bcbe6532e83 50 /* Print a message */
Hotboards 0:3bcbe6532e83 51 display.printf("[Hola]" );
Hotboards 0:3bcbe6532e83 52
Hotboards 0:3bcbe6532e83 53
Hotboards 0:3bcbe6532e83 54 /* scroll text 10 positions to the right once at time*/
Hotboards 0:3bcbe6532e83 55 for(int j=0;j<10;j++)
Hotboards 0:3bcbe6532e83 56 {
Hotboards 0:3bcbe6532e83 57 display.scrollDisplayRight();
Hotboards 0:3bcbe6532e83 58 wait(0.3);
Hotboards 0:3bcbe6532e83 59 }
Hotboards 0:3bcbe6532e83 60
Hotboards 0:3bcbe6532e83 61 /* scroll text 10 positions to the left once at time*/
Hotboards 0:3bcbe6532e83 62 for(int j=0;j<10;j++)
Hotboards 0:3bcbe6532e83 63 {
Hotboards 0:3bcbe6532e83 64 display.scrollDisplayLeft();
Hotboards 0:3bcbe6532e83 65 wait(0.3);
Hotboards 0:3bcbe6532e83 66 }
Hotboards 0:3bcbe6532e83 67
Hotboards 0:3bcbe6532e83 68 /*clear lcd and start again*/
Hotboards 0:3bcbe6532e83 69 display.clear();
Hotboards 0:3bcbe6532e83 70 }
Hotboards 0:3bcbe6532e83 71 }