This sketch prints "Hello World!" to the LCD and shows the time.
Dependencies: Hotboards_SpiLcd mbed
main.cpp@1:25bddedff209, 2016-01-29 (annotated)
- Committer:
- Hotboards
- Date:
- Fri Jan 29 00:56:21 2016 +0000
- Revision:
- 1:25bddedff209
- Parent:
- 0:a910ddaef7c0
update commets header
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 | 1:25bddedff209 | 7 | |
Hotboards | 0:a910ddaef7c0 | 8 | This sketch prints "Hello World!" to the LCD |
Hotboards | 0:a910ddaef7c0 | 9 | and shows the time. |
Hotboards | 0:a910ddaef7c0 | 10 | |
Hotboards | 0:a910ddaef7c0 | 11 | The circuit: |
Hotboards | 0:a910ddaef7c0 | 12 | * BKL --> GND |
Hotboards | 0:a910ddaef7c0 | 13 | * VDD --> 3.3v |
Hotboards | 0:a910ddaef7c0 | 14 | * GND --> GND |
Hotboards | 1:25bddedff209 | 15 | * SCLK --> PB_3 |
Hotboards | 1:25bddedff209 | 16 | * SI --> PB_5 |
Hotboards | 1:25bddedff209 | 17 | * CS --> PC_0 |
Hotboards | 1:25bddedff209 | 18 | * RS --> PC_1 |
Hotboards | 1:25bddedff209 | 19 | * RST --> PC_2 |
Hotboards | 0:a910ddaef7c0 | 20 | |
Hotboards | 0:a910ddaef7c0 | 21 | Library and example ported by Diego from Hotboards and originally cretaed by |
Hotboards | 0:a910ddaef7c0 | 22 | by David A. Mellis |
Hotboards | 0:a910ddaef7c0 | 23 | library modified 5 Jul 2009 |
Hotboards | 0:a910ddaef7c0 | 24 | by Limor Fried (http://www.ladyada.net) |
Hotboards | 0:a910ddaef7c0 | 25 | example added 9 Jul 2009 |
Hotboards | 0:a910ddaef7c0 | 26 | by Tom Igoe |
Hotboards | 0:a910ddaef7c0 | 27 | modified 22 Nov 2010 |
Hotboards | 0:a910ddaef7c0 | 28 | by Tom Igoe |
Hotboards | 0:a910ddaef7c0 | 29 | This example code is in the public domain. |
Hotboards | 0:a910ddaef7c0 | 30 | */ |
Hotboards | 0:a910ddaef7c0 | 31 | |
Hotboards | 0:a910ddaef7c0 | 32 | #include "mbed.h" |
Hotboards | 0:a910ddaef7c0 | 33 | #include "Hotboards_SpiLcd.h" |
Hotboards | 0:a910ddaef7c0 | 34 | |
Hotboards | 0:a910ddaef7c0 | 35 | // initialize the spi peripherals, setting the spi pins |
Hotboards | 0:a910ddaef7c0 | 36 | SPI device( PB_5, NC, PB_3 ); // mosi, miso, sclk |
Hotboards | 0:a910ddaef7c0 | 37 | // initialize the library with the numbers of the interface pins |
Hotboards | 0:a910ddaef7c0 | 38 | Hotboards_SpiLcd display( device, PC_0, PC_1, PC_2 ); //spi, cs, rs, rst |
Hotboards | 0:a910ddaef7c0 | 39 | |
Hotboards | 0:a910ddaef7c0 | 40 | int main( void ) |
Hotboards | 0:a910ddaef7c0 | 41 | { |
Hotboards | 0:a910ddaef7c0 | 42 | uint8_t milis = 0; |
Hotboards | 0:a910ddaef7c0 | 43 | // set the spi frequency to 5MHz |
Hotboards | 0:a910ddaef7c0 | 44 | device.frequency(5000000); |
Hotboards | 0:a910ddaef7c0 | 45 | // initialize internal lcd controller: |
Hotboards | 0:a910ddaef7c0 | 46 | display.init(); |
Hotboards | 0:a910ddaef7c0 | 47 | // Print a message to the LCD. |
Hotboards | 0:a910ddaef7c0 | 48 | display.printf( "Hello mbed!" ); |
Hotboards | 0:a910ddaef7c0 | 49 | |
Hotboards | 0:a910ddaef7c0 | 50 | while(1) |
Hotboards | 0:a910ddaef7c0 | 51 | { |
Hotboards | 0:a910ddaef7c0 | 52 | // set the cursor to column 0, line 1 |
Hotboards | 0:a910ddaef7c0 | 53 | // (note: line 1 is the second row, since counting begins with 0): |
Hotboards | 0:a910ddaef7c0 | 54 | display.setCursor( 0, 1 ); |
Hotboards | 0:a910ddaef7c0 | 55 | wait( 1 ); |
Hotboards | 0:a910ddaef7c0 | 56 | milis++; |
Hotboards | 0:a910ddaef7c0 | 57 | // print the number of seconds since reset: |
Hotboards | 0:a910ddaef7c0 | 58 | display.printf( " %d", milis ); |
Hotboards | 0:a910ddaef7c0 | 59 | } |
Hotboards | 0:a910ddaef7c0 | 60 | } |