Compare commits

...

10 Commits

9 changed files with 237 additions and 840 deletions

View File

@ -1,34 +0,0 @@
#include "SevSeg.h"
SevSeg sevseg;
#include "animations.h"
// Variables globales
int frameId = 0; // début
int frameAnim = 0; // début
int animId = 0; // début
int loopFrames = 10000;
void setup(){
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);
}
void loop(){
sevseg.refreshDisplay();
//sevseg.setNumber(8888, 1);
sevseg.setNumber(frameAnim, 3);
// système pour augmenter le compteur et créer un système de vitesse
frameId++;
if (frameId > loopFrames)
{
frameAnim++;
frameId = 0;
}
}

View File

@ -1,246 +0,0 @@
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION1[30][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x00, 0x00, 0x01 }, // Frame 1
{ 0x00, 0x00, 0x01, 0x00 }, // Frame 2
{ 0x00, 0x01, 0x00, 0x00 }, // Frame 3
{ 0x01, 0x00, 0x00, 0x00 }, // Frame 4
{ 0x20, 0x00, 0x00, 0x00 }, // Frame 5
{ 0x10, 0x00, 0x00, 0x00 }, // Frame 6
{ 0x08, 0x00, 0x00, 0x00 }, // Frame 7
{ 0x00, 0x08, 0x00, 0x00 }, // Frame 8
{ 0x00, 0x00, 0x08, 0x00 }, // Frame 9
{ 0x00, 0x00, 0x00, 0x08 }, // Frame 10
{ 0x00, 0x00, 0x00, 0x04 }, // Frame 11
{ 0x00, 0x00, 0x00, 0x02 }, // Frame 12
{ 0x00, 0x00, 0x01, 0x01 }, // Frame 13
{ 0x01, 0x01, 0x00, 0x00 }, // Frame 14
{ 0x30, 0x00, 0x00, 0x00 }, // Frame 15
{ 0x08, 0x08, 0x00, 0x00 }, // Frame 16
{ 0x00, 0x00, 0x08, 0x08 }, // Frame 17
{ 0x00, 0x00, 0x00, 0x06 }, // Frame 18
{ 0x00, 0x01, 0x01, 0x01 }, // Frame 19
{ 0x31, 0x00, 0x00, 0x00 }, // Frame 20
{ 0x08, 0x08, 0x08, 0x00 }, // Frame 21
{ 0x00, 0x00, 0x00, 0x0e }, // Frame 22
{ 0x01, 0x01, 0x01, 0x01 }, // Frame 23
{ 0x38, 0x08, 0x00, 0x00 }, // Frame 24
{ 0x00, 0x00, 0x08, 0x0e }, // Frame 25
{ 0x7f, 0x7f, 0x7f, 0x7f }, // Frame 26
{ 0x7f, 0x7f, 0x7f, 0x7f }, // Frame 27
{ 0xff, 0xff, 0xff, 0xff }, // Frame 28
{ 0x9b, 0x9b, 0x9b, 0x9b } // Frame 29
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION2[30][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x08, 0x00, 0x00, 0x00 }, // Frame 1
{ 0x48, 0x00, 0x00, 0x00 }, // Frame 2
{ 0x49, 0x00, 0x00, 0x00 }, // Frame 3
{ 0x49, 0x08, 0x00, 0x00 }, // Frame 4
{ 0x49, 0x48, 0x00, 0x00 }, // Frame 5
{ 0x49, 0x49, 0x00, 0x00 }, // Frame 6
{ 0x49, 0x49, 0x08, 0x00 }, // Frame 7
{ 0x49, 0x49, 0x48, 0x00 }, // Frame 8
{ 0x49, 0x49, 0x49, 0x00 }, // Frame 9
{ 0x49, 0x49, 0x49, 0x08 }, // Frame 10
{ 0x49, 0x49, 0x49, 0x48 }, // Frame 11
{ 0x49, 0x49, 0x49, 0x49 }, // Frame 12
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 13
{ 0x08, 0x00, 0x00, 0x00 }, // Frame 14
{ 0x5c, 0x00, 0x00, 0x00 }, // Frame 15
{ 0x7f, 0x00, 0x00, 0x00 }, // Frame 16
{ 0x7f, 0x08, 0x00, 0x00 }, // Frame 17
{ 0x7f, 0x5c, 0x00, 0x00 }, // Frame 18
{ 0x7f, 0x7f, 0x00, 0x00 }, // Frame 19
{ 0x7f, 0x7f, 0x08, 0x00 }, // Frame 20
{ 0x7f, 0x7f, 0x5c, 0x00 }, // Frame 21
{ 0x7f, 0x7f, 0x7f, 0x00 }, // Frame 22
{ 0x7f, 0x7f, 0x7f, 0x08 }, // Frame 23
{ 0x7f, 0x7f, 0x7f, 0x5c }, // Frame 24
{ 0x7f, 0x7f, 0x7f, 0x7f }, // Frame 25
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 26
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 27
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 28
{ 0x00, 0x00, 0x00, 0x00 } // Frame 29
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION3[30][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x08, 0x00, 0x00, 0x00 }, // Frame 1
{ 0x08, 0x00, 0x08, 0x00 }, // Frame 2
{ 0x08, 0x00, 0x08, 0x08 }, // Frame 3
{ 0x48, 0x08, 0x08, 0x08 }, // Frame 4
{ 0x48, 0x08, 0x48, 0x08 }, // Frame 5
{ 0x08, 0x08, 0x49, 0x49 }, // Frame 6
{ 0x08, 0x48, 0x48, 0x49 }, // Frame 7
{ 0x08, 0x48, 0x08, 0x49 }, // Frame 8
{ 0x08, 0x08, 0x08, 0x48 }, // Frame 9
{ 0x48, 0x08, 0x08, 0x48 }, // Frame 10
{ 0x49, 0x08, 0x48, 0x48 }, // Frame 11
{ 0x49, 0x08, 0x49, 0x08 }, // Frame 12
{ 0x49, 0x08, 0x08, 0x08 }, // Frame 13
{ 0x48, 0x08, 0x08, 0x08 }, // Frame 14
{ 0x08, 0x08, 0x08, 0x08 }, // Frame 15
{ 0x48, 0x08, 0x08, 0x48 }, // Frame 16
{ 0x08, 0x48, 0x48, 0x08 }, // Frame 17
{ 0x48, 0x08, 0x08, 0x48 }, // Frame 18
{ 0x48, 0x48, 0x48, 0x48 }, // Frame 19
{ 0x08, 0x48, 0x48, 0x08 }, // Frame 20
{ 0x08, 0x49, 0x49, 0x08 }, // Frame 21
{ 0x08, 0x48, 0x48, 0x08 }, // Frame 22
{ 0x08, 0x08, 0x08, 0x08 }, // Frame 23
{ 0x48, 0x08, 0x08, 0x48 }, // Frame 24
{ 0x08, 0x08, 0x08, 0x08 }, // Frame 25
{ 0x48, 0x08, 0x08, 0x48 }, // Frame 26
{ 0x08, 0x08, 0x08, 0x08 }, // Frame 27
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 28
{ 0x00, 0x00, 0x00, 0x00 } // Frame 29
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION4[30][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x62, 0x08, 0x08, 0x62 }, // Frame 1
{ 0x62, 0x08, 0x08, 0x62 }, // Frame 2
{ 0x62, 0x08, 0x08, 0x62 }, // Frame 3
{ 0x63, 0x08, 0x08, 0x63 }, // Frame 4
{ 0x63, 0x08, 0x08, 0x63 }, // Frame 5
{ 0x63, 0x58, 0x4c, 0x63 }, // Frame 6
{ 0x63, 0x39, 0x0f, 0x63 }, // Frame 7
{ 0x63, 0x39, 0x0f, 0x63 }, // Frame 8
{ 0x63, 0x58, 0x4c, 0x63 }, // Frame 9
{ 0x63, 0x08, 0x08, 0x63 }, // Frame 10
{ 0x63, 0x08, 0x08, 0x63 }, // Frame 11
{ 0x63, 0x08, 0x08, 0x63 }, // Frame 12
{ 0x63, 0x58, 0x4c, 0x63 }, // Frame 13
{ 0x63, 0x58, 0x4c, 0x63 }, // Frame 14
{ 0x63, 0x39, 0x0f, 0x63 }, // Frame 15
{ 0x63, 0x39, 0x0f, 0x63 }, // Frame 16
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 17
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 18
{ 0x62, 0x58, 0x4c, 0x62 }, // Frame 19
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 20
{ 0x62, 0x58, 0x4c, 0x62 }, // Frame 21
{ 0x62, 0x58, 0x4c, 0x62 }, // Frame 22
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 23
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 24
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 25
{ 0x62, 0x08, 0x08, 0x62 }, // Frame 27
{ 0x62, 0x08, 0x08, 0x62 }, // Frame 28
{ 0x62, 0x08, 0x08, 0x62 } // Frame 29
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION5[30][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x30, 0x00, 0x00, 0x00 }, // Frame 1
{ 0x30, 0x00, 0x00, 0x00 }, // Frame 2
{ 0x30, 0x00, 0x00, 0x06 }, // Frame 3
{ 0x30, 0x00, 0x00, 0x06 }, // Frame 4
{ 0x70, 0x00, 0x00, 0x06 }, // Frame 5
{ 0x70, 0x00, 0x00, 0x06 }, // Frame 6
{ 0x76, 0x00, 0x00, 0x06 }, // Frame 7
{ 0x70, 0x40, 0x00, 0x06 }, // Frame 8
{ 0x70, 0x00, 0x40, 0x06 }, // Frame 9
{ 0x70, 0x00, 0x00, 0x46 }, // Frame 10
{ 0x70, 0x00, 0x00, 0x06 }, // Frame 11
{ 0x70, 0x00, 0x00, 0x46 }, // Frame 12
{ 0x70, 0x00, 0x00, 0x06 }, // Frame 13
{ 0x70, 0x00, 0x00, 0x06 }, // Frame 14
{ 0x70, 0x00, 0x00, 0x0c }, // Frame 15
{ 0x70, 0x00, 0x00, 0x0c }, // Frame 16
{ 0x70, 0x00, 0x00, 0x88 }, // Frame 17
{ 0x30, 0x00, 0x00, 0x88 }, // Frame 18
{ 0x30, 0x00, 0x00, 0x88 }, // Frame 19
{ 0x30, 0x00, 0x00, 0x88 }, // Frame 20
{ 0x30, 0x00, 0x00, 0x88 }, // Frame 21
{ 0x00, 0x00, 0x00, 0x88 }, // Frame 22
{ 0x00, 0x00, 0x00, 0x88 }, // Frame 23
{ 0x00, 0x00, 0x00, 0x88 }, // Frame 24
{ 0x00, 0x00, 0x00, 0x88 }, // Frame 25
{ 0x00, 0x00, 0x00, 0x88 }, // Frame 26
{ 0x00, 0x00, 0x00, 0x88 } // Frame 27
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION6[41][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 1
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 2
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 3
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 4
{ 0x30, 0x00, 0x00, 0x00 }, // Frame 5
{ 0x30, 0x00, 0x00, 0x00 }, // Frame 6
{ 0x30, 0x00, 0x00, 0x06 }, // Frame 7
{ 0x30, 0x00, 0x00, 0x06 }, // Frame 8
{ 0x06, 0x00, 0x00, 0x06 }, // Frame 9
{ 0x06, 0x00, 0x00, 0x30 }, // Frame 10
{ 0x00, 0x30, 0x06, 0x00 }, // Frame 11
{ 0x00, 0x30, 0x06, 0x00 }, // Frame 12
{ 0x00, 0x50, 0x06, 0x00 }, // Frame 13
{ 0x00, 0x50, 0x44, 0x00 }, // Frame 14
{ 0x00, 0x50, 0x44, 0x00 }, // Frame 15
{ 0x00, 0x30, 0x06, 0x00 }, // Frame 16
{ 0x00, 0x30, 0x06, 0x00 }, // Frame 17
{ 0x00, 0x70, 0x06, 0x00 }, // Frame 18
{ 0x00, 0x06, 0x46, 0x40 }, // Frame 19
{ 0x00, 0x06, 0x46, 0x40 }, // Frame 20
{ 0x00, 0x06, 0x46, 0x70 }, // Frame 21
{ 0x00, 0x06, 0x46, 0x46 }, // Frame 22
{ 0x00, 0x06, 0x46, 0x50 }, // Frame 23
{ 0x00, 0x06, 0x46, 0x40 }, // Frame 24
{ 0x00, 0x06, 0x46, 0x00 }, // Frame 25
{ 0x00, 0x06, 0x06, 0x00 }, // Frame 26
{ 0x00, 0x06, 0x06, 0x00 }, // Frame 27
{ 0x00, 0x06, 0x0c, 0x00 }, // Frame 28
{ 0x00, 0x06, 0x0c, 0x00 }, // Frame 29
{ 0x00, 0x06, 0x88, 0x00 }, // Frame 30
{ 0x00, 0x06, 0x88, 0x00 }, // Frame 31
{ 0x00, 0x30, 0x88, 0x00 }, // Frame 32
{ 0x00, 0x30, 0x88, 0x00 }, // Frame 33
{ 0x06, 0x00, 0x88, 0x00 }, // Frame 34
{ 0x06, 0x00, 0x88, 0x00 }, // Frame 35
{ 0x30, 0x00, 0x88, 0x00 }, // Frame 36
{ 0x30, 0x00, 0x88, 0x00 }, // Frame 37
{ 0x00, 0x00, 0x88, 0x00 }, // Frame 38
{ 0x00, 0x00, 0x88, 0x00 }, // Frame 39
{ 0x00, 0x00, 0x88, 0x00 } // Frame 40
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION7[30][4] = {
{ 0x00, 0x00, 0x00, 0x3c }, // Frame 0
{ 0x00, 0x00, 0x3c, 0x1e }, // Frame 0
{ 0x00, 0x3c, 0x1e, 0x79 }, // Frame 0
{ 0x3c, 0x1e, 0x79, 0x38 }, // Frame 1
{ 0x1e, 0x79, 0x38, 0x39 }, // Frame 2
{ 0x79, 0x38, 0x39, 0x3f }, // Frame 3
{ 0x38, 0x39, 0x3f, 0x37 }, // Frame 4
{ 0x39, 0x3f, 0x37, 0x79 }, // Frame 5
{ 0x3f, 0x37, 0x79, 0x00 }, // Frame 6
{ 0x37, 0x79, 0x00, 0x00 }, // Frame 7
{ 0x79, 0x00, 0x00, 0x78 }, // Frame 8
{ 0x00, 0x00, 0x78, 0x5c }, // Frame 9
{ 0x00, 0x78, 0x5c, 0x00 }, // Frame 10
{ 0x78, 0x5c, 0x00, 0x00 }, // Frame 11
{ 0x5c, 0x00, 0x00, 0x78 }, // Frame 12
{ 0x00, 0x00, 0x78, 0x74 }, // Frame 13
{ 0x00, 0x78, 0x74, 0x48 }, // Frame 14
{ 0x78, 0x74, 0x48, 0x00 }, // Frame 15
{ 0x74, 0x48, 0x00, 0x00 }, // Frame 16
{ 0x48, 0x00, 0x00, 0x71 }, // Frame 17
{ 0x00, 0x00, 0x71, 0x1c }, // Frame 18
{ 0x00, 0x71, 0x1c, 0x78 }, // Frame 19
{ 0x71, 0x1c, 0x78, 0x1c }, // Frame 20
{ 0x1c, 0x78, 0x1c, 0x50 }, // Frame 21
{ 0x78, 0x1c, 0x50, 0x48 }, // Frame 22
{ 0x1c, 0x50, 0x48, 0x82 }, // Frame 23
{ 0x50, 0x48, 0x82, 0x00 }, // Frame 24
{ 0x48, 0x82, 0x00, 0x00 }, // Frame 25
{ 0x82, 0x00, 0x00, 0x00 } // Frame 26
};

View File

@ -17,9 +17,22 @@ struct MemSlot
MemSlot memory[] = //128 bytes for the Teensy LC MemSlot memory[] = //128 bytes for the Teensy LC
{ {
{"prst", 1, 0}, {"alt", 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},
{"effc", 14, 2},
{"afps", 15, 24},
{"clea", 0, 0}, // != 0 -> reset eeprom
}; };
@ -37,11 +50,23 @@ struct MenuItem
MenuItem menuEntries[] = MenuItem menuEntries[] =
{ {
{"", true, "prst"}, {"", true, "alt"},
{"", false, "edit"}, {"", false, "btn"},
{"/edit", false, "p2"}, {"", true, "effc"},
{"/edit/p2", true, "p2_1"}, {"", true, "afps"},
{"/edit/p2", true, "p2_2"}, {"", 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 = ""; String menuCurrentPath = "";
@ -75,6 +100,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
*/ */
@ -100,7 +141,8 @@ int animationFrame = 0;
bool animationPlaying = false; bool animationPlaying = false;
unsigned int animationLastFrameMillis = 0; unsigned int animationLastFrameMillis = 0;
unsigned int animationFrameDelayMillis = 64; unsigned int animationFrameDelayMillis = 64;
bool animationLooping = false; bool animationIdle = false;
bool animationEnabled = true;
/* /*
* time cooldown managment * time cooldown managment
@ -118,32 +160,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);
@ -163,31 +186,69 @@ 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("clea")->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 (animationIdle && !animationPlaying && animationEnabled && !isInMenu)
{ {
drawAnimation(animationLooping); playAnimation(4);
}
if (animationEnabled && animationPlaying && (millis() > (animationLastFrameMillis + animationFrameDelayMillis)))
{
drawAnimation();
animationLastFrameMillis = millis(); animationLastFrameMillis = millis();
} }
//INPUTS //INPUTS
if (millis() > lastInputMillis + inputCoolDown) if (millis() > lastInputMillis + inputCoolDown)
{ {
char customKey = keypad.getKey(); char customKey = keypad.getKey(); //-1 because our array stars with 1 instead of 0
if (customKey) if (customKey > 0)
{ {
sendInputOuput(customKey); sendInputOuput(customKey-1);
} }
if (rotaryEncoder.push() == 1) // = pressed if (rotaryEncoder.push() == 1) // = pressed
{ {
sendInputOuput(15); sendInputOuput(14);
} }
rotaryEncoderState = rotaryEncoder.rotate(); rotaryEncoderState = rotaryEncoder.rotate();
@ -196,20 +257,25 @@ void loop()
{ {
if ( rotaryEncoderState == 1 ) //Turned Clockwise if ( rotaryEncoderState == 1 ) //Turned Clockwise
{ {
sendInputOuput(14); sendInputOuput(13);
} }
if ( rotaryEncoderState == 2 ) //Turned Counter-Clockwise if ( rotaryEncoderState == 2 ) //Turned Counter-Clockwise
{ {
sendInputOuput(13); sendInputOuput(12);
} }
} }
} }
//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();
@ -265,6 +331,7 @@ void menuBack()
menuSelectionIndex = 0; menuSelectionIndex = 0;
menuCurrentPath = ""; menuCurrentPath = "";
sevseg.blank(); sevseg.blank();
playAnimation(3);
} }
else else
{ {
@ -358,11 +425,19 @@ 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);
animationFrameDelayMillis = 1000 / max(1, getMemorySlot("afps")->value);
animationIdle = (getMemorySlot("effc")->value == 2);
}
int menuGetSelectionIndexFromPath(String path) int menuGetSelectionIndexFromPath(String path)
{ {
int correspondingPathItemIndex = 0; int correspondingPathItemIndex = 0;
@ -398,6 +473,16 @@ MemSlot* getMemorySlot(String memSlotName)
void sendInputOuput(int input) void sendInputOuput(int input)
{ {
//get current presetID
int currentPreset = (getMemorySlot("alt")->value) % getPresetsCount();
//Hardware inputs ordered from the bottom left = 1 to the top right = 12 on the switch matrix,
Action actionToRun = getAction(currentPreset, input); //getting the virtual inputs from the modes array.
//Inputs uids starts with 1, so input - 1 to get the index 0 of the array
String inputName = "bt";
inputName += input +1;
MemSlot* buttonInputMem = getMemorySlot(inputName);
Serial.println(inputName);
if (isInMenu) if (isInMenu)
{ {
@ -405,25 +490,31 @@ void sendInputOuput(int input)
} }
else else
{ {
//sevseg.setNumber(input, -1);
playAnimation(1); playAnimation(1);
//toggle mode
if (buttonInputMem != NULL)
{
if (buttonInputMem->value == 1)
{
buttonsVirtualState[input] = !buttonsVirtualState[input];
actionToRun = getAction(currentPreset + (int)!buttonsVirtualState[input], input); //Toggle mode sends the next preset's input if the troggle state is true
}
if (buttonInputMem->value == 0)
{
buttonsVirtualState[input] = false;
}
} }
lastInputMillis = millis(); clickKey(actionToRun.keyID, actionToRun.keyModifierID);
}
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 (actionToRun.keyID == -1) //menu input, input mapping can be changed in modeAction.h
{ {
if (isInMenu) if (isInMenu)
{ {
menuBack(); menuBack();
playAnimation(3); //playAnimation(3);
} }
else else
{ {
@ -433,42 +524,43 @@ void sendInputOuput(int input)
printMenu(); printMenu();
} }
} }
else if (isInMenu && input == 13) //menu prev, hardcoded input else if (isInMenu && input == 12) //menu prev, hardcoded input :/
{ {
menuPrev(); menuPrev();
} }
else if (isInMenu && input == 14) //menu next, hardcoded input else if (isInMenu && input == 13) //menu next, hardcoded input :/
{ {
menuNext(); menuNext();
} }
else if (isInMenu && input == 15) //menu enter, hardcoded input else if (isInMenu && input == 14) //menu enter, hardcoded input :/
{ {
menuEnter(); menuEnter();
} }
else
{
clickKey(actionToRun.keyID, actionToRun.keyModifierID);
}
lastInputMillis = millis();
} }
void clickKey(int key, int modifier) void clickKey(int key, int modifier)
{ {
Serial.println(key);
Keyboard.set_modifier(modifier); Keyboard.set_modifier(modifier);
Keyboard.press(key); Keyboard.press(key);
Keyboard.release(key); Keyboard.release(key);
Keyboard.set_modifier(0); Keyboard.set_modifier(0);
//Keyboard.send_now(); //can't remember what's that's for Keyboard.send_now(); //i think that helps to avoid key to stay active
} }
void playAnimation(int animID) void playAnimation(int animID)
{
if (animationEnabled)
{ {
currentAnimationID = animID; currentAnimationID = animID;
animationFrame = 0; animationFrame = 0;
animationPlaying = true; animationPlaying = true;
} }
}
void drawAnimation(bool looping) void drawAnimation()
{ {
int currentAnimationFrameTotal = animData[currentAnimationID].animationFrameCount; int currentAnimationFrameTotal = animData[currentAnimationID].animationFrameCount;
sevseg.setSegments(animData[currentAnimationID].animationPtr + (animationFrame * (sizeof(const uint8_t)*4))); sevseg.setSegments(animData[currentAnimationID].animationPtr + (animationFrame * (sizeof(const uint8_t)*4)));
@ -476,7 +568,7 @@ void drawAnimation(bool looping)
if (animationFrame == currentAnimationFrameTotal) if (animationFrame == currentAnimationFrameTotal)
{ {
animationFrame = 0; animationFrame = 0;
if (!looping) if (!(animData[currentAnimationID].animationLooping))
{ {
animationPlaying = false; animationPlaying = false;
sevseg.blank(); sevseg.blank();
@ -487,3 +579,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);
}

View File

@ -3,13 +3,14 @@ int currentAnimationID = 0;
struct AnimationData struct AnimationData
{ {
const uint8_t *animationPtr; const uint8_t *animationPtr;
unsigned int animationFrameCount; const unsigned int animationFrameCount;
const bool animationLooping;
}; };
//animations created using https://jasonacox.github.io/TM1637TinyDisplay/examples/7-segment-animator.html //animations created using https://jasonacox.github.io/TM1637TinyDisplay/examples/7-segment-animator.html
/* Animation Data - HGFEDCBA Map */ /* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION1[31][4] = { const uint8_t ANIMATION1[][4] = {
{ 0x00, 0x00, 0x00, 0x01 }, // Frame 0 { 0x00, 0x00, 0x00, 0x01 }, // Frame 0
{ 0x00, 0x00, 0x01, 0x00 }, // Frame 1 { 0x00, 0x00, 0x01, 0x00 }, // Frame 1
{ 0x00, 0x01, 0x00, 0x00 }, // Frame 2 { 0x00, 0x01, 0x00, 0x00 }, // Frame 2
@ -39,8 +40,6 @@ const uint8_t ANIMATION1[31][4] = {
{ 0x08, 0x08, 0x08, 0x0e }, // Frame 26 { 0x08, 0x08, 0x08, 0x0e }, // Frame 26
{ 0x39, 0x09, 0x09, 0x0f }, // Frame 27 { 0x39, 0x09, 0x09, 0x0f }, // Frame 27
{ 0x46, 0x76, 0x76, 0x70 }, // Frame 28 { 0x46, 0x76, 0x76, 0x70 }, // Frame 28
{ 0x40, 0x40, 0x40, 0x40 }, // Frame 29
{ 0x00, 0x40, 0x40, 0x00 } // Frame 30
}; };
/* Animation Data - HGFEDCBA Map */ /* Animation Data - HGFEDCBA Map */
@ -78,12 +77,32 @@ const uint8_t ANIMATION4[][4] = {
{ 0x40, 0x40, 0x40, 0x40 }, // Frame 3 { 0x40, 0x40, 0x40, 0x40 }, // Frame 3
{ 0x00, 0x40, 0x40, 0x00 }, // Frame 4 { 0x00, 0x40, 0x40, 0x00 }, // Frame 4
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 5 { 0x00, 0x00, 0x00, 0x00 }, // Frame 5
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 5
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 5
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION5[13][4] = {
{ 0x39, 0x09, 0x09, 0x0f }, // Frame 0
{ 0x39, 0x08, 0x09, 0x0f }, // Frame 1
{ 0x38, 0x09, 0x09, 0x0f }, // Frame 2
{ 0x19, 0x09, 0x09, 0x0f }, // Frame 3
{ 0x29, 0x09, 0x09, 0x0f }, // Frame 4
{ 0x31, 0x09, 0x09, 0x0f }, // Frame 5
{ 0x39, 0x01, 0x09, 0x0f }, // Frame 6
{ 0x39, 0x09, 0x01, 0x0f }, // Frame 7
{ 0x39, 0x09, 0x09, 0x07 }, // Frame 8
{ 0x39, 0x09, 0x09, 0x0b }, // Frame 9
{ 0x39, 0x09, 0x09, 0x0d }, // Frame 10
{ 0x39, 0x09, 0x09, 0x0e }, // Frame 11
{ 0x39, 0x09, 0x08, 0x0f } // Frame 12
}; };
AnimationData animData[] = AnimationData animData[] =
{ {
{(const uint8_t*)ANIMATION1, sizeof(ANIMATION1) / (sizeof(const uint8_t)*4)}, {(const uint8_t*)ANIMATION1, sizeof(ANIMATION1) / (sizeof(const uint8_t)*4), false},
{(const uint8_t*)ANIMATION2, sizeof(ANIMATION2) / (sizeof(const uint8_t)*4)}, {(const uint8_t*)ANIMATION2, sizeof(ANIMATION2) / (sizeof(const uint8_t)*4), false},
{(const uint8_t*)ANIMATION3, sizeof(ANIMATION3) / (sizeof(const uint8_t)*4)}, {(const uint8_t*)ANIMATION3, sizeof(ANIMATION3) / (sizeof(const uint8_t)*4), false},
{(const uint8_t*)ANIMATION4, sizeof(ANIMATION4) / (sizeof(const uint8_t)*4)} {(const uint8_t*)ANIMATION4, sizeof(ANIMATION4) / (sizeof(const uint8_t)*4), false},
{(const uint8_t*)ANIMATION5, sizeof(ANIMATION5) / (sizeof(const uint8_t)*4), true}
}; };

View File

@ -5,7 +5,7 @@ struct Action
}; };
//Hardware buttons and Actions are ordered from the bottom left to the top right matrix. Rotary encoder: left, right then press //Hardware buttons and Actions are ordered from the bottom left to the top right matrix. Rotary encoder: left, right then press
Action modes[][15] = Action presets[][15] =
{ {
{ {
{KEY_MEDIA_PREV_TRACK, 0}, {KEY_MEDIA_PREV_TRACK, 0},
@ -37,9 +37,9 @@ Action modes[][15] =
{KEY_F22, MODIFIERKEY_SHIFT}, {KEY_F22, MODIFIERKEY_SHIFT},
{KEY_F23, MODIFIERKEY_SHIFT}, {KEY_F23, MODIFIERKEY_SHIFT},
{-1, 0}, //menu / back {-1, 0}, //menu / back
{KEYPAD_MINUS, 0}, {KEYPAD_MINUS, MODIFIERKEY_ALT},
{KEYPAD_PLUS, 0}, {KEYPAD_PLUS, MODIFIERKEY_ALT},
{KEYPAD_ENTER, 0} {KEYPAD_ASTERIX, MODIFIERKEY_ALT}
}, },
{ {
{KEY_F13, MODIFIERKEY_CTRL}, {KEY_F13, MODIFIERKEY_CTRL},
@ -56,6 +56,17 @@ Action modes[][15] =
{-1, 0}, //menu / back {-1, 0}, //menu / back
{KEYPAD_MINUS, MODIFIERKEY_CTRL}, {KEYPAD_MINUS, MODIFIERKEY_CTRL},
{KEYPAD_PLUS, MODIFIERKEY_CTRL}, {KEYPAD_PLUS, MODIFIERKEY_CTRL},
{KEYPAD_ENTER, MODIFIERKEY_CTRL} {KEYPAD_ASTERIX, MODIFIERKEY_CTRL}
} }
}; };
int getPresetsCount()
{
return sizeof(presets)/(sizeof(Action)*15);
}
Action getAction(int presetID, int physicalKeyID)
{
int presetCount = getPresetsCount();
return presets[(presetID % presetCount)][physicalKeyID];
}

26
Readme.md Normal file
View File

@ -0,0 +1,26 @@
# Maybe Arduino
This is the Arduino code for the teensy firmware used in the Maybe Macro Board
## Uploading the firmware using Teensyduino
- Install Teensyduino https://www.pjrc.com/teensy/td_download.html
- Run Arduino .exe
- Open Maybe.ino
- In >> Tools/ setup the board settings:
| | |
| --- | --- |
| Board | Teensy LC |
| USB Type | Serial + Keyboard + Mouse + Joystick (but only Serial and Keyboard are used for now) |
| CPU Speed | 48MHz (max) |
| Optimize | Smallest Code |
| Keyboard layout | US English (but any should work) |
| Port | \[your teensy port |
- Upload
## License
Do What the Fuck You Want to Public License (WTFPL)
![WTFPL_logo](https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/WTFPL_logo.svg/langfr-150px-WTFPL_logo.svg.png)

View File

@ -1,28 +0,0 @@
#include <Key.h>
#include <Keypad.h>
const byte rows = 4; //four rows
const byte cols = 3; //three columns
char keys[rows][cols] = {
{'1','5','9'},
{'2','6','x'},
{'3','7','y'},
{'4','8','z'}
};
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
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
char customKey = keypad.getKey();
if (customKey){
Serial.println(customKey);
}
}

View File

@ -1,246 +0,0 @@
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION1[30][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x00, 0x00, 0x01 }, // Frame 1
{ 0x00, 0x00, 0x01, 0x00 }, // Frame 2
{ 0x00, 0x01, 0x00, 0x00 }, // Frame 3
{ 0x01, 0x00, 0x00, 0x00 }, // Frame 4
{ 0x20, 0x00, 0x00, 0x00 }, // Frame 5
{ 0x10, 0x00, 0x00, 0x00 }, // Frame 6
{ 0x08, 0x00, 0x00, 0x00 }, // Frame 7
{ 0x00, 0x08, 0x00, 0x00 }, // Frame 8
{ 0x00, 0x00, 0x08, 0x00 }, // Frame 9
{ 0x00, 0x00, 0x00, 0x08 }, // Frame 10
{ 0x00, 0x00, 0x00, 0x04 }, // Frame 11
{ 0x00, 0x00, 0x00, 0x02 }, // Frame 12
{ 0x00, 0x00, 0x01, 0x01 }, // Frame 13
{ 0x01, 0x01, 0x00, 0x00 }, // Frame 14
{ 0x30, 0x00, 0x00, 0x00 }, // Frame 15
{ 0x08, 0x08, 0x00, 0x00 }, // Frame 16
{ 0x00, 0x00, 0x08, 0x08 }, // Frame 17
{ 0x00, 0x00, 0x00, 0x06 }, // Frame 18
{ 0x00, 0x01, 0x01, 0x01 }, // Frame 19
{ 0x31, 0x00, 0x00, 0x00 }, // Frame 20
{ 0x08, 0x08, 0x08, 0x00 }, // Frame 21
{ 0x00, 0x00, 0x00, 0x0e }, // Frame 22
{ 0x01, 0x01, 0x01, 0x01 }, // Frame 23
{ 0x38, 0x08, 0x00, 0x00 }, // Frame 24
{ 0x00, 0x00, 0x08, 0x0e }, // Frame 25
{ 0x7f, 0x7f, 0x7f, 0x7f }, // Frame 26
{ 0x7f, 0x7f, 0x7f, 0x7f }, // Frame 27
{ 0xff, 0xff, 0xff, 0xff }, // Frame 28
{ 0x9b, 0x9b, 0x9b, 0x9b } // Frame 29
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION2[30][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x08, 0x00, 0x00, 0x00 }, // Frame 1
{ 0x48, 0x00, 0x00, 0x00 }, // Frame 2
{ 0x49, 0x00, 0x00, 0x00 }, // Frame 3
{ 0x49, 0x08, 0x00, 0x00 }, // Frame 4
{ 0x49, 0x48, 0x00, 0x00 }, // Frame 5
{ 0x49, 0x49, 0x00, 0x00 }, // Frame 6
{ 0x49, 0x49, 0x08, 0x00 }, // Frame 7
{ 0x49, 0x49, 0x48, 0x00 }, // Frame 8
{ 0x49, 0x49, 0x49, 0x00 }, // Frame 9
{ 0x49, 0x49, 0x49, 0x08 }, // Frame 10
{ 0x49, 0x49, 0x49, 0x48 }, // Frame 11
{ 0x49, 0x49, 0x49, 0x49 }, // Frame 12
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 13
{ 0x08, 0x00, 0x00, 0x00 }, // Frame 14
{ 0x5c, 0x00, 0x00, 0x00 }, // Frame 15
{ 0x7f, 0x00, 0x00, 0x00 }, // Frame 16
{ 0x7f, 0x08, 0x00, 0x00 }, // Frame 17
{ 0x7f, 0x5c, 0x00, 0x00 }, // Frame 18
{ 0x7f, 0x7f, 0x00, 0x00 }, // Frame 19
{ 0x7f, 0x7f, 0x08, 0x00 }, // Frame 20
{ 0x7f, 0x7f, 0x5c, 0x00 }, // Frame 21
{ 0x7f, 0x7f, 0x7f, 0x00 }, // Frame 22
{ 0x7f, 0x7f, 0x7f, 0x08 }, // Frame 23
{ 0x7f, 0x7f, 0x7f, 0x5c }, // Frame 24
{ 0x7f, 0x7f, 0x7f, 0x7f }, // Frame 25
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 26
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 27
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 28
{ 0x00, 0x00, 0x00, 0x00 } // Frame 29
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION3[30][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x08, 0x00, 0x00, 0x00 }, // Frame 1
{ 0x08, 0x00, 0x08, 0x00 }, // Frame 2
{ 0x08, 0x00, 0x08, 0x08 }, // Frame 3
{ 0x48, 0x08, 0x08, 0x08 }, // Frame 4
{ 0x48, 0x08, 0x48, 0x08 }, // Frame 5
{ 0x08, 0x08, 0x49, 0x49 }, // Frame 6
{ 0x08, 0x48, 0x48, 0x49 }, // Frame 7
{ 0x08, 0x48, 0x08, 0x49 }, // Frame 8
{ 0x08, 0x08, 0x08, 0x48 }, // Frame 9
{ 0x48, 0x08, 0x08, 0x48 }, // Frame 10
{ 0x49, 0x08, 0x48, 0x48 }, // Frame 11
{ 0x49, 0x08, 0x49, 0x08 }, // Frame 12
{ 0x49, 0x08, 0x08, 0x08 }, // Frame 13
{ 0x48, 0x08, 0x08, 0x08 }, // Frame 14
{ 0x08, 0x08, 0x08, 0x08 }, // Frame 15
{ 0x48, 0x08, 0x08, 0x48 }, // Frame 16
{ 0x08, 0x48, 0x48, 0x08 }, // Frame 17
{ 0x48, 0x08, 0x08, 0x48 }, // Frame 18
{ 0x48, 0x48, 0x48, 0x48 }, // Frame 19
{ 0x08, 0x48, 0x48, 0x08 }, // Frame 20
{ 0x08, 0x49, 0x49, 0x08 }, // Frame 21
{ 0x08, 0x48, 0x48, 0x08 }, // Frame 22
{ 0x08, 0x08, 0x08, 0x08 }, // Frame 23
{ 0x48, 0x08, 0x08, 0x48 }, // Frame 24
{ 0x08, 0x08, 0x08, 0x08 }, // Frame 25
{ 0x48, 0x08, 0x08, 0x48 }, // Frame 26
{ 0x08, 0x08, 0x08, 0x08 }, // Frame 27
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 28
{ 0x00, 0x00, 0x00, 0x00 } // Frame 29
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION4[30][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x62, 0x08, 0x08, 0x62 }, // Frame 1
{ 0x62, 0x08, 0x08, 0x62 }, // Frame 2
{ 0x62, 0x08, 0x08, 0x62 }, // Frame 3
{ 0x63, 0x08, 0x08, 0x63 }, // Frame 4
{ 0x63, 0x08, 0x08, 0x63 }, // Frame 5
{ 0x63, 0x58, 0x4c, 0x63 }, // Frame 6
{ 0x63, 0x39, 0x0f, 0x63 }, // Frame 7
{ 0x63, 0x39, 0x0f, 0x63 }, // Frame 8
{ 0x63, 0x58, 0x4c, 0x63 }, // Frame 9
{ 0x63, 0x08, 0x08, 0x63 }, // Frame 10
{ 0x63, 0x08, 0x08, 0x63 }, // Frame 11
{ 0x63, 0x08, 0x08, 0x63 }, // Frame 12
{ 0x63, 0x58, 0x4c, 0x63 }, // Frame 13
{ 0x63, 0x58, 0x4c, 0x63 }, // Frame 14
{ 0x63, 0x39, 0x0f, 0x63 }, // Frame 15
{ 0x63, 0x39, 0x0f, 0x63 }, // Frame 16
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 17
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 18
{ 0x62, 0x58, 0x4c, 0x62 }, // Frame 19
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 20
{ 0x62, 0x58, 0x4c, 0x62 }, // Frame 21
{ 0x62, 0x58, 0x4c, 0x62 }, // Frame 22
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 23
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 24
{ 0x62, 0x39, 0x0f, 0x62 }, // Frame 25
{ 0x62, 0x08, 0x08, 0x62 }, // Frame 27
{ 0x62, 0x08, 0x08, 0x62 }, // Frame 28
{ 0x62, 0x08, 0x08, 0x62 } // Frame 29
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION5[30][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x30, 0x00, 0x00, 0x00 }, // Frame 1
{ 0x30, 0x00, 0x00, 0x00 }, // Frame 2
{ 0x30, 0x00, 0x00, 0x06 }, // Frame 3
{ 0x30, 0x00, 0x00, 0x06 }, // Frame 4
{ 0x70, 0x00, 0x00, 0x06 }, // Frame 5
{ 0x70, 0x00, 0x00, 0x06 }, // Frame 6
{ 0x76, 0x00, 0x00, 0x06 }, // Frame 7
{ 0x70, 0x40, 0x00, 0x06 }, // Frame 8
{ 0x70, 0x00, 0x40, 0x06 }, // Frame 9
{ 0x70, 0x00, 0x00, 0x46 }, // Frame 10
{ 0x70, 0x00, 0x00, 0x06 }, // Frame 11
{ 0x70, 0x00, 0x00, 0x46 }, // Frame 12
{ 0x70, 0x00, 0x00, 0x06 }, // Frame 13
{ 0x70, 0x00, 0x00, 0x06 }, // Frame 14
{ 0x70, 0x00, 0x00, 0x0c }, // Frame 15
{ 0x70, 0x00, 0x00, 0x0c }, // Frame 16
{ 0x70, 0x00, 0x00, 0x88 }, // Frame 17
{ 0x30, 0x00, 0x00, 0x88 }, // Frame 18
{ 0x30, 0x00, 0x00, 0x88 }, // Frame 19
{ 0x30, 0x00, 0x00, 0x88 }, // Frame 20
{ 0x30, 0x00, 0x00, 0x88 }, // Frame 21
{ 0x00, 0x00, 0x00, 0x88 }, // Frame 22
{ 0x00, 0x00, 0x00, 0x88 }, // Frame 23
{ 0x00, 0x00, 0x00, 0x88 }, // Frame 24
{ 0x00, 0x00, 0x00, 0x88 }, // Frame 25
{ 0x00, 0x00, 0x00, 0x88 }, // Frame 26
{ 0x00, 0x00, 0x00, 0x88 } // Frame 27
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION6[41][4] = {
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 1
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 2
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 3
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 4
{ 0x30, 0x00, 0x00, 0x00 }, // Frame 5
{ 0x30, 0x00, 0x00, 0x00 }, // Frame 6
{ 0x30, 0x00, 0x00, 0x06 }, // Frame 7
{ 0x30, 0x00, 0x00, 0x06 }, // Frame 8
{ 0x06, 0x00, 0x00, 0x06 }, // Frame 9
{ 0x06, 0x00, 0x00, 0x30 }, // Frame 10
{ 0x00, 0x30, 0x06, 0x00 }, // Frame 11
{ 0x00, 0x30, 0x06, 0x00 }, // Frame 12
{ 0x00, 0x50, 0x06, 0x00 }, // Frame 13
{ 0x00, 0x50, 0x44, 0x00 }, // Frame 14
{ 0x00, 0x50, 0x44, 0x00 }, // Frame 15
{ 0x00, 0x30, 0x06, 0x00 }, // Frame 16
{ 0x00, 0x30, 0x06, 0x00 }, // Frame 17
{ 0x00, 0x70, 0x06, 0x00 }, // Frame 18
{ 0x00, 0x06, 0x46, 0x40 }, // Frame 19
{ 0x00, 0x06, 0x46, 0x40 }, // Frame 20
{ 0x00, 0x06, 0x46, 0x70 }, // Frame 21
{ 0x00, 0x06, 0x46, 0x46 }, // Frame 22
{ 0x00, 0x06, 0x46, 0x50 }, // Frame 23
{ 0x00, 0x06, 0x46, 0x40 }, // Frame 24
{ 0x00, 0x06, 0x46, 0x00 }, // Frame 25
{ 0x00, 0x06, 0x06, 0x00 }, // Frame 26
{ 0x00, 0x06, 0x06, 0x00 }, // Frame 27
{ 0x00, 0x06, 0x0c, 0x00 }, // Frame 28
{ 0x00, 0x06, 0x0c, 0x00 }, // Frame 29
{ 0x00, 0x06, 0x88, 0x00 }, // Frame 30
{ 0x00, 0x06, 0x88, 0x00 }, // Frame 31
{ 0x00, 0x30, 0x88, 0x00 }, // Frame 32
{ 0x00, 0x30, 0x88, 0x00 }, // Frame 33
{ 0x06, 0x00, 0x88, 0x00 }, // Frame 34
{ 0x06, 0x00, 0x88, 0x00 }, // Frame 35
{ 0x30, 0x00, 0x88, 0x00 }, // Frame 36
{ 0x30, 0x00, 0x88, 0x00 }, // Frame 37
{ 0x00, 0x00, 0x88, 0x00 }, // Frame 38
{ 0x00, 0x00, 0x88, 0x00 }, // Frame 39
{ 0x00, 0x00, 0x88, 0x00 } // Frame 40
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION7[30][4] = {
{ 0x00, 0x00, 0x00, 0x3c }, // Frame 0
{ 0x00, 0x00, 0x3c, 0x1e }, // Frame 0
{ 0x00, 0x3c, 0x1e, 0x79 }, // Frame 0
{ 0x3c, 0x1e, 0x79, 0x38 }, // Frame 1
{ 0x1e, 0x79, 0x38, 0x39 }, // Frame 2
{ 0x79, 0x38, 0x39, 0x3f }, // Frame 3
{ 0x38, 0x39, 0x3f, 0x37 }, // Frame 4
{ 0x39, 0x3f, 0x37, 0x79 }, // Frame 5
{ 0x3f, 0x37, 0x79, 0x00 }, // Frame 6
{ 0x37, 0x79, 0x00, 0x00 }, // Frame 7
{ 0x79, 0x00, 0x00, 0x78 }, // Frame 8
{ 0x00, 0x00, 0x78, 0x5c }, // Frame 9
{ 0x00, 0x78, 0x5c, 0x00 }, // Frame 10
{ 0x78, 0x5c, 0x00, 0x00 }, // Frame 11
{ 0x5c, 0x00, 0x00, 0x78 }, // Frame 12
{ 0x00, 0x00, 0x78, 0x74 }, // Frame 13
{ 0x00, 0x78, 0x74, 0x48 }, // Frame 14
{ 0x78, 0x74, 0x48, 0x00 }, // Frame 15
{ 0x74, 0x48, 0x00, 0x00 }, // Frame 16
{ 0x48, 0x00, 0x00, 0x71 }, // Frame 17
{ 0x00, 0x00, 0x71, 0x1c }, // Frame 18
{ 0x00, 0x71, 0x1c, 0x78 }, // Frame 19
{ 0x71, 0x1c, 0x78, 0x1c }, // Frame 20
{ 0x1c, 0x78, 0x1c, 0x50 }, // Frame 21
{ 0x78, 0x1c, 0x50, 0x48 }, // Frame 22
{ 0x1c, 0x50, 0x48, 0x82 }, // Frame 23
{ 0x50, 0x48, 0x82, 0x00 }, // Frame 24
{ 0x48, 0x82, 0x00, 0x00 }, // Frame 25
{ 0x82, 0x00, 0x00, 0x00 } // Frame 26
};

View File

@ -1,210 +0,0 @@
#include <Keyboard.h>
#include "SevSeg.h"
SevSeg sevseg;
#include <Key.h>
#include <Keypad.h>
const byte rows = 4; //four rows
const byte cols = 3; //three columns
char keys[rows][cols] = {
{1,5,9},
{2,6,10},
{3,7,11},
{4,8,12}
};
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
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
#include <SimpleRotary.h>
SimpleRotary rotaryEncoder(19, 20, 4);
byte rotaryEncoderState = 0;
// BUTTONS Rotary
const int BUTTON_Rotary = 4;
bool BUTTON_Rotary_lastState = HIGH;
#include "animations.h"
// Variables globales
int frameId = 0; // début
int frameAnim = 0; // début
int animId = 0; // début
int loopFrames = 20000;
int waitDelay = 0;
void setup(){
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);
//Init rotary encoders
rotaryEncoder.setDebounceDelay(2);
rotaryEncoder.setErrorDelay(100);
pinMode(BUTTON_Rotary, INPUT_PULLUP);
Serial.begin(9600);
Serial.println("setup");
Keyboard.begin();
}
void loop()
{
sevseg.refreshDisplay();
//sevseg.setNumber(1234, 1);
//sevseg.setNumber(frameAnim, 2);
// système pour augmenter le compteur et créer un système de vitesse
char customKey = keypad.getKey();
rotaryEncoderState = rotaryEncoder.rotate();
if (waitDelay > 0)
{
waitDelay -= 1;
} else
{
if (customKey){
Serial.println(customKey);
if (customKey == 1)
{
sevseg.setNumber(1, -1);
Keyboard.press(KEY_F13);
Keyboard.release(KEY_F13);
}
if (customKey == 2)
{
sevseg.setNumber(2, -1);
Keyboard.press(KEY_F14);
Keyboard.release(KEY_F14);
}
if (customKey == 3)
{
sevseg.setNumber(3, -1);
Keyboard.press(KEY_F15);
Keyboard.release(KEY_F15);
}
if (customKey == 4)
{
sevseg.setNumber(4, -1);
Keyboard.press(KEY_F16);
Keyboard.release(KEY_F16);
}
if (customKey == 5)
{
sevseg.setNumber(5, -1);
Keyboard.press(KEY_F17);
Keyboard.release(KEY_F17);
}
if (customKey == 6)
{
sevseg.setNumber(6, -1);
Keyboard.press(KEY_F18);
Keyboard.release(KEY_F18);
}
if (customKey == 7)
{
sevseg.setNumber(7, -1);
Keyboard.press(KEY_F19);
Keyboard.release(KEY_F19);
}
if (customKey == 8)
{
sevseg.setNumber(8, -1);
Keyboard.press(KEY_F20);
Keyboard.release(KEY_F20);
}
if (customKey == 9)
{
sevseg.setNumber(9, -1);
Keyboard.press(KEY_F21);
Keyboard.release(KEY_F21);
}
if (customKey == 10)
{
sevseg.setNumber(10, -1);
Keyboard.press(KEY_F22);
Keyboard.release(KEY_F22);
}
if (customKey == 11)
{
sevseg.setNumber(11, -1);
Keyboard.press(KEY_F23);
Keyboard.release(KEY_F23);
}
if (customKey == 12)
{
sevseg.setNumber(12, -1);
Keyboard.press(KEY_F24);
Keyboard.release(KEY_F24);
}
waitDelay = 10000;
} else if (digitalRead(BUTTON_Rotary) == LOW && BUTTON_Rotary_lastState == HIGH) // = pressed
{
sevseg.setNumber(13, -1);
Keyboard.press(KEY_MEDIA_MUTE);
Keyboard.release(KEY_MEDIA_MUTE);
waitDelay = 5000;
} else if (rotaryEncoderState == 1 || rotaryEncoderState == 2)
{
if ( rotaryEncoderState == 1 ) //Turned Clockwise
{
sevseg.setNumber(14, -1);
Keyboard.press(KEY_MEDIA_VOLUME_INC);
Keyboard.release(KEY_MEDIA_VOLUME_INC);
}
if ( rotaryEncoderState == 2 ) //Turned Counter-Clockwise
{
sevseg.setNumber(15, -1);
Keyboard.press(KEY_MEDIA_VOLUME_DEC);
Keyboard.release(KEY_MEDIA_VOLUME_DEC);
}
waitDelay = 5000;
} else
{
frameId ++;
if (frameId >= loopFrames)
{
frameAnim++;
frameId = 0;
}
if (frameAnim == 30)
{
animId = (animId + 1)%7;
frameAnim = 0;
}
if(animId == 0) sevseg.setSegments(ANIMATION1[frameAnim]);
if(animId == 1) sevseg.setSegments(ANIMATION2[frameAnim]);
if(animId == 2) sevseg.setSegments(ANIMATION3[frameAnim]);
if(animId == 3) sevseg.setSegments(ANIMATION4[frameAnim]);
if(animId == 4) sevseg.setSegments(ANIMATION7[frameAnim]);
if(animId == 5) sevseg.setSegments(ANIMATION7[frameAnim]);
if(animId == 6) sevseg.setSegments(ANIMATION7[frameAnim]);
//delay(150);
}
BUTTON_Rotary_lastState = digitalRead(BUTTON_Rotary);
}
}