Skip to content

File keyboard.hpp

FileList > keyboard > keyboard.hpp

Go to the source code of this file

Header file for keyboard functions and keymaps. More...

  • #include <Arduino.h>
  • #include <Wire.h>

Public Types

Type Name
enum KeyState

Public Attributes

Type Name
bool altLock
bool backlightState
bool capsLock
uint8_t cols
bool ctrlLock
uint8_t currentBrightness
char defaultKeymap
uint8_t emptyData
uint8_t keyInfo
unsigned long keyRepeatStart
KeyState keyStates
uint8_t keymapIndex
bool lastValue
uint8_t rows
uint8_t sendData
bool sendDataFlag
char symbolKeymap1
char symbolKeymap2
char symbolKeymap3
char symbolKeymap4
char symbolKeymap5
char symbolKeymap6
char symbolKeymap7
bool symbolLock

Public Functions

Type Name
void autoResetKeymapIndex ()
Handles resetting the keymap index.
bool doesKeyExistInKeymap (int rowIndex, int colIndex, char keymap)
Checks if a key exists in the keymap.
void handleCharacter (int rowIndex, int colIndex)
Handles the character for a specific key.
bool keyHeld (int rowIndex, int colIndex)
Checks if a key is being held.
bool keyNotPressed (int rowIndex, int colIndex)
Checks if a key is not pressed.
bool keyPressed (int rowIndex, int colIndex)
Checks if a key was pressed.
bool keyReleased (int rowIndex, int colIndex)
Checks if a key was released.
void onRequest ()
Handles I2C requests.
void printKeyInfo (uint8_t data)
Prints the key information.
void readKeyMatrix ()
Reads the key matrix and updates the key states.
void sendKeyInfo ()
Sends the key information over I2C.
void setDefaultCharacter (int rowIndex, int colIndex)
Sets keyInfo to the correct character for a specific key, from the default keymap only.
void setKeyboardBrightness (uint8_t command)
Sets the keyboard backlight brightness.
void setSymbolCharacter (int rowIndex, int colIndex)
Sets keyInfo to the correct character for a specific key, from the symbol keymaps only.

Macros

Type Name
define COL_COUNT 7
define DEBOUNCE_DELAY 50
define FUNCTION_DOWN 0x02
define FUNCTION_TOGGLE 0x01
define FUNCTION_UP 0x03
define I2C_DEV_ADDR 0x55
define KEYBOARD_BACKLIGHT_PIN 9
define KEYBOARD_BRIGHTNESS_CH 0
define KEYBOARD_BRIGHTNESS_DEFAULT 119
define KEYBOARD_BRIGHTNESS_FREQ 1000
define KEYBOARD_BRIGHTNESS_MAX 255
define KEYBOARD_BRIGHTNESS_MIN 0
define KEYBOARD_BRIGHTNESS_RES 8
define KEYBOARD_BRIGHTNESS_STEP 17
define KEY_INFO_SIZE 7
define KEY_REPEAT_DELAY 200
define MAX_KEYMAP_INDEX 8
define MIN_KEYMAP_INDEX 0
define ROW_COUNT 5
define SCL 10
define SDA 2

Detailed Description

Author:

hreikin (hreikin@gmail.com) @license MIT

Copyright:

Copyright (c) 2025 hreikin (hreikin@gmail.com)

Date:

2025-03-07

Public Types Documentation

enum KeyState

enum KeyState {
    NOT_PRESSED,
    PRESSED,
    HELD,
    RELEASED
};

Public Attributes Documentation

variable altLock

bool altLock;

variable backlightState

bool backlightState;

variable capsLock

bool capsLock;

variable cols

uint8_t cols[];

variable ctrlLock

bool ctrlLock;

variable currentBrightness

uint8_t currentBrightness;

variable defaultKeymap

char defaultKeymap[ROW_COUNT][COL_COUNT];

variable emptyData

uint8_t emptyData[KEY_INFO_SIZE];

variable keyInfo

uint8_t keyInfo[KEY_INFO_SIZE];

variable keyRepeatStart

unsigned long keyRepeatStart;

variable keyStates

KeyState keyStates[ROW_COUNT][COL_COUNT];

variable keymapIndex

uint8_t keymapIndex;

variable lastValue

bool lastValue[ROW_COUNT][COL_COUNT];

variable rows

uint8_t rows[];

variable sendData

uint8_t sendData[KEY_INFO_SIZE];

variable sendDataFlag

bool sendDataFlag;

variable symbolKeymap1

char symbolKeymap1[ROW_COUNT][COL_COUNT];

variable symbolKeymap2

char symbolKeymap2[ROW_COUNT][COL_COUNT];

variable symbolKeymap3

char symbolKeymap3[ROW_COUNT][COL_COUNT];

variable symbolKeymap4

char symbolKeymap4[ROW_COUNT][COL_COUNT];

variable symbolKeymap5

char symbolKeymap5[ROW_COUNT][COL_COUNT];

variable symbolKeymap6

char symbolKeymap6[ROW_COUNT][COL_COUNT];

variable symbolKeymap7

char symbolKeymap7[ROW_COUNT][COL_COUNT];

variable symbolLock

bool symbolLock;

Public Functions Documentation

function autoResetKeymapIndex

Handles resetting the keymap index.

void autoResetKeymapIndex () 


function doesKeyExistInKeymap

Checks if a key exists in the keymap.

bool doesKeyExistInKeymap (
    int rowIndex,
    int colIndex,
    char keymap
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.
  • keymap The keymap to check.

Returns:

true if the key exists in the keymap, false otherwise.


function handleCharacter

Handles the character for a specific key.

void handleCharacter (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

function keyHeld

Checks if a key is being held.

bool keyHeld (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Returns:

true if the key is being held, false otherwise.


function keyNotPressed

Checks if a key is not pressed.

bool keyNotPressed (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Returns:

true if the key is not pressed, false otherwise.


function keyPressed

Checks if a key was pressed.

bool keyPressed (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Returns:

true if the key was pressed, false otherwise.


function keyReleased

Checks if a key was released.

bool keyReleased (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Returns:

true if the key was released, false otherwise.


function onRequest

Handles I2C requests.

void onRequest () 

Sends the key data over I2C when requested.


function printKeyInfo

Prints the key information.

void printKeyInfo (
    uint8_t data
) 

Parameters:

  • data The key data array.

function readKeyMatrix

Reads the key matrix and updates the key states.

void readKeyMatrix () 


function sendKeyInfo

Sends the key information over I2C.

void sendKeyInfo () 


function setDefaultCharacter

Sets keyInfo to the correct character for a specific key, from the default keymap only.

void setDefaultCharacter (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Sets keyInfo to the correct character for a specific key, from the default keymap only.

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

function setKeyboardBrightness

Sets the keyboard backlight brightness.

void setKeyboardBrightness (
    uint8_t command
) 

Parameters:

  • command The command to set the brightness (toggle, up, down).

function setSymbolCharacter

Sets keyInfo to the correct character for a specific key, from the symbol keymaps only.

void setSymbolCharacter (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Sets keyInfo to the correct character for a specific key, from the symbol keymaps only.

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Macro Definition Documentation

define COL_COUNT

#define COL_COUNT `7`

define DEBOUNCE_DELAY

#define DEBOUNCE_DELAY `50`

define FUNCTION_DOWN

#define FUNCTION_DOWN `0x02`

define FUNCTION_TOGGLE

#define FUNCTION_TOGGLE `0x01`

define FUNCTION_UP

#define FUNCTION_UP `0x03`

define I2C_DEV_ADDR

#define I2C_DEV_ADDR `0x55`

define KEYBOARD_BACKLIGHT_PIN

#define KEYBOARD_BACKLIGHT_PIN `9`

define KEYBOARD_BRIGHTNESS_CH

#define KEYBOARD_BRIGHTNESS_CH `0`

define KEYBOARD_BRIGHTNESS_DEFAULT

#define KEYBOARD_BRIGHTNESS_DEFAULT `119`

define KEYBOARD_BRIGHTNESS_FREQ

#define KEYBOARD_BRIGHTNESS_FREQ `1000`

define KEYBOARD_BRIGHTNESS_MAX

#define KEYBOARD_BRIGHTNESS_MAX `255`

define KEYBOARD_BRIGHTNESS_MIN

#define KEYBOARD_BRIGHTNESS_MIN `0`

define KEYBOARD_BRIGHTNESS_RES

#define KEYBOARD_BRIGHTNESS_RES `8`

define KEYBOARD_BRIGHTNESS_STEP

#define KEYBOARD_BRIGHTNESS_STEP `17`

define KEY_INFO_SIZE

#define KEY_INFO_SIZE `7`

define KEY_REPEAT_DELAY

#define KEY_REPEAT_DELAY `200`

define MAX_KEYMAP_INDEX

#define MAX_KEYMAP_INDEX `8`

define MIN_KEYMAP_INDEX

#define MIN_KEYMAP_INDEX `0`

define ROW_COUNT

#define ROW_COUNT `5`

define SCL

#define SCL `10`

define SDA

#define SDA `2`


The documentation for this class was generated from the following file keyboard/keyboard.hpp