|
1 | | -#include "mkrEthernetOled_menu.h" |
| 1 | +/* |
| 2 | + * Simple demo project that runs on our MKR1300 boards with Ethernet module |
| 3 | + * and OLED screen. It uses the fluent menu builder and all-in-one plugin |
| 4 | + * support added in 4.5. |
| 5 | + * |
| 6 | + * Setup: |
| 7 | + * |
| 8 | + * OLED: configured on standard I2C GPIOs using an SH1106 driver. |
| 9 | + * Ethernet: We have the regular MKR ethernet shield. |
| 10 | + * Menu, a simple menu structure defined in TcMenu Designer Turbo |
| 11 | + * |
| 12 | + * To build your own menu: https://designer.thecoderscorner.com/ |
| 13 | + * Getting started: https://www.thecoderscorner.com/products/apps/tcmenu-designer/ |
| 14 | + * Documentation: https://tcmenu.github.io/documentation/ |
| 15 | + */ |
| 16 | + |
| 17 | +#include "MkrEthernetOLED_menu.h" |
2 | 18 |
|
3 | 19 | // This variable is the RAM data for scroll choice item Foods |
4 | | -// 1234567890 1234567890 1234567890 1234567890 1234567890 |
5 | | -char ScrollRam[] = "Pizza\0 Pasta \0Salad\0 Apple\0 Orange\0 ~"; |
| 20 | +char ScrollRam[] = "1\0 2\0 3\0 4\0 5\0 ~"; |
6 | 21 |
|
7 | 22 |
|
8 | 23 | void setup() { |
9 | | - while (!Serial && millis() < 15000) { |
10 | | - } |
| 24 | + // On SAMD/MKR it's best to wait for the serial port to start before proceeding. |
| 25 | + while (!Serial && millis() < 15000) {} |
| 26 | + |
| 27 | + // Before we do anything else, we start things up. |
11 | 28 | Serial.begin(115200); |
12 | 29 | Wire.begin(); |
13 | | - serlogF(SER_DEBUG, "TcMenu MKR example starting"); |
| 30 | + |
| 31 | + serEnableLevel(SER_TCMENU_DEBUG, true); |
| 32 | + |
| 33 | + // in TcMenu we set up the menu using this method. |
14 | 34 | setupMenu(); |
15 | | - serlogF(SER_DEBUG, "TcMenu MKR example started"); |
| 35 | + serlogF(SER_TCMENU_DEBUG, "Menu setup complete"); |
16 | 36 |
|
| 37 | + // here we use task manager to schedule some tasks to happen ever 500 millis |
| 38 | + // https://tcmenu.github.io/documentation/arduino-libraries/taskmanager-io/task-manager-scheduling-guide/ |
| 39 | + taskManager.schedule(repeatMillis(500), [] { |
| 40 | + // Here we adjust some menu items at runtime, every 500 millis. |
| 41 | + //https://tcmenu.github.io/documentation/arduino-libraries/tc-menu/menu-item-types/ |
| 42 | + getAnalogItemById(MENU_KITCHEN_ID).setCurrentValue(random(100)); |
| 43 | + getAnalogItemById(MENU_LOUNGE_ID).setCurrentValue(random(100)); |
| 44 | + // menuKitchen.setCurrentValue(random(100)); |
| 45 | + // menuLounge.setCurrentValue(random(100)); |
| 46 | + }); |
17 | 47 | } |
18 | 48 |
|
| 49 | +// All TcMenu projects use taskmanager |
19 | 50 | void loop() { |
20 | 51 | taskManager.runLoop(); |
21 | | - |
22 | 52 | } |
0 commit comments