button mode (toggle)
This commit is contained in:
parent
c5da2ee8d3
commit
242adc47de
|
@ -17,9 +17,20 @@ struct MemSlot
|
||||||
|
|
||||||
MemSlot memory[] = //128 bytes for the Teensy LC
|
MemSlot memory[] = //128 bytes for the Teensy LC
|
||||||
{
|
{
|
||||||
{"prst", 1, 0},
|
{"prst", 1, 0}, //preset
|
||||||
{"p2_1", 2, 63},
|
{"bt1", 2, 0}, //button mode (0 = default, 1 = toggle)
|
||||||
{"p2_2", 3, 63},
|
{"bt2", 3, 0},
|
||||||
|
{"bt3", 4, 0},
|
||||||
|
{"bt4", 5, 0},
|
||||||
|
{"bt5", 6, 0},
|
||||||
|
{"bt6", 7, 0},
|
||||||
|
{"bt7", 8, 0},
|
||||||
|
{"bt8", 9, 0},
|
||||||
|
{"bt9", 10, 0},
|
||||||
|
{"bt10", 11, 0},
|
||||||
|
{"bt11", 12, 0},
|
||||||
|
{"bt12", 13, 0},
|
||||||
|
{"reset", 0, 0}, //255 = reset eeprom
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,10 +49,20 @@ struct MenuItem
|
||||||
MenuItem menuEntries[] =
|
MenuItem menuEntries[] =
|
||||||
{
|
{
|
||||||
{"", true, "prst"},
|
{"", true, "prst"},
|
||||||
{"", false, "edit"},
|
{"", false, "butt"},
|
||||||
{"/edit", false, "p2"},
|
{"", true, "reset"},
|
||||||
{"/edit/p2", true, "p2_1"},
|
{"/butt", true, "bt1"},
|
||||||
{"/edit/p2", true, "p2_2"},
|
{"/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"},
|
||||||
};
|
};
|
||||||
|
|
||||||
String menuCurrentPath = "";
|
String menuCurrentPath = "";
|
||||||
|
@ -75,6 +96,22 @@ byte rowPins[rows] = {1, 2, 3, 0}; //connect to the row pinouts of the keypad
|
||||||
byte colPins[cols] = {21, 22, 23}; //connect to the column pinouts of the keypad
|
byte colPins[cols] = {21, 22, 23}; //connect to the column pinouts of the keypad
|
||||||
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
|
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
|
||||||
|
|
||||||
|
bool buttonsVirtualState[] =
|
||||||
|
{
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Rotary Encoder
|
* Rotary Encoder
|
||||||
*/
|
*/
|
||||||
|
@ -206,10 +243,15 @@ void loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//clear screen after no input delay
|
/*//clear screen after no input delay
|
||||||
if (millis() > lastInputMillis + sevSegCoolDown)
|
if (millis() > lastInputMillis + sevSegCoolDown)
|
||||||
{
|
{
|
||||||
//sevseg.blank();
|
//sevseg.blank();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if(!animationPlaying && !isInMenu)
|
||||||
|
{
|
||||||
|
drawCustomSegments();
|
||||||
}
|
}
|
||||||
|
|
||||||
sevseg.refreshDisplay();
|
sevseg.refreshDisplay();
|
||||||
|
@ -398,15 +440,30 @@ MemSlot* getMemorySlot(String memSlotName)
|
||||||
|
|
||||||
void sendInputOuput(int input)
|
void sendInputOuput(int input)
|
||||||
{
|
{
|
||||||
|
String inputName = "bt";
|
||||||
|
inputName += input;
|
||||||
|
MemSlot* buttonInputMem = getMemorySlot(inputName);
|
||||||
|
Serial.println(inputName);
|
||||||
|
|
||||||
if (isInMenu)
|
if (isInMenu)
|
||||||
{
|
{
|
||||||
animationPlaying = false;
|
animationPlaying = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//sevseg.setNumber(input, -1);
|
|
||||||
playAnimation(1);
|
playAnimation(1);
|
||||||
|
|
||||||
|
if (buttonInputMem != NULL)
|
||||||
|
{
|
||||||
|
if (buttonInputMem->value == 1)
|
||||||
|
{
|
||||||
|
buttonsVirtualState[input-1] = !buttonsVirtualState[input-1];
|
||||||
|
}
|
||||||
|
if (buttonInputMem->value == 0)
|
||||||
|
{
|
||||||
|
buttonsVirtualState[input-1] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastInputMillis = millis();
|
lastInputMillis = millis();
|
||||||
|
@ -487,3 +544,16 @@ void drawAnimation(bool looping)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawCustomSegments()
|
||||||
|
{
|
||||||
|
uint8_t seg0 = (0b00001000 * buttonsVirtualState[0]) + (0b01000000 * buttonsVirtualState[4]) + (0b00000001 * buttonsVirtualState[8]);
|
||||||
|
uint8_t seg1 = (0b00001000 * buttonsVirtualState[1]) + (0b01000000 * buttonsVirtualState[5]) + (0b00000001 * buttonsVirtualState[9]);
|
||||||
|
uint8_t seg2 = (0b00001000 * buttonsVirtualState[2]) + (0b01000000 * buttonsVirtualState[6]) + (0b00000001 * buttonsVirtualState[10]);
|
||||||
|
uint8_t seg3 = (0b00001000 * buttonsVirtualState[3]) + (0b01000000 * buttonsVirtualState[7]) + (0b00000001 * buttonsVirtualState[11]);
|
||||||
|
|
||||||
|
sevseg.setSegmentsDigit(0,seg0);
|
||||||
|
sevseg.setSegmentsDigit(1,seg1);
|
||||||
|
sevseg.setSegmentsDigit(2,seg2);
|
||||||
|
sevseg.setSegmentsDigit(3,seg3);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue