This sketch prints "Hello World!" to the LCD and shows the time.
Dependencies: Hotboards_SpiLcd mbed
main.cpp@0:a910ddaef7c0, 2016-01-28 (annotated)
- Committer:
- Hotboards
- Date:
- Thu Jan 28 23:01:37 2016 +0000
- Revision:
- 0:a910ddaef7c0
- Child:
- 1:25bddedff209
first mbed example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Hotboards | 0:a910ddaef7c0 | 1 | /* |
Hotboards | 0:a910ddaef7c0 | 2 | Hotboards_SpiLcd Library - Hello World |
Hotboards | 0:a910ddaef7c0 | 3 | |
Hotboards | 0:a910ddaef7c0 | 4 | Demonstrates the use a 16x2 LCD display. The Hotboards_SpiLcd |
Hotboards | 0:a910ddaef7c0 | 5 | library works with all LCD displays that are compatible with the |
Hotboards | 0:a910ddaef7c0 | 6 | SP7032 driver presented on Spi Lcd board (http://www.hotboards.org). |
Hotboards | 0:a910ddaef7c0 | 7 | This sketch prints "Hello World!" to the LCD |
Hotboards | 0:a910ddaef7c0 | 8 | and shows the time. |
Hotboards | 0:a910ddaef7c0 | 9 | |
Hotboards | 0:a910ddaef7c0 | 10 | The circuit: |
Hotboards | 0:a910ddaef7c0 | 11 | * BKL --> GND |
Hotboards | 0:a910ddaef7c0 | 12 | * VDD --> 3.3v |
Hotboards | 0:a910ddaef7c0 | 13 | * GND --> GND |
Hotboards | 0:a910ddaef7c0 | 14 | * SCLK --> CLK (ICSP conector) |
Hotboards | 0:a910ddaef7c0 | 15 | * SI --> MOSI (ICSPs conector) |
Hotboards | 0:a910ddaef7c0 | 16 | * CS --> D7 |
Hotboards | 0:a910ddaef7c0 | 17 | * RS --> D6 |
Hotboards | 0:a910ddaef7c0 | 18 | * RST --> D5 |
Hotboards | 0:a910ddaef7c0 | 19 | |
Hotboards | 0:a910ddaef7c0 | 20 | Library and example ported by Diego from Hotboards and originally cretaed by |
Hotboards | 0:a910ddaef7c0 | 21 | by David A. Mellis |
Hotboards | 0:a910ddaef7c0 | 22 | library modified 5 Jul 2009 |
Hotboards | 0:a910ddaef7c0 | 23 | by Limor Fried (http://www.ladyada.net) |
Hotboards | 0:a910ddaef7c0 | 24 | example added 9 Jul 2009 |
Hotboards | 0:a910ddaef7c0 | 25 | by Tom Igoe |
Hotboards | 0:a910ddaef7c0 | 26 | modified 22 Nov 2010 |
Hotboards | 0:a910ddaef7c0 | 27 | by Tom Igoe |
Hotboards | 0:a910ddaef7c0 | 28 | This example code is in the public domain. |
Hotboards | 0:a910ddaef7c0 | 29 | */ |
Hotboards | 0:a910ddaef7c0 | 30 | |
Hotboards | 0:a910ddaef7c0 | 31 | #include "mbed.h" |
Hotboards | 0:a910ddaef7c0 | 32 | #include "Hotboards_SpiLcd.h" |
Hotboards | 0:a910ddaef7c0 | 33 | |
Hotboards | 0:a910ddaef7c0 | 34 | // initialize the spi peripherals, setting the spi pins |
Hotboards | 0:a910ddaef7c0 | 35 | SPI device( PB_5, NC, PB_3 ); // mosi, miso, sclk |
Hotboards | 0:a910ddaef7c0 | 36 | // initialize the library with the numbers of the interface pins |
Hotboards | 0:a910ddaef7c0 | 37 | Hotboards_SpiLcd display( device, PC_0, PC_1, PC_2 ); //spi, cs, rs, rst |
Hotboards | 0:a910ddaef7c0 | 38 | |
Hotboards | 0:a910ddaef7c0 | 39 | int main( void ) |
Hotboards | 0:a910ddaef7c0 | 40 | { |
Hotboards | 0:a910ddaef7c0 | 41 | uint8_t milis = 0; |
Hotboards | 0:a910ddaef7c0 | 42 | // set the spi frequency to 5MHz |
Hotboards | 0:a910ddaef7c0 | 43 | device.frequency(5000000); |
Hotboards | 0:a910ddaef7c0 | 44 | // initialize internal lcd controller: |
Hotboards | 0:a910ddaef7c0 | 45 | display.init(); |
Hotboards | 0:a910ddaef7c0 | 46 | // Print a message to the LCD. |
Hotboards | 0:a910ddaef7c0 | 47 | display.printf( "Hello mbed!" ); |
Hotboards | 0:a910ddaef7c0 | 48 | |
Hotboards | 0:a910ddaef7c0 | 49 | while(1) |
Hotboards | 0:a910ddaef7c0 | 50 | { |
Hotboards | 0:a910ddaef7c0 | 51 | // set the cursor to column 0, line 1 |
Hotboards | 0:a910ddaef7c0 | 52 | // (note: line 1 is the second row, since counting begins with 0): |
Hotboards | 0:a910ddaef7c0 | 53 | display.setCursor( 0, 1 ); |
Hotboards | 0:a910ddaef7c0 | 54 | wait( 1 ); |
Hotboards | 0:a910ddaef7c0 | 55 | milis++; |
Hotboards | 0:a910ddaef7c0 | 56 | // print the number of seconds since reset: |
Hotboards | 0:a910ddaef7c0 | 57 | display.printf( " %d", milis ); |
Hotboards | 0:a910ddaef7c0 | 58 | } |
Hotboards | 0:a910ddaef7c0 | 59 | } |