cavallera claude / Mbed 2 deprecated afficheur_grove_lcd_exo

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LCD.cpp Source File

LCD.cpp

00001 #include "mbed.h"
00002 #include "LCD.h"
00003 
00004 LCD::LCD(PinName sda, PinName scl):i2c(sda, scl)
00005 {
00006     init();
00007 }
00008 
00009 void LCD::clear()
00010 {
00011     sendCommand(????????);
00012     wait_us(1600);
00013 }
00014 
00015 void LCD::print(char *str)
00016 {
00017     data[0] = 0x40;
00018     while(*str) {
00019         data[1] = *str;
00020         i2c.write(LCD_ADDRESS, data, 2);
00021         str++;
00022     }
00023 }
00024 
00025 void LCD::cursor(char col, char row)
00026 {
00027     if(row == 0) {
00028         col = col | 0x80;
00029     } else {
00030         col = col | 0xc0;
00031     }
00032     sendCommand(col);
00033 }
00034 
00035 void LCD::sendCommand(char value)
00036 {
00037     data[0] = 0x80 ; // Co = 1, RS = 0 (Command transmitted)
00038     data[1] = value;
00039     i2c.write(LCD_ADDRESS, data, 2);
00040 }
00041 
00042 void LCD::init()
00043 {
00044     // Attendre au moins 30 ms après la mise en tension de la carte
00045     wait_ms(50);
00046     // Choisir le type d'affichage : 2 lignes de 5x8 points /caractère
00047     sendCommand(???????);
00048     // Attendre au moins 39 us
00049     wait_us(45);
00050     // Allumer l'afficheur, pas de curseur, il ne clignote pas
00051     sendCommand(??????);
00052     // Attendre au moins 39 us
00053     wait_us(45);
00054     // Effacer l'afficheur
00055     ??????????
00056     ??????????
00057     // Curseur se déplace à droite à chaque caractère, pas de "shift" de l'affichage
00058     sendCommand(0x06);
00059 }