Remove unnecessary files

This commit is contained in:
KemoNine 2020-09-08 22:14:55 -04:00
parent 741793c298
commit e132cf1e6f
2 changed files with 0 additions and 421 deletions

View File

@ -1,203 +0,0 @@
// Varous system includes
#include <Arduino.h>
// Various library includes
#include <Adafruit_NeoPixel.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <BBQ10Keyboard.h>
#include <CircularBuffer.h>
// Various local includes
#include "serial_debugger_GSLC.h"
// Battery level measurement
#define VBATPIN A6
float measuredVBat;
int batteryPercent;
// TFT Setup
#define TFT_CS 9
#define TFT_DC 10
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;
#define KBD_BTN_1 0x06
#define KBD_BTN_2 0x11
#define KBD_BTN_3 0x07
#define KBD_BTN_4 0x12
#define KBD_SW_UP 0x01
#define KBD_SW_DN 0x02
#define KBD_SW_LF 0x03
#define KBD_SW_RT 0x04
#define KBD_SW_OK 0x05
// NeoPixels
#define PIXELS_NUM_BOARD 1
#define PIXELS_NUM_WING 1
#define PIXELS_WING_PIN 11
Adafruit_NeoPixel pixels_board(PIXELS_NUM_BOARD, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels_wing(PIXELS_NUM_WING, PIXELS_WING_PIN, NEO_GRB + NEO_KHZ800);
// Various loop handlers
void handlerKeyboard();
void handlerBatteryLevel();
// GUI Slice
gslc_tsElemRef* m_pElemBatteryLevel= NULL;
gslc_tsElemRef* m_pElemStatusText = NULL;
gslc_tsElemRef* m_pElemText = NULL;
gslc_tsElemRef* m_pTextSlider = NULL;
static int16_t DebugOut(char ch) { if (ch == (char)'\n') Serial.println(""); else Serial.write(ch); return 0; }
bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos);
void setup() {
Serial.begin(115200);
// Setup red LED to indicate device is on (in case we disable NeoPixel battery level later)
pinMode(3, OUTPUT);
digitalWrite(3, HIGH);
// Setup NeoPixels
pixels_board.begin();
pixels_wing.begin();
pixels_board.clear();
pixels_wing.clear();
pixels_board.setBrightness(10);
pixels_wing.setBrightness(5);
// Start with blank wing indicator
pixels_wing.show();
// Green : pixels.Color(0, 255, 0)
// Yellow : pixels.Color(255, 255, 0)
// Orange : pixels.Color(255, 128, 0)
// Red : pixels.Color(255, 0, 0)
pixels_board.setPixelColor(0, pixels_board.Color(0, 0, 255));
pixels_board.show();
// Setup BBQ10Keyboard
Wire.begin();
keyboard.begin();
keyboard.setBacklight(0.5f);
// GUI Slice (TFT is setup through GUI Slice)
gslc_InitDebug(&DebugOut);
InitGUIslice_gen();
}
// Main program via the Arduino standard methods
void loop() {
// Handle keyboard events
handlerKeyboard();
// Update battery level as appropriate
handlerBatteryLevel();
// Update UI
gslc_Update(&m_gui);
}
// Keyboard handler
void handlerKeyboard() {
// Check if keys were pressed
if (keyboard.keyCount()) {
// 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;
}
}
// Add keycodes to text box
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) {
keyboard_pixel_color = pixels_wing.Color(0, 255, 255);
}
// Display indicator accordingly
if (key.state == BBQ10Keyboard::StatePress || key.state == BBQ10Keyboard::StateLongPress) {
pixels_wing.setPixelColor(0, keyboard_pixel_color);
pixels_wing.show();
}
else {
pixels_wing.clear();
pixels_wing.show();
}
}
}
// Measure battery level and change NeoPixel accordingly
void handlerBatteryLevel() {
measuredVBat = analogRead(VBATPIN);
measuredVBat *= 2; // we divided by 2, so multiply back
measuredVBat *= 3.3; // Multiply by 3.3V, our reference voltage
measuredVBat /= 1024; // convert to voltage
batteryPercent = (measuredVBat / 3.3) * 100;
gslc_tsColor colorForHeaderElements;
if (batteryPercent >= 75) {
pixels_board.setPixelColor(0, pixels_board.Color(0, 255, 0));
colorForHeaderElements = GSLC_COL_GREEN;
}
else if (batteryPercent >= 50) {
colorForHeaderElements = GSLC_COL_YELLOW;
pixels_board.setPixelColor(0, pixels_board.Color(255, 255, 0));
}
else if (batteryPercent >= 25) {
colorForHeaderElements = GSLC_COL_ORANGE;
pixels_board.setPixelColor(0, pixels_board.Color(255, 128, 0));
}
else {
colorForHeaderElements = GSLC_COL_RED;
pixels_board.setPixelColor(0, pixels_board.Color(255, 0, 0));
}
gslc_ElemXProgressSetVal(&m_gui, m_pElemBatteryLevel, batteryPercent);
gslc_tsXProgress* pGauge = (gslc_tsXProgress*)gslc_GetXDataFromRef(&m_gui,m_pElemBatteryLevel,GSLC_TYPEX_PROGRESS,__LINE__);
pGauge->colGauge = colorForHeaderElements;
gslc_ElemSetTxtCol(&m_gui, m_pElemBatteryLevel, colorForHeaderElements);
gslc_ElemSetTxtCol(&m_gui, m_pElemStatusText, colorForHeaderElements);
// Update GUI and NeoPixel with battery status information
gslc_Update(&m_gui);
pixels_board.show();
}
// Slider callback function
bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos) {
gslc_tsGui* pGui = (gslc_tsGui*)(pvGui);
gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef);
gslc_tsElem* pElem = gslc_GetElemFromRef(pGui,pElemRef);
int16_t nVal;
// From the element's ID we can determine which slider was updated.
switch (pElem->nId) {
case E_TXTSCROLL:
// Fetch the slider position
nVal = gslc_ElemXSliderGetPos(pGui,m_pTextSlider);
break;
default:
break;
}
return true;
}

View File

@ -1,218 +0,0 @@
//<File !Start!>
// Varous system includes
#include <Arduino.h>
//<File !End!>
// Various library includes
#include <Adafruit_NeoPixel.h>
#include <Adafruit_GFX.h>
//<Includes !Start!>
//<Includes !End!>
#include <Adafruit_ILI9341.h>
#include <BBQ10Keyboard.h>
#include <CircularBuffer.h>
// Various local includes
#include "serial_debugger_GSLC.h"
// Battery level measurement
#define VBATPIN A6
float measuredVBat;
int batteryPercent;
// TFT Setup
#define TFT_CS 9
#define TFT_DC 10
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;
#define KBD_BTN_1 0x06
#define KBD_BTN_2 0x11
#define KBD_BTN_3 0x07
#define KBD_BTN_4 0x12
#define KBD_SW_UP 0x01
#define KBD_SW_DN 0x02
#define KBD_SW_LF 0x03
#define KBD_SW_RT 0x04
#define KBD_SW_OK 0x05
// NeoPixels
#define PIXELS_NUM_BOARD 1
#define PIXELS_NUM_WING 1
#define PIXELS_WING_PIN 11
Adafruit_NeoPixel pixels_board(PIXELS_NUM_BOARD, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels_wing(PIXELS_NUM_WING, PIXELS_WING_PIN, NEO_GRB + NEO_KHZ800);
// Various loop handlers
void handlerKeyboard();
void handlerBatteryLevel();
// GUI Slice
gslc_tsElemRef* m_pElemBatteryLevel= NULL;
gslc_tsElemRef* m_pElemStatusText = NULL;
gslc_tsElemRef* m_pElemText = NULL;
gslc_tsElemRef* m_pTextSlider = NULL;
static int16_t DebugOut(char ch) { if (ch == (char)'\n') Serial.println(""); else Serial.write(ch); return 0; }
bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos);
void setup() {
Serial.begin(115200);
// Setup red LED to indicate device is on (in case we disable NeoPixel battery level later)
pinMode(3, OUTPUT);
digitalWrite(3, HIGH);
// Setup NeoPixels
pixels_board.begin();
pixels_wing.begin();
pixels_board.clear();
pixels_wing.clear();
pixels_board.setBrightness(10);
pixels_wing.setBrightness(5);
// Start with blank wing indicator
pixels_wing.show();
// Green : pixels.Color(0, 255, 0)
// Yellow : pixels.Color(255, 255, 0)
// Orange : pixels.Color(255, 128, 0)
// Red : pixels.Color(255, 0, 0)
pixels_board.setPixelColor(0, pixels_board.Color(0, 0, 255));
pixels_board.show();
// Setup BBQ10Keyboard
Wire.begin();
keyboard.begin();
keyboard.setBacklight(0.5f);
// GUI Slice (TFT is setup through GUI Slice)
gslc_InitDebug(&DebugOut);
InitGUIslice_gen();
}
// Main program via the Arduino standard methods
void loop() {
// Handle keyboard events
handlerKeyboard();
// Update battery level as appropriate
handlerBatteryLevel();
// Update UI
gslc_Update(&m_gui);
}
// Keyboard handler
void handlerKeyboard() {
// Check if keys were pressed
if (keyboard.keyCount()) {
// 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;
}
}
// Add keycodes to text box
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) {
keyboard_pixel_color = pixels_wing.Color(0, 255, 255);
}
// Display indicator accordingly
if (key.state == BBQ10Keyboard::StatePress || key.state == BBQ10Keyboard::StateLongPress) {
pixels_wing.setPixelColor(0, keyboard_pixel_color);
pixels_wing.show();
}
else {
pixels_wing.clear();
pixels_wing.show();
}
}
}
// Measure battery level and change NeoPixel accordingly
void handlerBatteryLevel() {
measuredVBat = analogRead(VBATPIN);
measuredVBat *= 2; // we divided by 2, so multiply back
measuredVBat *= 3.3; // Multiply by 3.3V, our reference voltage
measuredVBat /= 1024; // convert to voltage
batteryPercent = (measuredVBat / 3.3) * 100;
gslc_tsColor colorForHeaderElements;
if (batteryPercent >= 75) {
pixels_board.setPixelColor(0, pixels_board.Color(0, 255, 0));
colorForHeaderElements = GSLC_COL_GREEN;
}
else if (batteryPercent >= 50) {
colorForHeaderElements = GSLC_COL_YELLOW;
pixels_board.setPixelColor(0, pixels_board.Color(255, 255, 0));
}
else if (batteryPercent >= 25) {
colorForHeaderElements = GSLC_COL_ORANGE;
pixels_board.setPixelColor(0, pixels_board.Color(255, 128, 0));
}
else {
colorForHeaderElements = GSLC_COL_RED;
pixels_board.setPixelColor(0, pixels_board.Color(255, 0, 0));
}
gslc_ElemXProgressSetVal(&m_gui, m_pElemBatteryLevel, batteryPercent);
gslc_tsXProgress* pGauge = (gslc_tsXProgress*)gslc_GetXDataFromRef(&m_gui,m_pElemBatteryLevel,GSLC_TYPEX_PROGRESS,__LINE__);
pGauge->colGauge = colorForHeaderElements;
gslc_ElemSetTxtCol(&m_gui, m_pElemBatteryLevel, colorForHeaderElements);
gslc_ElemSetTxtCol(&m_gui, m_pElemStatusText, colorForHeaderElements);
// Update GUI and NeoPixel with battery status information
gslc_Update(&m_gui);
pixels_board.show();
}
// Slider callback function
bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos) {
gslc_tsGui* pGui = (gslc_tsGui*)(pvGui);
gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef);
gslc_tsElem* pElem = gslc_GetElemFromRef(pGui,pElemRef);
int16_t nVal;
// From the element's ID we can determine which slider was updated.
switch (pElem->nId) {
case E_TXTSCROLL:
// Fetch the slider position
nVal = gslc_ElemXSliderGetPos(pGui,m_pTextSlider);
break;
default:
break;
}
return true;
}
//<Checkbox Callback !Start!>
//<Checkbox Callback !End!>
//<Keypad Callback !Start!>
//<Keypad Callback !End!>
//<Spinner Callback !Start!>
//<Spinner Callback !End!>
//<Listbox Callback !Start!>
//<Listbox Callback !End!>