From 90e0f98b926c2b150e1705a8bf7d52c02e007564 Mon Sep 17 00:00:00 2001 From: Jeremie GABOLDE Date: Thu, 22 Sep 2022 00:32:30 +0200 Subject: [PATCH] variable framerate (anim effect) --- Maybe/Maybe.ino | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Maybe/Maybe.ino b/Maybe/Maybe.ino index 72ba351..0a64554 100644 --- a/Maybe/Maybe.ino +++ b/Maybe/Maybe.ino @@ -17,7 +17,7 @@ struct MemSlot MemSlot memory[] = //128 bytes for the Teensy LC { - {"prst", 1, 0}, //preset + {"alt", 1, 0}, //preset {"bt1", 2, 0}, //button mode (0 = default, 1 = toggle) {"bt2", 3, 0}, {"bt3", 4, 0}, @@ -31,7 +31,8 @@ MemSlot memory[] = //128 bytes for the Teensy LC {"bt11", 12, 0}, {"bt12", 13, 0}, {"effc", 14, 1}, - {"reset", 0, 0}, // != 0 -> reset eeprom + {"afps", 15, 24}, + {"clea", 0, 0}, // != 0 -> reset eeprom }; @@ -49,22 +50,23 @@ struct MenuItem MenuItem menuEntries[] = { - {"", true, "prst"}, - {"", false, "butt"}, + {"", true, "alt"}, + {"", false, "btn"}, {"", true, "effc"}, - {"", true, "reset"}, - {"/butt", true, "bt1"}, - {"/butt", true, "bt2"}, - {"/butt", true, "bt3"}, - {"/butt", true, "bt4"}, - {"/butt", true, "bt5"}, - {"/butt", true, "bt6"}, - {"/butt", true, "bt7"}, - {"/butt", true, "bt8"}, - {"/butt", true, "bt9"}, - {"/butt", true, "bt10"}, - {"/butt", true, "bt11"}, - {"/butt", true, "bt12"}, + {"", true, "afps"}, + {"", true, "clea"}, + {"/btn", true, "bt1"}, + {"/btn", true, "bt2"}, + {"/btn", true, "bt3"}, + {"/btn", true, "bt4"}, + {"/btn", true, "bt5"}, + {"/btn", true, "bt6"}, + {"/btn", true, "bt7"}, + {"/btn", true, "bt8"}, + {"/btn", true, "bt9"}, + {"/btn", true, "bt10"}, + {"/btn", true, "bt11"}, + {"/btn", true, "bt12"}, }; String menuCurrentPath = ""; @@ -194,7 +196,7 @@ void initEepromMemory() { EEPROM.write(memory[i].address, memory[i].value); } - EEPROM.write(getMemorySlot("reset")->address,0); + EEPROM.write(getMemorySlot("clea")->address,0); } //read eeprom for (byte i = 0; i < (sizeof(memory)/sizeof(MemSlot)); i++) @@ -427,6 +429,7 @@ bool menuSetValue(String variableName, byte newValue) void applyMemoryChange() { animationEnabled = (getMemorySlot("effc")->value > 0); + animationFrameDelayMillis = 1000 / max(1, getMemorySlot("afps")->value); } int menuGetSelectionIndexFromPath(String path) @@ -466,7 +469,7 @@ void sendInputOuput(int input) { int numberOfModes = sizeof(modes)/(sizeof(Action)*15); - int currentMode = (getMemorySlot("prst")->value) % numberOfModes; + int currentMode = (getMemorySlot("alt")->value) % numberOfModes; //Hardware inputs ordered from the bottom left = 1 to the top right = 12 on the switch matrix, Action actionToRun = modes[currentMode][input-1]; //getting the virtual inputs from the modes array. //Inputs uids starts with 1, so input - 1 to get the index 0 of the array