Initial import
This commit is contained in:
87
code/macro_keyboard/macro_keyboard.h
Normal file
87
code/macro_keyboard/macro_keyboard.h
Normal file
@@ -0,0 +1,87 @@
|
||||
#ifndef __MACRO_KEYBOARD_H__
|
||||
#define __MACRO_KEYBOARD_H__
|
||||
|
||||
// Keypad defines
|
||||
#define KEYBOARD_ROWS 3
|
||||
#define KEYBOARD_COLS 4
|
||||
|
||||
#define KEYBOARD_KEY0 0
|
||||
#define KEYBOARD_KEY1 1
|
||||
#define KEYBOARD_KEY2 2
|
||||
#define KEYBOARD_KEY3 3
|
||||
#define KEYBOARD_KEY4 4
|
||||
#define KEYBOARD_KEY5 5
|
||||
#define KEYBOARD_KEY6 6
|
||||
#define KEYBOARD_KEY7 7
|
||||
#define KEYBOARD_KEY8 8
|
||||
#define KEYBOARD_KEY9 9
|
||||
#define KEYBOARD_KEYA 10
|
||||
#define KEYBOARD_KEYB 11
|
||||
#define KEYBOARD_KEYC 12
|
||||
|
||||
#define KEYBOARD_MODE0 0
|
||||
#define KEYBOARD_MODE1 1
|
||||
#define KEYBOARD_MODE2 2
|
||||
#define KEYBOARD_MODE3 3
|
||||
#define KEYBOARD_LAST_MODE 3
|
||||
|
||||
#define ROTARY_SENSITIVITY 4
|
||||
|
||||
char key = 0;
|
||||
char keys[KEYBOARD_ROWS][KEYBOARD_COLS] = {
|
||||
{KEYBOARD_KEY1, KEYBOARD_KEY2, KEYBOARD_KEY3, KEYBOARD_KEY4}, // the keyboard hardware is a 3x4 grid...
|
||||
{KEYBOARD_KEY5, KEYBOARD_KEY6, KEYBOARD_KEY7, KEYBOARD_KEY8},
|
||||
{KEYBOARD_KEY9, KEYBOARD_KEYA, KEYBOARD_KEYB, KEYBOARD_KEYC}, // these values need to be single char, so...
|
||||
};
|
||||
byte rowPins[KEYBOARD_ROWS] = {4, 5, A3 }; //connect to the row pinouts of the keypad
|
||||
byte colPins[KEYBOARD_COLS] = {6, 7, 8, 9 }; //connect to the column pinouts of the keypad
|
||||
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, KEYBOARD_ROWS, KEYBOARD_COLS );
|
||||
|
||||
// The library will return the character inside this array when the appropriate
|
||||
// button is pressed then look for that case statement. This is the key assignment lookup table.
|
||||
// Layout(key/button order) looks like this
|
||||
// |----------------------------|
|
||||
// | [2/3]* | *TRS breakout connection. Keys 2 and 3 are duplicated at the TRS jack
|
||||
// | [ 1] [ 2] [ 3] [ 4] | * Encoder A location = key[1]
|
||||
// | [ 5] [ 6] [ 7] [ 8] | * Encoder B location = Key[4]
|
||||
// | [ 9] [ A] [ B] [ C] | NOTE: The mode button (0) is not row/column key, it's directly wired to A0!!
|
||||
// |----------------------------|
|
||||
|
||||
#define KEYBOARD_MODEBUTTON_PIN A0 // the pin that the Modebutton is attached to
|
||||
#define KEYBOARD_POT_PIN A1 // pot for adjusting attract mode demoTime or mouseMouse pixel value
|
||||
|
||||
|
||||
// Rotary defines
|
||||
Encoder RotaryEncoderA(16, 10); //the LEFT encoder (encoder A)
|
||||
Encoder RotaryEncoderB(15, 14); //the RIGHT encoder (encoder B)
|
||||
|
||||
// Display defines
|
||||
#define LCD_NB_ROWS 4 //for the 4x20 LCD lcd.begin(), but i think this is kinda redundant
|
||||
#define LCD_NB_COLUMNS 20
|
||||
unsigned long previousMillis = 0; // values to compare last time interval was checked (For LCD refreshing)
|
||||
int check_State = 0; // state to check trigger the demo interrupt
|
||||
int updateLCD_flag = 0; // LCD updater, this flag is used to only update the screen once between mode changes
|
||||
// and once every 3 second while in a mode. Saves cycles / resources
|
||||
LiquidCrystal_I2C lcd(0x3F, 20, 4); // set the LCD address for a 40 chars and 4 line display
|
||||
|
||||
// Neopixel defines
|
||||
#define NEOPIXEL_PIN A2 // Which pin on the Arduino is connected to the NeoPixels?
|
||||
#define NEOPIXEL_NUMPIXELS 13 // How many NeoPixels are attached to the Arduino? 13 total, but they are address from 0,1,2,...12.
|
||||
|
||||
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NEOPIXEL_NUMPIXELS, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
|
||||
int colorUpdate = 0; //setting a flag to only update colors once when the mode is switched.
|
||||
const int b = 3; // Brightness control variable. Used to divide the RBG vales set for the RGB LEDs. full range is 0-255. 255 is super bright
|
||||
// In fact 255 is obnoxiously bright, so this use this variable to reduce the value. It also reduces the current draw on the USB
|
||||
|
||||
#define SYSTEM_KEY_WAIT 50
|
||||
#define SYSTEM_GUI_WAIT 200
|
||||
|
||||
// Variables that will change:
|
||||
int keyboardState = KEYBOARD_MODE0; // counter for the number of button presses
|
||||
int buttonState = 0; // current state of the button
|
||||
int lastButtonState = 0; // previous state of the button
|
||||
int mouseMove;
|
||||
long positionEncoderA = -999; //encoderA LEFT position variable
|
||||
long positionEncoderB = -999; //encoderB RIGHT position variable
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user