From 6e524e8de464cd921ee46c42bcedd6b0239fc54c Mon Sep 17 00:00:00 2001 From: Nico Stuhlmueller Date: Sat, 15 Apr 2023 19:25:21 +0200 Subject: [PATCH] added simple arduino firmware --- .../hackpad_simple/hackpad_simple.ino | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 firmware_arduino/hackpad_simple/hackpad_simple.ino diff --git a/firmware_arduino/hackpad_simple/hackpad_simple.ino b/firmware_arduino/hackpad_simple/hackpad_simple.ino new file mode 100644 index 0000000..882251d --- /dev/null +++ b/firmware_arduino/hackpad_simple/hackpad_simple.ino @@ -0,0 +1,66 @@ +//============================================================================= +// iR Hackpad Demo Firmware +// Compile for Arduino Leonardo +//============================================================================= + +// The Arduino Keyboard library creates a HID keyboard interface to send keyboard scancodes to the host. +// For convenience, the class takes ASCII characters via Keyboard::write(), which are automatically +// converted to the corresponding keboard scan-codes according to the keyboard layout passed to +// Keyboard::begin(). On the host side, the scan-codes are again converted to characters by the OS. +#include "Keyboard.h" + +//============================================================================= +// Our key matrix (see schematics) +const int N_rows = 5; +const int N_cols = 4; +const int gpio_rows[N_rows] = { 6, 7, 8, 9, 5 }; +const int gpio_cols[N_cols] = { 15, 14, 16, 10 }; + +// Key function assignment: ASCII characters or special function codes (see Keyboard.h) +const int key_matrix[N_rows][N_cols] = { + {'a', 'b', 'c', 'd'}, // 4x4 keypad + {'e', 'f', 'g', 'h'}, + {'i', 'j', 'k', 'l'}, + {'m', 'n', 'o', 'p'}, + {'_', '_', '_', 'x'} // rotery encoder button +}; +int is_pressed[N_rows][N_cols] = { 0 }; + +const uint32_t KEY_SCAN_DELAY_US = 100; // Delay between row scans + +//============================================================================= + +void setup() +{ + for (int col=0; col