This sketch prints "Hello World!" to the LCD and uses the cursor() and noCursor() methods to turn on and off the cursor.

Dependencies:   Hotboards_SpiLcd mbed

Committer:
Hotboards
Date:
Tue Feb 02 21:59:06 2016 +0000
Revision:
0:9e8b1e9bc6ca
First Release: Hotboards_SpiLcd_Cursor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Hotboards 0:9e8b1e9bc6ca 1 /*
Hotboards 0:9e8b1e9bc6ca 2 Hotboards_Spilcd Library - Cursor
Hotboards 0:9e8b1e9bc6ca 3
Hotboards 0:9e8b1e9bc6ca 4 Demonstrates the use a 16x2 LCD display. The Hotboards_SpiLcd
Hotboards 0:9e8b1e9bc6ca 5 library works with all LCD displays that are compatible with the
Hotboards 0:9e8b1e9bc6ca 6 ST7032 driver presented on Spi Lcd board (http://www.hotboards.org).
Hotboards 0:9e8b1e9bc6ca 7 This sketch prints "Hello World!" to the LCD and
Hotboards 0:9e8b1e9bc6ca 8 uses the cursor() and noCursor() methods to turn
Hotboards 0:9e8b1e9bc6ca 9 on and off the cursor.
Hotboards 0:9e8b1e9bc6ca 10 The circuit:
Hotboards 0:9e8b1e9bc6ca 11 * BKL --> GND
Hotboards 0:9e8b1e9bc6ca 12 * VDD --> 3.3v
Hotboards 0:9e8b1e9bc6ca 13 * GND --> GND
Hotboards 0:9e8b1e9bc6ca 14 * SCK --> PA_5
Hotboards 0:9e8b1e9bc6ca 15 * SI --> PA_6
Hotboards 0:9e8b1e9bc6ca 16 * CS --> PB_15
Hotboards 0:9e8b1e9bc6ca 17 * RS --> PB_14
Hotboards 0:9e8b1e9bc6ca 18 * RST --> PB_13
Hotboards 0:9e8b1e9bc6ca 19 Library and example ported by Diego from Hotboards and originally created
Hotboards 0:9e8b1e9bc6ca 20 by David A. Mellis
Hotboards 0:9e8b1e9bc6ca 21 library modified 5 Jul 2009
Hotboards 0:9e8b1e9bc6ca 22 by Limor Fried (http://www.ladyada.net)
Hotboards 0:9e8b1e9bc6ca 23 example added 9 Jul 2009
Hotboards 0:9e8b1e9bc6ca 24 by Tom Igoe
Hotboards 0:9e8b1e9bc6ca 25 modified 22 Nov 2010
Hotboards 0:9e8b1e9bc6ca 26 by Tom Igoe
Hotboards 0:9e8b1e9bc6ca 27 */
Hotboards 0:9e8b1e9bc6ca 28
Hotboards 0:9e8b1e9bc6ca 29 #include "mbed.h"
Hotboards 0:9e8b1e9bc6ca 30 #include "Hotboards_SpiLcd.h"
Hotboards 0:9e8b1e9bc6ca 31
Hotboards 0:9e8b1e9bc6ca 32 /* initialize an instance of SPI bus,setting the SPI pins*/
Hotboards 0:9e8b1e9bc6ca 33 SPI device(PA_7,PA_6,PA_5); /* SO, SI, SCK*/
Hotboards 0:9e8b1e9bc6ca 34 /* initialize the library with the numbers of the interface pins*/
Hotboards 0:9e8b1e9bc6ca 35 Hotboards_SpiLcd display( device, PB_15, PB_14, PB_13 ); /* SPI, CS, RS, RST */
Hotboards 0:9e8b1e9bc6ca 36
Hotboards 0:9e8b1e9bc6ca 37
Hotboards 0:9e8b1e9bc6ca 38
Hotboards 0:9e8b1e9bc6ca 39 int main()
Hotboards 0:9e8b1e9bc6ca 40 {
Hotboards 0:9e8b1e9bc6ca 41 /* set the spi frequency to 5MHz*/
Hotboards 0:9e8b1e9bc6ca 42 device.frequency(5000000);
Hotboards 0:9e8b1e9bc6ca 43 /* initialize internal lcd controller:*/
Hotboards 0:9e8b1e9bc6ca 44 display.init();
Hotboards 0:9e8b1e9bc6ca 45
Hotboards 0:9e8b1e9bc6ca 46 // Print a message to the LCD.
Hotboards 0:9e8b1e9bc6ca 47 display.printf("hello, world!");
Hotboards 0:9e8b1e9bc6ca 48
Hotboards 0:9e8b1e9bc6ca 49 while(1)
Hotboards 0:9e8b1e9bc6ca 50 {
Hotboards 0:9e8b1e9bc6ca 51 // Turn off the cursor:
Hotboards 0:9e8b1e9bc6ca 52 display.noCursor();
Hotboards 0:9e8b1e9bc6ca 53 wait(0.5);
Hotboards 0:9e8b1e9bc6ca 54 // Turn on the cursor:
Hotboards 0:9e8b1e9bc6ca 55 display.cursor();
Hotboards 0:9e8b1e9bc6ca 56 wait(0.5);
Hotboards 0:9e8b1e9bc6ca 57 }
Hotboards 0:9e8b1e9bc6ca 58 }