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.
Fork of TextLCD by
MAIN.cpp@42:31cad388feaa, 2018-04-07 (annotated)
- Committer:
- salvatore93
- Date:
- Sat Apr 07 13:24:28 2018 +0000
- Revision:
- 42:31cad388feaa
xale
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
salvatore93 | 42:31cad388feaa | 1 | /**************************************************** |
salvatore93 | 42:31cad388feaa | 2 | * FAST PROTOTYPING WITH NUCLEO * |
salvatore93 | 42:31cad388feaa | 3 | * Example Code 05: LCDdisplay * |
salvatore93 | 42:31cad388feaa | 4 | * Author: Mauro D'Angelo * |
salvatore93 | 42:31cad388feaa | 5 | * Organization: Perlatecnica no-profit organization * |
salvatore93 | 42:31cad388feaa | 6 | *****************************************************/ |
salvatore93 | 42:31cad388feaa | 7 | |
salvatore93 | 42:31cad388feaa | 8 | #include "mbed.h" |
salvatore93 | 42:31cad388feaa | 9 | #include "TextLCD.h" |
salvatore93 | 42:31cad388feaa | 10 | |
salvatore93 | 42:31cad388feaa | 11 | |
salvatore93 | 42:31cad388feaa | 12 | // PCF8574T |
salvatore93 | 42:31cad388feaa | 13 | //#define SLAVEADDRESS 0x4E |
salvatore93 | 42:31cad388feaa | 14 | //PCF8574AT |
salvatore93 | 42:31cad388feaa | 15 | #define SLAVEADDRESS 0x7E |
salvatore93 | 42:31cad388feaa | 16 | |
salvatore93 | 42:31cad388feaa | 17 | // Instanzia un oggetto I2C assegnando i due pin SDA ed SCL |
salvatore93 | 42:31cad388feaa | 18 | I2C i2c_lcd(PB_9,PB_8); // SDA, SCL |
salvatore93 | 42:31cad388feaa | 19 | |
salvatore93 | 42:31cad388feaa | 20 | // Instanzia un oggetto TextLCD_I2C per la gestione del display via I2Cbus |
salvatore93 | 42:31cad388feaa | 21 | TextLCD_I2C lcd(&i2c_lcd,SLAVEADDRESS, TextLCD::LCD16x2); // I2C exp: I2C bus, PCF8574AT Slaveaddress, LCD Type |
salvatore93 | 42:31cad388feaa | 22 | |
salvatore93 | 42:31cad388feaa | 23 | //0x7e, |
salvatore93 | 42:31cad388feaa | 24 | int main() { |
salvatore93 | 42:31cad388feaa | 25 | // Spegne il cursore |
salvatore93 | 42:31cad388feaa | 26 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
salvatore93 | 42:31cad388feaa | 27 | |
salvatore93 | 42:31cad388feaa | 28 | // Pulisce lo schermo |
salvatore93 | 42:31cad388feaa | 29 | lcd.cls(); |
salvatore93 | 42:31cad388feaa | 30 | |
salvatore93 | 42:31cad388feaa | 31 | // Stampa sullo schermo |
salvatore93 | 42:31cad388feaa | 32 | lcd.printf("scherzo:"); |
salvatore93 | 42:31cad388feaa | 33 | |
salvatore93 | 42:31cad388feaa | 34 | // punta alla prima colonna del secondo rigo del display |
salvatore93 | 42:31cad388feaa | 35 | lcd.setAddress(0, 1); |
salvatore93 | 42:31cad388feaa | 36 | |
salvatore93 | 42:31cad388feaa | 37 | // Stampa sullo schermo |
salvatore93 | 42:31cad388feaa | 38 | lcd.printf("<3"); |
salvatore93 | 42:31cad388feaa | 39 | wait(2); |
salvatore93 | 42:31cad388feaa | 40 | } |