Loïc Couillet
/
TP3_app-shield-joystick
edfds
Fork of TP3_app-shield-joystick by
main.cpp
- Committer:
- NoSense
- Date:
- 2016-09-28
- Revision:
- 5:64791f7d8708
- Parent:
- 4:dd6d3b44dcb9
File content as of revision 5:64791f7d8708:
#include "mbed.h" #include "C12832.h" DigitalIn up(A2); DigitalIn right(A5); DigitalIn center(D4); DigitalIn left(A4); DigitalIn down(A3); C12832 lcd(D11, D13, D12, D7, D10); void menu1(){ lcd.locate(10,0); lcd.printf("Matin"); lcd.locate(10,10); lcd.printf("Midi"); lcd.locate(10,20); lcd.printf("Soir"); } void menu2(){ lcd.locate(10,0); lcd.printf("Petit-dejeuner"); lcd.locate(10,10); lcd.printf("Dejeuner"); lcd.locate(10,20); lcd.printf("Diner"); } int i = 0; int k = 0; int out = 0; int main() { menu1(); lcd.locate(0,0); lcd.printf(">"); while(1){ if(down){ if(i==0){ lcd.cls(); menu1(); i++; lcd.locate(0,10); lcd.printf(">"); wait(0.8); } else if(i==1){ lcd.cls(); menu1(); i++; lcd.locate(0,20); lcd.printf(">"); wait(0.8); } } //fin if(down) if(up){ if(i==2){ lcd.cls(); menu1(); i--; lcd.locate(0,10); lcd.printf(">"); wait(0.8); } else if(i==1){ lcd.cls(); menu1(); i--; lcd.locate(0,0); lcd.printf(">"); wait(0.8); } } //fin if(up) if(right){ wait(0.8); lcd.cls(); menu2(); lcd.locate(0,0); lcd.printf(">"); while(left==0){ //bis if(down){ if(k==0){ lcd.cls(); menu2(); k++; lcd.locate(0,10); lcd.printf(">"); wait(0.8); } else if(k==1){ lcd.cls(); menu2(); k++; lcd.locate(0,20); lcd.printf(">"); wait(0.8); } } //fin if(down) if(up){ if(k==2){ lcd.cls(); menu2(); k--; lcd.locate(0,10); lcd.printf(">"); wait(0.8); } else if(k==1){ lcd.cls(); menu2(); k--; lcd.locate(0,0); lcd.printf(">"); wait(0.8); } } //fin if(up) if(right){ wait(0.8); while(left==0 || out==0){ if(i==0){ if(k==0){ lcd.cls(); lcd.locate(0,0); lcd.printf("Ok !"); out = 1; wait(2.5); } else if(k==1){ lcd.cls(); lcd.locate(0,0); lcd.printf("Trop tot"); out = 1; wait(2.5); } else if(k==2){ lcd.cls(); lcd.locate(0,0); lcd.printf("Trop tot"); out = 1; wait(2.5); } } //fin if(i==0); else if(i==1){ if(k==0){ lcd.cls(); lcd.locate(0,0); lcd.printf("Trop tard"); out = 1; wait(2.5); } else if(k==1){ lcd.cls(); lcd.locate(0,0); lcd.printf("Ok !"); out = 1; wait(2.5); } else if(k==2){ lcd.cls(); lcd.locate(0,0); lcd.printf("Trop tot"); out = 1; wait(2.5); } } //fin if(i==1) else if(i==2){ if(k==0){ lcd.cls(); lcd.locate(0,0); lcd.printf("Trop tard"); out = 1; wait(2.5); } else if(k==1){ lcd.cls(); lcd.locate(0,0); lcd.printf("Trop tard"); out = 1; wait(2.5); } else if(k==2){ lcd.cls(); lcd.locate(0,0); lcd.printf("Ok !"); out = 1; wait(2.5); } } //fin if(i==2); } //fin while(left==0) bis } //fin if(right) } //fin boucle while(left==0) lcd.cls(); menu1(); lcd.locate(0,0); lcd.printf(">"); i = 0; k = 0; } //fin if(right) } //fin boucle while(1) } //fin main