made each preset unique and added animations
This commit is contained in:
@@ -60,11 +60,11 @@ SevSeg sevseg;
|
||||
/*
|
||||
* key button matrix
|
||||
*/
|
||||
//#include <Key.h>
|
||||
#include <Keypad.h>
|
||||
|
||||
const byte rows = 4; //four rows
|
||||
const byte cols = 3; //three columns
|
||||
//Hardware inputs ordered from the bottom left = 1 to the top right = 12 on the switch matrix,
|
||||
char keys[rows][cols] = { // assiging arbitraty uid to each button
|
||||
{9,5,1},
|
||||
{10,6,2},
|
||||
@@ -94,10 +94,13 @@ const int BUTTON_Rotary = 4;
|
||||
/*
|
||||
* custom display animations
|
||||
*/
|
||||
//#include "animations.h"
|
||||
#include "animations.h"
|
||||
|
||||
//int animationFrame = 0;
|
||||
//bool animationLooping = true;
|
||||
int animationFrame = 0;
|
||||
bool animationPlaying = false;
|
||||
unsigned int animationLastFrameMillis = 0;
|
||||
unsigned int animationFrameDelayMillis = 64;
|
||||
bool animationLooping = false;
|
||||
|
||||
/*
|
||||
* time cooldown managment
|
||||
@@ -156,6 +159,8 @@ unsigned int sevSegCoolDown = 5000;
|
||||
|
||||
Serial.println("setup complete");
|
||||
|
||||
playAnimation(0);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -163,6 +168,13 @@ unsigned int sevSegCoolDown = 5000;
|
||||
*/
|
||||
void loop()
|
||||
{
|
||||
//animation draw tick
|
||||
if (animationPlaying && millis() > (animationLastFrameMillis + animationFrameDelayMillis))
|
||||
{
|
||||
drawAnimation(animationLooping);
|
||||
animationLastFrameMillis = millis();
|
||||
}
|
||||
|
||||
//INPUTS
|
||||
if (millis() > lastInputMillis + inputCoolDown)
|
||||
{
|
||||
@@ -197,7 +209,7 @@ void loop()
|
||||
//clear screen after no input delay
|
||||
if (millis() > lastInputMillis + sevSegCoolDown)
|
||||
{
|
||||
sevseg.blank();
|
||||
//sevseg.blank();
|
||||
}
|
||||
|
||||
sevseg.refreshDisplay();
|
||||
@@ -386,32 +398,50 @@ MemSlot* getMemorySlot(String memSlotName)
|
||||
|
||||
void sendInputOuput(int input)
|
||||
{
|
||||
|
||||
if (isInMenu)
|
||||
{
|
||||
animationPlaying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//sevseg.setNumber(input, -1);
|
||||
playAnimation(1);
|
||||
}
|
||||
|
||||
lastInputMillis = millis();
|
||||
sevseg.setNumber(input, -1);
|
||||
int mode = (getMemorySlot("prst")->value) % (sizeof(modes)/(sizeof(Action)*15));
|
||||
Action actionToRun = modes[mode][input-1];
|
||||
if (actionToRun.keyID == -1) //menu
|
||||
|
||||
int numberOfModes = sizeof(modes)/(sizeof(Action)*15);
|
||||
|
||||
int currentMode = (getMemorySlot("prst")->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
|
||||
|
||||
if (actionToRun.keyID == -1) //menu input, input mapping can be changed in modeAction.h
|
||||
{
|
||||
if (isInMenu)
|
||||
{
|
||||
menuBack();
|
||||
playAnimation(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
isInMenu = true;
|
||||
sevseg.blank();
|
||||
sevseg.blank(); // clear display
|
||||
playAnimation(2);
|
||||
printMenu();
|
||||
}
|
||||
}
|
||||
else if (isInMenu && input == 13) //menu prev
|
||||
else if (isInMenu && input == 13) //menu prev, hardcoded input
|
||||
{
|
||||
menuPrev();
|
||||
}
|
||||
else if (isInMenu && input == 14) //menu next
|
||||
else if (isInMenu && input == 14) //menu next, hardcoded input
|
||||
{
|
||||
menuNext();
|
||||
}
|
||||
else if (isInMenu && input == 15) //menu enter
|
||||
else if (isInMenu && input == 15) //menu enter, hardcoded input
|
||||
{
|
||||
menuEnter();
|
||||
}
|
||||
@@ -419,13 +449,41 @@ void sendInputOuput(int input)
|
||||
{
|
||||
clickKey(actionToRun.keyID, actionToRun.keyModifierID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void clickKey(int key, int modifier)
|
||||
{
|
||||
if (modifier != -1) Keyboard.set_modifier(modifier);
|
||||
Keyboard.set_modifier(modifier);
|
||||
Keyboard.press(key);
|
||||
Keyboard.release(key);
|
||||
Keyboard.set_modifier(0);
|
||||
Keyboard.send_now();
|
||||
//Keyboard.send_now(); //can't remember what's that's for
|
||||
}
|
||||
|
||||
void playAnimation(int animID)
|
||||
{
|
||||
currentAnimationID = animID;
|
||||
animationFrame = 0;
|
||||
animationPlaying = true;
|
||||
}
|
||||
|
||||
void drawAnimation(bool looping)
|
||||
{
|
||||
int currentAnimationFrameTotal = animData[currentAnimationID].animationFrameCount;
|
||||
sevseg.setSegments(animData[currentAnimationID].animationPtr + (animationFrame * (sizeof(const uint8_t)*4)));
|
||||
animationFrame++;
|
||||
if (animationFrame == currentAnimationFrameTotal)
|
||||
{
|
||||
animationFrame = 0;
|
||||
if (!looping)
|
||||
{
|
||||
animationPlaying = false;
|
||||
sevseg.blank();
|
||||
if (isInMenu) //not great
|
||||
{
|
||||
printMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user