Add ring buffer for text display on LCD ; add some debug code to verify what keys are availble for use ; need to sort symbol key still

This commit is contained in:
KemoNine 2020-09-07 23:53:06 -04:00
parent 99c0b77398
commit b765f65d9c
1 changed files with 20 additions and 0 deletions

View File

@ -6,6 +6,7 @@
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <BBQ10Keyboard.h>
#include <CircularBuffer.h>
// Debugging via serial monitor (don't turn this on unless you're hacking on the firmware code)
#define DEBUG true
@ -22,6 +23,7 @@ Adafruit_ILI9341 tft(TFT_CS, TFT_DC);
#include <Fonts/FreeMono9pt7b.h>
#define CHARS_HORIZONTAL 28
#define CHARS_ROWS 13
CircularBuffer<char,364> textBuffer;
// Keyboard
BBQ10Keyboard keyboard;
@ -106,6 +108,24 @@ void handlerKeyboard() {
// Get keyboard event
const BBQ10Keyboard::KeyEvent key = keyboard.keyEvent();
char output[28];
snprintf(output, 28, "key: '%c' (dec %d, hex %02x)", key.key, key.key, key.key);
for (int i=0; i<sizeof(output); i++) {
char toPush = output[i];
if (toPush != '\0') {
textBuffer.push(toPush);
}
else if (toPush == '\0') {
textBuffer.push('\n');
break;
}
}
screenClear();
for (int i=0; i<textBuffer.size(); i++) {
tft.print(textBuffer[i]);
}
// Pick color for signaling a key was pressed (short or long press)
uint32_t keyboard_pixel_color = pixels_wing.Color(0, 0, 255);
if (key.state == BBQ10Keyboard::StateLongPress) {