File keyboard.hpp
File List > keyboard > keyboard.hpp
Go to the documentation of this file
#ifndef KEYBOARD_HPP
#define KEYBOARD_HPP
#include <Arduino.h>
#include <Wire.h>
#define I2C_DEV_ADDR 0x55
#define KEYBOARD_BACKLIGHT_PIN 9
#define SDA 2
#define SCL 10
#define KEYBOARD_BRIGHTNESS_CH 0 // ledc channel
#define KEYBOARD_BRIGHTNESS_FREQ 1000 // ledc Frequency
#define KEYBOARD_BRIGHTNESS_RES 8 // ledc Resolution_bits
#define KEYBOARD_BRIGHTNESS_MAX 255
#define KEYBOARD_BRIGHTNESS_MIN 0
#define KEYBOARD_BRIGHTNESS_DEFAULT 119
#define KEYBOARD_BRIGHTNESS_STEP 17
#define FUNCTION_TOGGLE 0x01
#define FUNCTION_DOWN 0x02
#define FUNCTION_UP 0x03
#define DEBOUNCE_DELAY 50 // 50 milliseconds debounce delay
#define KEY_REPEAT_DELAY 200 // 200 milliseconds key repeat delay
#define MIN_KEYMAP_INDEX 0
#define MAX_KEYMAP_INDEX 8
#define ROW_COUNT 5
#define COL_COUNT 7
#define KEY_INFO_SIZE 7
enum KeyState {
NOT_PRESSED,
PRESSED,
HELD,
RELEASED
};
extern unsigned long keyRepeatStart;
extern uint8_t currentBrightness;
extern uint8_t rows[];
extern uint8_t cols[];
extern bool lastValue[ROW_COUNT][COL_COUNT];
extern char defaultKeymap[ROW_COUNT][COL_COUNT];
extern char symbolKeymap1[ROW_COUNT][COL_COUNT];
extern char symbolKeymap2[ROW_COUNT][COL_COUNT];
extern char symbolKeymap3[ROW_COUNT][COL_COUNT];
extern char symbolKeymap4[ROW_COUNT][COL_COUNT];
extern char symbolKeymap5[ROW_COUNT][COL_COUNT];
extern char symbolKeymap6[ROW_COUNT][COL_COUNT];
extern char symbolKeymap7[ROW_COUNT][COL_COUNT];
extern KeyState keyStates[ROW_COUNT][COL_COUNT];
extern uint8_t keymapIndex;
extern bool altLock;
extern bool ctrlLock;
extern bool capsLock;
extern bool symbolLock;
extern bool backlightState;
extern bool sendDataFlag;
extern uint8_t keyInfo[KEY_INFO_SIZE]; // keyValue, alt, ctrl, shift, sym, mic, speaker
extern uint8_t sendData[KEY_INFO_SIZE]; // keyValue, alt, ctrl, shift, sym, mic, speaker
extern uint8_t emptyData[KEY_INFO_SIZE]; // empty array to send when no key is pressed
void onRequest();
bool keyReleased(int rowIndex, int colIndex);
bool keyHeld(int rowIndex, int colIndex);
bool keyPressed(int rowIndex, int colIndex);
bool keyNotPressed(int rowIndex, int colIndex);
bool doesKeyExistInKeymap(int rowIndex, int colIndex, char keymap[ROW_COUNT][COL_COUNT]);
void printKeyInfo(uint8_t data[KEY_INFO_SIZE]);
void readKeyMatrix();
void sendKeyInfo();
void setKeyboardBrightness(uint8_t command);
void autoResetKeymapIndex();
void setDefaultCharacter(int rowIndex, int colIndex);
void setSymbolCharacter(int rowIndex, int colIndex);
void handleCharacter(int rowIndex, int colIndex);
#endif // KEYBOARD_HPP