Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Hotboards_SpiLcd mbed
main.cpp
00001 /* 00002 Hotboards_SpiLcd - TextDirection 00003 Demonstrates the use a 16x2 LCD display. The Hotboards_SpiLcd 00004 library works with all LCD displays that are compatible with the 00005 ST7032 driver presented on Spi Lcd board (http://www.hotboards.org). 00006 This sketch demonstrates how to use leftToRight() and rightToLeft() 00007 to move the cursor. 00008 The circuit: 00009 * BKL --> GND 00010 * VDD --> 3.3v 00011 * GND --> GND 00012 * SCK --> PA_5 00013 * SI --> PA_6 00014 * CS --> PB_15 00015 * RS --> PB_14 00016 * RST --> PB_13 00017 Library and example ported by Diego from Hotboards and originally created 00018 by David A. Mellis 00019 library modified 5 Jul 2009 00020 by Limor Fried (http://www.ladyada.net) 00021 example added 9 Jul 2009 00022 by Tom Igoe 00023 modified 22 Nov 2010 00024 by Tom Igoe 00025 */ 00026 #include "mbed.h" 00027 #include "Hotboards_SpiLcd.h" 00028 00029 /* initialize an instance of SPI bus,setting the SPI pins*/ 00030 SPI device(PA_7,PA_6,PA_5); /* SO, SI, SCK*/ 00031 /* initialize the library with the numbers of the interface pins*/ 00032 Hotboards_SpiLcd display( device, PB_15, PB_14, PB_13 ); /* SPI, CS, RS, RST */ 00033 00034 int thisChar = 'a'; 00035 00036 int main() 00037 { 00038 /* set the spi frequency to 5MHz*/ 00039 device.frequency(5000000); 00040 /* initialize internal lcd controller:*/ 00041 display.init(); 00042 // turn on the cursor: 00043 display.cursor(); 00044 00045 while(1) 00046 { 00047 // reverse directions at 'm': 00048 if (thisChar == 'm') 00049 { 00050 // go right for the next letter 00051 display.rightToLeft(); 00052 } 00053 // reverse again at 's': 00054 if (thisChar == 's') 00055 { 00056 // go left for the next letter 00057 display.leftToRight(); 00058 } 00059 // reset at 'z': 00060 if (thisChar > 'z') 00061 { 00062 // go to (0,0): 00063 display.home(); 00064 // start again at 0 00065 thisChar = 'a'; 00066 } 00067 // print the character 00068 display.printf("%c",thisChar); 00069 // wait a second: 00070 wait(1); 00071 // increment the letter: 00072 thisChar++; 00073 } 00074 }
Generated on Tue Jul 26 2022 09:42:55 by
1.7.2