|
|
|
@ -12,8 +12,12 @@ public:
|
|
|
|
|
{
|
|
|
|
|
scanBuffer = &spiBuffer[1];
|
|
|
|
|
|
|
|
|
|
// Enable 74HC165 clock
|
|
|
|
|
// Enable clock
|
|
|
|
|
HAL_GPIO_WritePin(CE_GPIO_Port,CE_Pin,GPIO_PIN_RESET);
|
|
|
|
|
|
|
|
|
|
// Init RGB buffer
|
|
|
|
|
for (uint8_t i = 0; i < HWKeyboard::LED_NUMBER; i++)
|
|
|
|
|
SetRgbBufferByID(i, HWKeyboard::Color_t{0, 0, 0});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -21,7 +25,6 @@ public:
|
|
|
|
|
static const uint8_t KEY_NUMBER = 82;
|
|
|
|
|
static const uint8_t TOUCHPAD_NUMBER = 6;
|
|
|
|
|
static const uint8_t LED_NUMBER = 104;
|
|
|
|
|
static const uint8_t KEYMAP_NUM = 5;
|
|
|
|
|
static const uint16_t KEY_REPORT_SIZE = 1 + 16;
|
|
|
|
|
static const uint16_t RAW_REPORT_SIZE = 1 + 32;
|
|
|
|
|
static const uint16_t HID_REPORT_SIZE = KEY_REPORT_SIZE + RAW_REPORT_SIZE;
|
|
|
|
@ -47,19 +50,11 @@ public:
|
|
|
|
|
PAD_SLASH,PAD_ASTERISK,PAD_MINUS,PAD_PLUS,PAD_ENTER,
|
|
|
|
|
PAD_NUM_1,PAD_NUM_2,PAD_NUM_3,PAD_NUM_4,PAD_NUM_5,
|
|
|
|
|
PAD_NUM_6,PAD_NUM_7,PAD_NUM_8,PAD_NUM_9,PAD_NUM_0,
|
|
|
|
|
PAD_PERIOD = 99, // followed with 20 bits 0, total 16 Bytes report data
|
|
|
|
|
PAD_PERIOD , NONUS_BACKSLASH,APPLICATION,POWER,PAD_EQUAL,
|
|
|
|
|
F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23,F24, EXECUTE,
|
|
|
|
|
HELP,MENU,SELECT,STOP,AGAIN,UNDO,CUT,COPY,PASTE,FIND,MUTE,VOLUME_UP,VOLUME_DOWN,
|
|
|
|
|
FN = 1000
|
|
|
|
|
/*------------------------- HID report data -------------------------*/
|
|
|
|
|
|
|
|
|
|
// /*-------------------------- Virtual keys ---------------------------*/
|
|
|
|
|
// EXECUTE = 116,
|
|
|
|
|
// HELP, MENU, SELECT, STOP, AGAIN, UNDO, CUT, COPY, PASTE, FIND, MUTE,
|
|
|
|
|
// VOLUME_UP, VOLUME_DOWN,
|
|
|
|
|
// /*-------------------------- Virtual keys ---------------------------*/
|
|
|
|
|
|
|
|
|
|
/*--------------------------- Smart keys ----------------------------*/
|
|
|
|
|
FN = 1000,
|
|
|
|
|
TOUCH_BAR_1, TOUCH_BAR_2, TOUCH_BAR_3, TOUCH_BAR_4, TOUCH_BAR_5, TOUCH_BAR_6
|
|
|
|
|
/*--------------------------- Smart keys ----------------------------*/
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Color_t
|
|
|
|
@ -68,54 +63,51 @@ public:
|
|
|
|
|
uint8_t g;
|
|
|
|
|
uint8_t b;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum SpiWs2812Byte_t : uint8_t
|
|
|
|
|
{
|
|
|
|
|
// This should be tuned considering WS2812b clock timing
|
|
|
|
|
WS_HIGH = 0xFE,
|
|
|
|
|
WS_LOW = 0xE0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t* ScanKeyStates();
|
|
|
|
|
void ApplyDebounceFilter(uint32_t _filterTimeUs = 100);
|
|
|
|
|
uint8_t* Remap(uint8_t _layer = 1);
|
|
|
|
|
void SetRgbBuffer(uint8_t _keyId, Color_t _color);
|
|
|
|
|
void SyncLights();
|
|
|
|
|
bool FnPressed();
|
|
|
|
|
uint8_t* GetHidReportBuffer(uint8_t _reportId = 0);
|
|
|
|
|
bool KeyPressed(KeyCode_t _key);
|
|
|
|
|
void Press(KeyCode_t _key);
|
|
|
|
|
void Release(KeyCode_t _key);
|
|
|
|
|
uint8_t* GetHidReportBuffer(uint8_t _reportId);
|
|
|
|
|
uint8_t GetTouchBarState(uint8_t _id = 0);
|
|
|
|
|
void SetRgbBufferByID(uint8_t _keyId, Color_t _color, float _brightness = 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int16_t keyMap[KEYMAP_NUM][IO_NUMBER] = {
|
|
|
|
|
// The first layer, used for aligning 74HC165 IO pins to PCB key layout
|
|
|
|
|
int16_t keyMap[5][IO_NUMBER] = {
|
|
|
|
|
{67,61,60,58,59,52,55,51,50,49,48,47,46,3,
|
|
|
|
|
80,81,64,57,62,63,53,54,45,44,40,31,26,18,2,
|
|
|
|
|
19,70,71,66,65,56,36,37,38,39,43,42,41,28,1,
|
|
|
|
|
15,74,73,72,68,69,29,30,35,34,33,32,24,0,
|
|
|
|
|
14,76,77,78,79,16,20,21,22,23,27,25,17,4,
|
|
|
|
|
13,12,8,75,9,10,7,11,6,5,
|
|
|
|
|
82,83,84,85,86,87},
|
|
|
|
|
86,84,82,87,85,83}, // TouchBar index
|
|
|
|
|
|
|
|
|
|
// Other layer, used for mapping default key layout to custom layout
|
|
|
|
|
{ESC,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PAUSE,
|
|
|
|
|
GRAVE_ACCENT,NUM_1,NUM_2,NUM_3,NUM_4,NUM_5,NUM_6,NUM_7,NUM_8,NUM_9,NUM_0,MINUS,EQUAL,BACKSPACE,INSERT,
|
|
|
|
|
TAB,Q,W,E,R,T,Y,U,I,O,P,LEFT_U_BRACE,RIGHT_U_BRACE,BACKSLASH,DELETE,
|
|
|
|
|
CAP_LOCK,A,S,D,F,G,H,J,K,L,SEMI_COLON,QUOTE,ENTER,PAGE_UP,
|
|
|
|
|
LEFT_SHIFT,Z,X,C,V,B,N,M,COMMA,PERIOD,SLASH,RIGHT_SHIFT,UP_ARROW,PAGE_DOWN,
|
|
|
|
|
LEFT_CTRL, LEFT_GUI, LEFT_ALT, SPACE, RIGHT_ALT, RIGHT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,RIGHT_ALT,FN,RIGHT_CTRL,LEFT_ARROW,DOWN_ARROW,RIGHT_ARROW }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
volatile bool isRgbTxBusy{};
|
|
|
|
|
uint8_t hidBuffer[HID_REPORT_SIZE]{};
|
|
|
|
|
volatile bool isRgbTxBusy;
|
|
|
|
|
bool isCapsLocked = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
@ -123,11 +115,11 @@ private:
|
|
|
|
|
uint8_t spiBuffer[IO_NUMBER / 8 + 1]{};
|
|
|
|
|
uint8_t* scanBuffer;
|
|
|
|
|
uint8_t debounceBuffer[IO_NUMBER / 8 + 1]{};
|
|
|
|
|
uint8_t hidBuffer[HID_REPORT_SIZE]{};
|
|
|
|
|
uint8_t remapBuffer[IO_NUMBER / 8]{};
|
|
|
|
|
|
|
|
|
|
uint8_t rgbBuffer[LED_NUMBER][3][8]{};
|
|
|
|
|
uint8_t wsCommit[64] = {0};
|
|
|
|
|
uint8_t brightnessPrediv = 2; // means 1/4 brightness
|
|
|
|
|
uint8_t brightnessPreDiv = 2; // 1/4
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|