Demonstrates de setCursor funcion of Hotboards_SpiLcd Library
Dependencies: Hotboards_SpiLcd mbed
main.cpp@0:90058d9b164b, 2016-02-01 (annotated)
- Committer:
- Hotboards
- Date:
- Mon Feb 01 04:42:26 2016 +0000
- Revision:
- 0:90058d9b164b
This sketch prints "Row 1" in the upper row of the LCD; & prints "Row 2" in the lower row of the LCD,; Demonstrating the function setCursor.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Hotboards | 0:90058d9b164b | 1 | /* |
Hotboards | 0:90058d9b164b | 2 | Hotboards_SpiLcd Library - Writing in diferent rows |
Hotboards | 0:90058d9b164b | 3 | |
Hotboards | 0:90058d9b164b | 4 | Demonstrates the use a 16x2 LCD display, specially the function setCursor. |
Hotboards | 0:90058d9b164b | 5 | The Hotboards_SpiLcd library works with all LCD displays that are compatible with the |
Hotboards | 0:90058d9b164b | 6 | ST7032 driver presented on Spi Lcd board (http://www.hotboards.org). |
Hotboards | 0:90058d9b164b | 7 | |
Hotboards | 0:90058d9b164b | 8 | This sketch prints "Row 1" in the upper row of the LCD |
Hotboards | 0:90058d9b164b | 9 | & prints "Row 2" in the lower row of the LCD |
Hotboards | 0:90058d9b164b | 10 | |
Hotboards | 0:90058d9b164b | 11 | The circuit: |
Hotboards | 0:90058d9b164b | 12 | * BKL --> GND |
Hotboards | 0:90058d9b164b | 13 | * VDD --> 3.3v |
Hotboards | 0:90058d9b164b | 14 | * GND --> GND |
Hotboards | 0:90058d9b164b | 15 | * SCK --> PA_5 |
Hotboards | 0:90058d9b164b | 16 | * SI --> PA_6 |
Hotboards | 0:90058d9b164b | 17 | * CS --> PB_15 |
Hotboards | 0:90058d9b164b | 18 | * RS --> PB_14 |
Hotboards | 0:90058d9b164b | 19 | * RST --> PB_13 |
Hotboards | 0:90058d9b164b | 20 | |
Hotboards | 0:90058d9b164b | 21 | Library ported by Diego from Hotboards and originally created by |
Hotboards | 0:90058d9b164b | 22 | David A. Mellis |
Hotboards | 0:90058d9b164b | 23 | library modified 5 Jul 2009 |
Hotboards | 0:90058d9b164b | 24 | by Limor Fried (http://www.ladyada.net) |
Hotboards | 0:90058d9b164b | 25 | example added |
Hotboards | 0:90058d9b164b | 26 | by Pedro from Hotboards |
Hotboards | 0:90058d9b164b | 27 | This example code is in the public domain. |
Hotboards | 0:90058d9b164b | 28 | */ |
Hotboards | 0:90058d9b164b | 29 | #include "mbed.h" |
Hotboards | 0:90058d9b164b | 30 | #include "Hotboards_SpiLcd.h" |
Hotboards | 0:90058d9b164b | 31 | |
Hotboards | 0:90058d9b164b | 32 | /* initialize an instance of SPI bus,setting the SPI pins*/ |
Hotboards | 0:90058d9b164b | 33 | SPI device(PA_7,PA_6,PA_5); /* SO, SI, SCK*/ |
Hotboards | 0:90058d9b164b | 34 | /* initialize the library with the numbers of the interface pins*/ |
Hotboards | 0:90058d9b164b | 35 | Hotboards_SpiLcd display( device, PB_15, PB_14, PB_13 ); /* SPI, CS, RS, RST */ |
Hotboards | 0:90058d9b164b | 36 | |
Hotboards | 0:90058d9b164b | 37 | int main() |
Hotboards | 0:90058d9b164b | 38 | { |
Hotboards | 0:90058d9b164b | 39 | /* set the spi frequency to 5MHz*/ |
Hotboards | 0:90058d9b164b | 40 | device.frequency(5000000); |
Hotboards | 0:90058d9b164b | 41 | /* initialize internal lcd controller:*/ |
Hotboards | 0:90058d9b164b | 42 | display.init(); |
Hotboards | 0:90058d9b164b | 43 | /* Set Cursor on column 2 and Row 0*/ |
Hotboards | 0:90058d9b164b | 44 | display.setCursor(2,0); |
Hotboards | 0:90058d9b164b | 45 | /* Print a message */ |
Hotboards | 0:90058d9b164b | 46 | display.printf( "Row 1" ); |
Hotboards | 0:90058d9b164b | 47 | /* Set Cursor on column 4 and Row 1*/ |
Hotboards | 0:90058d9b164b | 48 | display.setCursor(4,1); |
Hotboards | 0:90058d9b164b | 49 | /* Print another message */ |
Hotboards | 0:90058d9b164b | 50 | display.printf( "Row 2" ); |
Hotboards | 0:90058d9b164b | 51 | |
Hotboards | 0:90058d9b164b | 52 | while(1) |
Hotboards | 0:90058d9b164b | 53 | { |
Hotboards | 0:90058d9b164b | 54 | /* infinite loop, doing nothing*/ |
Hotboards | 0:90058d9b164b | 55 | } |
Hotboards | 0:90058d9b164b | 56 | } |