animation effect (EFFC) toggle option
This commit is contained in:
parent
242adc47de
commit
e89570b136
|
@ -30,7 +30,8 @@ MemSlot memory[] = //128 bytes for the Teensy LC
|
||||||
{"bt10", 11, 0},
|
{"bt10", 11, 0},
|
||||||
{"bt11", 12, 0},
|
{"bt11", 12, 0},
|
||||||
{"bt12", 13, 0},
|
{"bt12", 13, 0},
|
||||||
{"reset", 0, 0}, //255 = reset eeprom
|
{"effc", 14, 1},
|
||||||
|
{"reset", 0, 0}, // != 0 -> reset eeprom
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ MenuItem menuEntries[] =
|
||||||
{
|
{
|
||||||
{"", true, "prst"},
|
{"", true, "prst"},
|
||||||
{"", false, "butt"},
|
{"", false, "butt"},
|
||||||
|
{"", true, "effc"},
|
||||||
{"", true, "reset"},
|
{"", true, "reset"},
|
||||||
{"/butt", true, "bt1"},
|
{"/butt", true, "bt1"},
|
||||||
{"/butt", true, "bt2"},
|
{"/butt", true, "bt2"},
|
||||||
|
@ -138,6 +140,7 @@ bool animationPlaying = false;
|
||||||
unsigned int animationLastFrameMillis = 0;
|
unsigned int animationLastFrameMillis = 0;
|
||||||
unsigned int animationFrameDelayMillis = 64;
|
unsigned int animationFrameDelayMillis = 64;
|
||||||
bool animationLooping = false;
|
bool animationLooping = false;
|
||||||
|
bool animationEnabled = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* time cooldown managment
|
* time cooldown managment
|
||||||
|
@ -155,32 +158,13 @@ unsigned int sevSegCoolDown = 5000;
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println("setup start");
|
Serial.println("setup start");
|
||||||
|
|
||||||
//write eeprom first init
|
//memory
|
||||||
byte memValue = EEPROM.read(0);
|
initEepromMemory();
|
||||||
if (memValue == 255) // cannot find settings, writes defualt ones
|
|
||||||
{
|
|
||||||
for (byte i = 0; i < (sizeof(memory)/sizeof(MemSlot)); i++)
|
|
||||||
{
|
|
||||||
EEPROM.write(memory[i].address, memory[i].value);
|
|
||||||
}
|
|
||||||
EEPROM.write(0,1);
|
|
||||||
}
|
|
||||||
//read eeprom
|
|
||||||
for (byte i = 0; i < (sizeof(memory)/sizeof(MemSlot)); i++)
|
|
||||||
{
|
|
||||||
memory[i].value = EEPROM.read(memory[i].address);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Init display
|
applyMemoryChange();
|
||||||
byte numDigits = 4;
|
|
||||||
byte digitPins[] = {7, 8, 9, 6};
|
|
||||||
byte segmentPins[] = {10, 12, 14, 16, 17, 11, 13, 15};
|
|
||||||
|
|
||||||
bool resistorsOnSegments = true;
|
//display
|
||||||
//bool updateWithDelaysIn = true;
|
initSevSegDisplay();
|
||||||
byte hardwareConfig = COMMON_CATHODE;
|
|
||||||
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
|
|
||||||
sevseg.setBrightness(90);
|
|
||||||
|
|
||||||
//Init rotary encoders
|
//Init rotary encoders
|
||||||
rotaryEncoder.setDebounceDelay(2);
|
rotaryEncoder.setDebounceDelay(2);
|
||||||
|
@ -200,13 +184,46 @@ unsigned int sevSegCoolDown = 5000;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initEepromMemory()
|
||||||
|
{
|
||||||
|
//write eeprom first init
|
||||||
|
byte memValue = EEPROM.read(0);
|
||||||
|
if (memValue > 0) // cannot find settings, writes default ones
|
||||||
|
{
|
||||||
|
for (byte i = 0; i < (sizeof(memory)/sizeof(MemSlot)); i++)
|
||||||
|
{
|
||||||
|
EEPROM.write(memory[i].address, memory[i].value);
|
||||||
|
}
|
||||||
|
EEPROM.write(getMemorySlot("reset")->address,0);
|
||||||
|
}
|
||||||
|
//read eeprom
|
||||||
|
for (byte i = 0; i < (sizeof(memory)/sizeof(MemSlot)); i++)
|
||||||
|
{
|
||||||
|
memory[i].value = EEPROM.read(memory[i].address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void initSevSegDisplay()
|
||||||
|
{
|
||||||
|
//Init display
|
||||||
|
byte numDigits = 4;
|
||||||
|
byte digitPins[] = {7, 8, 9, 6};
|
||||||
|
byte segmentPins[] = {10, 12, 14, 16, 17, 11, 13, 15};
|
||||||
|
|
||||||
|
bool resistorsOnSegments = true;
|
||||||
|
//bool updateWithDelaysIn = true;
|
||||||
|
byte hardwareConfig = COMMON_CATHODE;
|
||||||
|
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
|
||||||
|
sevseg.setBrightness(90);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tick Loop
|
* Tick Loop
|
||||||
*/
|
*/
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
//animation draw tick
|
//animation draw tick
|
||||||
if (animationPlaying && millis() > (animationLastFrameMillis + animationFrameDelayMillis))
|
if (animationEnabled && animationPlaying && millis() > (animationLastFrameMillis + animationFrameDelayMillis))
|
||||||
{
|
{
|
||||||
drawAnimation(animationLooping);
|
drawAnimation(animationLooping);
|
||||||
animationLastFrameMillis = millis();
|
animationLastFrameMillis = millis();
|
||||||
|
@ -306,7 +323,7 @@ void menuBack()
|
||||||
isInMenu = false;
|
isInMenu = false;
|
||||||
menuSelectionIndex = 0;
|
menuSelectionIndex = 0;
|
||||||
menuCurrentPath = "";
|
menuCurrentPath = "";
|
||||||
sevseg.blank();
|
playAnimation(3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -400,11 +417,17 @@ bool menuSetValue(String variableName, byte newValue)
|
||||||
if (memorySlot != NULL)
|
if (memorySlot != NULL)
|
||||||
{
|
{
|
||||||
memorySlot->value = newValue;
|
memorySlot->value = newValue;
|
||||||
|
applyMemoryChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void applyMemoryChange()
|
||||||
|
{
|
||||||
|
animationEnabled = (getMemorySlot("effc")->value > 0);
|
||||||
|
}
|
||||||
|
|
||||||
int menuGetSelectionIndexFromPath(String path)
|
int menuGetSelectionIndexFromPath(String path)
|
||||||
{
|
{
|
||||||
int correspondingPathItemIndex = 0;
|
int correspondingPathItemIndex = 0;
|
||||||
|
@ -480,7 +503,7 @@ void sendInputOuput(int input)
|
||||||
if (isInMenu)
|
if (isInMenu)
|
||||||
{
|
{
|
||||||
menuBack();
|
menuBack();
|
||||||
playAnimation(3);
|
//playAnimation(3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue