diff --git a/hardware/sd_card_formatter/.gitignore b/hardware/sd_card_formatter/.gitignore new file mode 100644 index 0000000..aed9464 --- /dev/null +++ b/hardware/sd_card_formatter/.gitignore @@ -0,0 +1,5 @@ +build/ +sd_card_formatter*.bak +gui_backup/ +sd_card_formatter.ino.beta +sd_card_formatter.ino.orig \ No newline at end of file diff --git a/hardware/sd_card_formatter/README.md b/hardware/sd_card_formatter/README.md new file mode 100644 index 0000000..092e6a9 --- /dev/null +++ b/hardware/sd_card_formatter/README.md @@ -0,0 +1,7 @@ +# SD Card Formatter + +A simple utility that will **FORMAT** the inserted SD Card. + +**YOU MUST USE THIS TOOL TO INITIALIZE AN SD CARD 100% SAFELY** + +*This utility is designed to be run from the ```_controller``` build!* diff --git a/hardware/sd_card_formatter/build.ps1 b/hardware/sd_card_formatter/build.ps1 new file mode 100644 index 0000000..8ad4cb6 --- /dev/null +++ b/hardware/sd_card_formatter/build.ps1 @@ -0,0 +1 @@ +arduino-cli compile --log-level=warn --fqbn adafruit:nrf52:feather52840 sd_card_formatter.ino diff --git a/hardware/sd_card_formatter/make.ps1 b/hardware/sd_card_formatter/make.ps1 new file mode 100644 index 0000000..fc2a375 --- /dev/null +++ b/hardware/sd_card_formatter/make.ps1 @@ -0,0 +1,8 @@ +# Ensure this script fails if either build or upload fails +$ErrorActionPreference = "Stop" + +# Ensure we actually build before upload (common mistake) +& .\build.ps1 + +# Upload to board +& .\upload.ps1 diff --git a/hardware/sd_card_formatter/sd_card_formatter.ino b/hardware/sd_card_formatter/sd_card_formatter.ino new file mode 100644 index 0000000..210df58 --- /dev/null +++ b/hardware/sd_card_formatter/sd_card_formatter.ino @@ -0,0 +1,804 @@ +// +// FILE: [sd_card_formatter.ino] +// Created by GUIslice Builder version: [0.15.b004] +// +// GUIslice Builder Generated File +// +// For the latest guides, updates and support view: +// https://github.com/ImpulseAdventure/GUIslice +// +// + +// ------------------------------------------------ +// Headers to include +// ------------------------------------------------ +// +// Varous system includes +#include + +// Various library includes +#include +#include +#include +#include +#include + +// Various local includes +#include "sd_card_formatter_GSLC.h" + +// + +// ------------------------------------------------ +// Program Globals +// ------------------------------------------------ + +// 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); + +// 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 +CircularBuffer uiKeyBuffer; + +// 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); + +// GUI state globals +bool popupOnScreen = false; + +// Various loop handlers +void handlerKeyboard(); +void handlerBatteryLevel(); +void eraseAndFormatCard(); + +// Save some element references for direct access +// +gslc_tsElemRef* m_pElemBatteryLevel= NULL; +gslc_tsElemRef* m_pElemBtSDNo = NULL; +gslc_tsElemRef* m_pElemBtSDYes = NULL; +gslc_tsElemRef* m_pElemSDInfo = NULL; +gslc_tsElemRef* m_pElemStatusText = NULL; +// + +// Keyboard map related +#define MAX_INPUT_MAP 5 +gslc_tsInputMap m_asInputMap[MAX_INPUT_MAP]; + +// Define debug message function +static int16_t DebugOut(char ch) { if (ch == (char)'\n') Serial.println(""); else Serial.write(ch); return 0; } + +// ------------------------------------------------ +// Callback Methods +// ------------------------------------------------ +// Common Button callback +bool CbBtnCommon(void* pvGui,void *pvElemRef,gslc_teTouch eTouch,int16_t nX,int16_t nY) +{ + // Typecast the parameters to match the GUI and element types + gslc_tsGui* pGui = (gslc_tsGui*)(pvGui); + gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef); + gslc_tsElem* pElem = gslc_GetElemFromRef(pGui,pElemRef); + + if ( eTouch == GSLC_TOUCH_UP_IN ) { + // From the element's ID we can determine which button was pressed. + switch (pElem->nId) { +//