This sketch prints to all the positions of the LCD using the setCursor() method.
Dependencies: Hotboards_SpiLcd mbed
main.cpp@0:9278fbadebb5, 2016-02-02 (annotated)
- Committer:
- Hotboards
- Date:
- Tue Feb 02 22:36:55 2016 +0000
- Revision:
- 0:9278fbadebb5
First Release: Hotboards_SpiLcd_setCursor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Hotboards | 0:9278fbadebb5 | 1 | /* |
Hotboards | 0:9278fbadebb5 | 2 | Hotboards_SpiLcd Library - setCursor |
Hotboards | 0:9278fbadebb5 | 3 | Demonstrates the use a 16x2 LCD display. The Hotboards_SpiLcd |
Hotboards | 0:9278fbadebb5 | 4 | library works with all LCD displays that are compatible with the |
Hotboards | 0:9278fbadebb5 | 5 | ST7032 driver presented on Spi Lcd board (http://www.hotboards.org). |
Hotboards | 0:9278fbadebb5 | 6 | This sketch prints to all the positions of the LCD using the |
Hotboards | 0:9278fbadebb5 | 7 | setCursor() method: |
Hotboards | 0:9278fbadebb5 | 8 | |
Hotboards | 0:9278fbadebb5 | 9 | The circuit: |
Hotboards | 0:9278fbadebb5 | 10 | * BKL --> GND |
Hotboards | 0:9278fbadebb5 | 11 | * VDD --> 3.3v |
Hotboards | 0:9278fbadebb5 | 12 | * GND --> GND |
Hotboards | 0:9278fbadebb5 | 13 | * SCK --> PA_5 |
Hotboards | 0:9278fbadebb5 | 14 | * SI --> PA_6 |
Hotboards | 0:9278fbadebb5 | 15 | * CS --> PB_15 |
Hotboards | 0:9278fbadebb5 | 16 | * RS --> PB_14 |
Hotboards | 0:9278fbadebb5 | 17 | * RST --> PB_13 |
Hotboards | 0:9278fbadebb5 | 18 | |
Hotboards | 0:9278fbadebb5 | 19 | Library and example ported by Diego from Hotboards and originally created |
Hotboards | 0:9278fbadebb5 | 20 | by David A. Mellis |
Hotboards | 0:9278fbadebb5 | 21 | library modified 5 Jul 2009 |
Hotboards | 0:9278fbadebb5 | 22 | by Limor Fried (http://www.ladyada.net) |
Hotboards | 0:9278fbadebb5 | 23 | example added 9 Jul 2009 |
Hotboards | 0:9278fbadebb5 | 24 | by Tom Igoe |
Hotboards | 0:9278fbadebb5 | 25 | modified 22 Nov 2010 |
Hotboards | 0:9278fbadebb5 | 26 | by Tom Igoe |
Hotboards | 0:9278fbadebb5 | 27 | */ |
Hotboards | 0:9278fbadebb5 | 28 | |
Hotboards | 0:9278fbadebb5 | 29 | #include "mbed.h" |
Hotboards | 0:9278fbadebb5 | 30 | #include "Hotboards_SpiLcd.h" |
Hotboards | 0:9278fbadebb5 | 31 | |
Hotboards | 0:9278fbadebb5 | 32 | /* initialize an instance of SPI bus,setting the SPI pins*/ |
Hotboards | 0:9278fbadebb5 | 33 | SPI device(PA_7,PA_6,PA_5); /* SO, SI, SCK*/ |
Hotboards | 0:9278fbadebb5 | 34 | /* initialize the library with the numbers of the interface pins*/ |
Hotboards | 0:9278fbadebb5 | 35 | Hotboards_SpiLcd display( device, PB_15, PB_14, PB_13 ); /* SPI, CS, RS, RST */ |
Hotboards | 0:9278fbadebb5 | 36 | |
Hotboards | 0:9278fbadebb5 | 37 | |
Hotboards | 0:9278fbadebb5 | 38 | int main() |
Hotboards | 0:9278fbadebb5 | 39 | { |
Hotboards | 0:9278fbadebb5 | 40 | /* set the spi frequency to 5MHz*/ |
Hotboards | 0:9278fbadebb5 | 41 | device.frequency(5000000); |
Hotboards | 0:9278fbadebb5 | 42 | /* initialize internal lcd controller:*/ |
Hotboards | 0:9278fbadebb5 | 43 | display.init(); |
Hotboards | 0:9278fbadebb5 | 44 | |
Hotboards | 0:9278fbadebb5 | 45 | while(1) |
Hotboards | 0:9278fbadebb5 | 46 | { |
Hotboards | 0:9278fbadebb5 | 47 | // loop from ASCII 'a' to ASCII 'z': |
Hotboards | 0:9278fbadebb5 | 48 | for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) |
Hotboards | 0:9278fbadebb5 | 49 | { |
Hotboards | 0:9278fbadebb5 | 50 | // loop over the columns: |
Hotboards | 0:9278fbadebb5 | 51 | for (int thisRow = 0; thisRow < 2; thisRow++) |
Hotboards | 0:9278fbadebb5 | 52 | { |
Hotboards | 0:9278fbadebb5 | 53 | // loop over the rows: |
Hotboards | 0:9278fbadebb5 | 54 | for (int thisCol = 0; thisCol < 16; thisCol++) |
Hotboards | 0:9278fbadebb5 | 55 | { |
Hotboards | 0:9278fbadebb5 | 56 | // set the cursor position: |
Hotboards | 0:9278fbadebb5 | 57 | display.setCursor(thisCol, thisRow); |
Hotboards | 0:9278fbadebb5 | 58 | // print the letter: |
Hotboards | 0:9278fbadebb5 | 59 | display.printf("%c",thisLetter); |
Hotboards | 0:9278fbadebb5 | 60 | wait(0.2); |
Hotboards | 0:9278fbadebb5 | 61 | } |
Hotboards | 0:9278fbadebb5 | 62 | } |
Hotboards | 0:9278fbadebb5 | 63 | } |
Hotboards | 0:9278fbadebb5 | 64 | } |
Hotboards | 0:9278fbadebb5 | 65 | } |