Librarie pour ecran 128x32 de MyLab
menu.cpp@12:00bbd42614c7, 2016-03-29 (annotated)
- Committer:
- lucas_favre
- Date:
- Tue Mar 29 18:56:20 2016 +0000
- Revision:
- 12:00bbd42614c7
- Parent:
- 11:c00a727f140f
- Child:
- 13:337e207baca2
V2.0 fonctionnel
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lucas_favre | 11:c00a727f140f | 1 | # include"C12832.h" |
lucas_favre | 11:c00a727f140f | 2 | |
lucas_favre | 11:c00a727f140f | 3 | #include "MyLab_Lib.h" |
lucas_favre | 11:c00a727f140f | 4 | |
lucas_favre | 11:c00a727f140f | 5 | bool connected = false; |
lucas_favre | 11:c00a727f140f | 6 | char* joystickPos = "CENTRE"; |
lucas_favre | 11:c00a727f140f | 7 | int blink_interval = 0; |
lucas_favre | 11:c00a727f140f | 8 | int select_app =0; |
lucas_favre | 11:c00a727f140f | 9 | static int menuItem =0; |
lucas_favre | 11:c00a727f140f | 10 | |
lucas_favre | 11:c00a727f140f | 11 | |
lucas_favre | 11:c00a727f140f | 12 | |
lucas_favre | 12:00bbd42614c7 | 13 | extern MyLab periph; |
lucas_favre | 11:c00a727f140f | 14 | void printMenu(int menuItem) |
lucas_favre | 11:c00a727f140f | 15 | { |
lucas_favre | 11:c00a727f140f | 16 | lcd.cls(); |
lucas_favre | 11:c00a727f140f | 17 | lcd.locate(0,0); |
lucas_favre | 11:c00a727f140f | 18 | switch (menuItem) |
lucas_favre | 11:c00a727f140f | 19 | { |
lucas_favre | 11:c00a727f140f | 20 | case 0: |
lucas_favre | 11:c00a727f140f | 21 | lcd.printf("ARM mBed IoT App"); |
lucas_favre | 11:c00a727f140f | 22 | lcd.locate(0,16); |
lucas_favre | 11:c00a727f140f | 23 | lcd.printf("Scroll with joystick"); |
lucas_favre | 11:c00a727f140f | 24 | break; |
lucas_favre | 11:c00a727f140f | 25 | case 1: |
lucas_favre | 11:c00a727f140f | 26 | lcd.printf("Websocket App"); |
lucas_favre | 11:c00a727f140f | 27 | lcd.locate(0,16); |
lucas_favre | 11:c00a727f140f | 28 | lcd.printf("Click center to Start Snake"); |
lucas_favre | 11:c00a727f140f | 29 | break; |
lucas_favre | 11:c00a727f140f | 30 | case 2: |
lucas_favre | 11:c00a727f140f | 31 | lcd.printf("MQTT App:"); |
lucas_favre | 11:c00a727f140f | 32 | lcd.locate(0,16); |
lucas_favre | 11:c00a727f140f | 33 | lcd.printf("Click center to Start"); |
lucas_favre | 11:c00a727f140f | 34 | break; |
lucas_favre | 11:c00a727f140f | 35 | case 3: |
lucas_favre | 11:c00a727f140f | 36 | lcd.printf("Credits"); |
lucas_favre | 11:c00a727f140f | 37 | lcd.locate(0,16); |
lucas_favre | 11:c00a727f140f | 38 | lcd.printf("Favre Lucas ITI3 Hepia "); |
lucas_favre | 11:c00a727f140f | 39 | break; |
lucas_favre | 11:c00a727f140f | 40 | } |
lucas_favre | 11:c00a727f140f | 41 | } |
lucas_favre | 11:c00a727f140f | 42 | int setMenu() |
lucas_favre | 11:c00a727f140f | 43 | { |
lucas_favre | 12:00bbd42614c7 | 44 | char pos[6]; |
lucas_favre | 12:00bbd42614c7 | 45 | periph.JoyStick_Position(pos); |
lucas_favre | 11:c00a727f140f | 46 | |
lucas_favre | 12:00bbd42614c7 | 47 | if (strcmp(pos,"South") == 0) |
lucas_favre | 11:c00a727f140f | 48 | { |
lucas_favre | 11:c00a727f140f | 49 | joystickPos = "DOWN"; |
lucas_favre | 11:c00a727f140f | 50 | if (menuItem >= 0 && menuItem < 3) |
lucas_favre | 11:c00a727f140f | 51 | printMenu(++menuItem); |
lucas_favre | 11:c00a727f140f | 52 | } |
lucas_favre | 12:00bbd42614c7 | 53 | else if (strcmp(pos,"Center") == 0){ |
lucas_favre | 11:c00a727f140f | 54 | if (menuItem == 1) |
lucas_favre | 11:c00a727f140f | 55 | select_app = 1; |
lucas_favre | 11:c00a727f140f | 56 | else if(menuItem == 2) |
lucas_favre | 11:c00a727f140f | 57 | select_app = 2; |
lucas_favre | 11:c00a727f140f | 58 | joystickPos = "CLICK"; |
lucas_favre | 11:c00a727f140f | 59 | } |
lucas_favre | 12:00bbd42614c7 | 60 | else if (strcmp(pos,"North") == 0) |
lucas_favre | 11:c00a727f140f | 61 | { |
lucas_favre | 11:c00a727f140f | 62 | joystickPos = "UP"; |
lucas_favre | 11:c00a727f140f | 63 | if (menuItem <= 3 && menuItem > 0) |
lucas_favre | 11:c00a727f140f | 64 | printMenu(--menuItem); |
lucas_favre | 11:c00a727f140f | 65 | } |
lucas_favre | 11:c00a727f140f | 66 | return select_app; |
lucas_favre | 11:c00a727f140f | 67 | } |
lucas_favre | 11:c00a727f140f | 68 | |
lucas_favre | 11:c00a727f140f | 69 |