To add new functions to HACKRWATCH, follow these steps
-
Assign a sequential number to the switcher, comment this on the switcher comment around line 41
-
Add 2 methods, a loop and a setup. This follows the same execution style of how Arduino does setup() and loop(). Use comments to seperate the methods(Eventually this should be seperated into files)
-
Add your methods to the case statements at the bottom of the code
For this example we will add a new app to the main menu
Locate the main menu comment, and find the mmenu[]
Add your entry to the array, along with the switch code you added to the switcher.
Set rstOverride
to true.
Make sure to set this to false while switching!
Paste the following code to switch
isSwitching = true;
current_proc = <SWITCHER NUMBER>;
On the next loop, the setup method for the other app will be called.
When you want to switch, generally you should clear the LCD and set the rotation to the direction your app needs
For example, this is the clock setup:
void clock_setup() {
M5.Lcd.setRotation(rotation);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setTextSize(1);
}
Note the setRoation call, rotation is going to be your landscape rotation set in the EEPROM. If you want to use portrait, use 0.