Mike EI2I
/
LCDCptS
Gestion d'un compteur de seconde sur l'écran LCD
main.cpp@0:389f59556837, 2015-03-25 (annotated)
- Committer:
- Kemix
- Date:
- Wed Mar 25 08:17:15 2015 +0000
- Revision:
- 0:389f59556837
Debut du programme
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kemix | 0:389f59556837 | 1 | #include "mbed.h" |
Kemix | 0:389f59556837 | 2 | |
Kemix | 0:389f59556837 | 3 | I2C link(I2C_SDA, I2C_SCL); |
Kemix | 0:389f59556837 | 4 | const int addr = 0x7C; |
Kemix | 0:389f59556837 | 5 | |
Kemix | 0:389f59556837 | 6 | void Init(void){ |
Kemix | 0:389f59556837 | 7 | char cmd[2]; |
Kemix | 0:389f59556837 | 8 | cmd[0] = 0x80; |
Kemix | 0:389f59556837 | 9 | cmd[1] = 0x3F; |
Kemix | 0:389f59556837 | 10 | link.write(addr,cmd,2); |
Kemix | 0:389f59556837 | 11 | wait_us(100); |
Kemix | 0:389f59556837 | 12 | |
Kemix | 0:389f59556837 | 13 | cmd[1] = 0x0F; |
Kemix | 0:389f59556837 | 14 | link.write(addr,cmd,2); |
Kemix | 0:389f59556837 | 15 | wait_us(100); |
Kemix | 0:389f59556837 | 16 | |
Kemix | 0:389f59556837 | 17 | cmd[1] = 0x01; |
Kemix | 0:389f59556837 | 18 | link.write(addr,cmd,2); |
Kemix | 0:389f59556837 | 19 | wait_ms(2); |
Kemix | 0:389f59556837 | 20 | |
Kemix | 0:389f59556837 | 21 | cmd[1] = 0x06; |
Kemix | 0:389f59556837 | 22 | link.write(addr,cmd,2); |
Kemix | 0:389f59556837 | 23 | |
Kemix | 0:389f59556837 | 24 | cmd[1] = 0xC0; |
Kemix | 0:389f59556837 | 25 | link.write(addr,cmd,2); |
Kemix | 0:389f59556837 | 26 | wait_us(100); |
Kemix | 0:389f59556837 | 27 | } |
Kemix | 0:389f59556837 | 28 | |
Kemix | 0:389f59556837 | 29 | |
Kemix | 0:389f59556837 | 30 | int main(void){ |
Kemix | 0:389f59556837 | 31 | char data[3]; |
Kemix | 0:389f59556837 | 32 | |
Kemix | 0:389f59556837 | 33 | data[0] = 0x40; |
Kemix | 0:389f59556837 | 34 | data[1] = '0'; |
Kemix | 0:389f59556837 | 35 | data[2] = '0'; |
Kemix | 0:389f59556837 | 36 | |
Kemix | 0:389f59556837 | 37 | while(1){ |
Kemix | 0:389f59556837 | 38 | Init(); |
Kemix | 0:389f59556837 | 39 | link.write(addr,data,3); |
Kemix | 0:389f59556837 | 40 | if (data[2] < '9'){ |
Kemix | 0:389f59556837 | 41 | data[2]++; |
Kemix | 0:389f59556837 | 42 | }else{ |
Kemix | 0:389f59556837 | 43 | data[2] = '0'; |
Kemix | 0:389f59556837 | 44 | if(data[1] < '5'){ |
Kemix | 0:389f59556837 | 45 | data[1]++; |
Kemix | 0:389f59556837 | 46 | }else{ |
Kemix | 0:389f59556837 | 47 | data[1] = '0'; |
Kemix | 0:389f59556837 | 48 | } |
Kemix | 0:389f59556837 | 49 | } |
Kemix | 0:389f59556837 | 50 | wait(0.5); |
Kemix | 0:389f59556837 | 51 | } |
Kemix | 0:389f59556837 | 52 | } |