This sketch prints "Hello World!" to the LCD and shows the time.

Dependencies:   Hotboards_SpiLcd mbed

main.cpp

Committer:
Hotboards
Date:
2016-01-28
Revision:
0:a910ddaef7c0
Child:
1:25bddedff209

File content as of revision 0:a910ddaef7c0:

/*
  Hotboards_SpiLcd Library - Hello World
  
  Demonstrates the use a 16x2 LCD display.  The Hotboards_SpiLcd
  library works with all LCD displays that are compatible with the
  SP7032 driver presented on Spi Lcd board (http://www.hotboards.org).
  This sketch prints "Hello World!" to the LCD
  and shows the time.
  
  The circuit:
  *  BKL   -->  GND
  *  VDD   -->  3.3v
  *  GND   -->  GND
  *  SCLK  -->  CLK (ICSP conector)
  *  SI    -->  MOSI (ICSPs conector)
  *  CS    -->  D7
  *  RS    -->  D6
  *  RST   -->  D5
 
  Library and example ported by Diego from Hotboards and originally cretaed by
  by David A. Mellis
  library modified 5 Jul 2009
  by Limor Fried (http://www.ladyada.net)
  example added 9 Jul 2009
  by Tom Igoe
  modified 22 Nov 2010
  by Tom Igoe
  This example code is in the public domain.
 */
 
#include "mbed.h"
#include "Hotboards_SpiLcd.h"
 
// initialize the spi peripherals, setting the spi pins 
SPI device( PB_5, NC, PB_3 ); // mosi, miso, sclk
// initialize the library with the numbers of the interface pins
Hotboards_SpiLcd display( device, PC_0, PC_1, PC_2 ); //spi, cs, rs, rst
 
int main( void ) 
{
    uint8_t milis = 0;
    // set the spi frequency to 5MHz
    device.frequency(5000000);
    // initialize internal lcd controller:
    display.init();
    // Print a message to the LCD.
    display.printf( "Hello mbed!" );
    
    while(1)
    {
        // set the cursor to column 0, line 1
        // (note: line 1 is the second row, since counting begins with 0):
        display.setCursor( 0, 1 );
        wait( 1 );
        milis++;
        // print the number of seconds since reset:
        display.printf( "  %d", milis );
    }
}