Robert Tomczak
/
TP3_app-shield-joystick
TPN°3 joystick BTS SNEC Amiens
Fork of app-shield-joystick by
main.cpp
- Committer:
- rtk
- Date:
- 2021-10-10
- Revision:
- 5:d879f538c159
- Parent:
- 4:dd6d3b44dcb9
File content as of revision 5:d879f538c159:
#include "mbed.h" #include "C12832.h" DigitalIn up(A2); DigitalIn down(A3); DigitalIn left(A4); DigitalIn right(A5); DigitalIn center(D4); C12832 lcd(D11, D13, D12, D7, D10); enum {MATIN,MIDI,SOIR, PETIT, DEJ,DINER} etat = MATIN; int menu_precedent = MIDI; char message_precedent[]=" "; void Afficher_Menu(int Menu) { if (menu_precedent == Menu) return; menu_precedent = Menu; lcd.cls(); lcd.locate(0,8); //wait(0.050); switch(Menu) { case MATIN : lcd.printf("Matin"); break; case MIDI : lcd.printf("Midi"); break; case SOIR : lcd.printf("Soir"); break; case PETIT : lcd.printf("Petit dejeuner"); break; case DEJ : lcd.printf("Dejeuner"); break; case DINER : lcd.printf("Diner"); break; } } void Afficher_Message(char *Message) { if (strcmp(message_precedent,Message) ==0) return; lcd.cls(); lcd.locate(0,8); lcd.printf(Message); } void Menu_Matin(int etat) { bool Sortir = false; // On sort du sous-menu while (!Sortir) { Afficher_Menu(etat); switch (etat) { case PETIT : // évèments if (left) { etat = MATIN; Sortir=true; } if (right) etat=DEJ; if (center)Afficher_Message("Ok"); break; case DEJ : // évèments break; case DINER : } wait(0.125); } } int main() { while (1) { Afficher_Menu(etat); switch (etat) { case MATIN : // évèments if (down) etat = MIDI; if (right) Menu_Matin(PETIT); break; case MIDI : break; case SOIR : break; } } }