Compare commits
2 commits
601e2ad4f0
...
c9cd379e2d
Author | SHA1 | Date | |
---|---|---|---|
KemoNine | c9cd379e2d | ||
KemoNine | ce63d33a57 |
|
@ -46,6 +46,10 @@ A debug console for serial TTL. This can be used to work with serial TTL directl
|
||||||
- Battery level on feather neopixel (green = >80% ; yellow >=40% ; orange >= 25% ; red < 25%)
|
- Battery level on feather neopixel (green = >80% ; yellow >=40% ; orange >= 25% ; red < 25%)
|
||||||
- User LED (red) always on when feather is running
|
- User LED (red) always on when feather is running
|
||||||
|
|
||||||
|
## Building / Uploading
|
||||||
|
|
||||||
|
The ```make.ps1```, ```build.ps1``` and ```upload.ps1``` scripts can be used to build/upload this project. These scripts call the ```arduino-cli``` commands programatically.
|
||||||
|
|
||||||
## Licensing
|
## Licensing
|
||||||
|
|
||||||
Unless otherwise stated all source code is licensed under the [Apache 2 License](LICENSE-APACHE-2.0.txt).
|
Unless otherwise stated all source code is licensed under the [Apache 2 License](LICENSE-APACHE-2.0.txt).
|
||||||
|
|
1
build.ps1
Normal file
1
build.ps1
Normal file
|
@ -0,0 +1 @@
|
||||||
|
arduino-cli compile --log-level=warn --fqbn adafruit:nrf52:feather52840 serial_debugger.ino
|
9
make.ps1
9
make.ps1
|
@ -1 +1,8 @@
|
||||||
arduino-cli compile --log-level=warn --fqbn adafruit:nrf52:feather52840 serial_debugger.ino
|
# 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
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
// Various library includes
|
// Various library includes
|
||||||
#include <Adafruit_NeoPixel.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
#include <Adafruit_GFX.h>
|
||||||
|
#include <Adafruit_ILI9341.h>
|
||||||
|
|
||||||
// Debugging via serial monitor (don't turn this on unless you're hacking on the firmware code)
|
// Debugging via serial monitor (don't turn this on unless you're hacking on the firmware code)
|
||||||
#define DEBUG true
|
#define DEBUG true
|
||||||
|
@ -12,10 +14,26 @@
|
||||||
float measuredVBat;
|
float measuredVBat;
|
||||||
float batteryPercent;
|
float 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
|
||||||
|
|
||||||
// NeoPixels
|
// NeoPixels
|
||||||
#define NUMPIXELS 1
|
#define NUMPIXELS 1
|
||||||
Adafruit_NeoPixel pixels(NUMPIXELS, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
|
Adafruit_NeoPixel pixels(NUMPIXELS, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
|
// UI screens
|
||||||
|
void screenClear();
|
||||||
|
|
||||||
|
// Color conversion (RGB888 -> RGB565 used by Adafruit GFX)
|
||||||
|
uint16_t RGB565(uint8_t r, uint8_t g, uint8_t b) {
|
||||||
|
return ((r & 0b11111000) << 8) | ((g & 0b11111100) << 3) | (b >> 3);
|
||||||
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Setup red LED to indicate device is on (in case we disable NeoPixel battery level later)
|
// Setup red LED to indicate device is on (in case we disable NeoPixel battery level later)
|
||||||
pinMode(3, OUTPUT);
|
pinMode(3, OUTPUT);
|
||||||
|
@ -32,6 +50,13 @@ void setup() {
|
||||||
// Red : pixels.Color(255, 0, 0)
|
// Red : pixels.Color(255, 0, 0)
|
||||||
pixels.setPixelColor(0, pixels.Color(0, 0, 0));
|
pixels.setPixelColor(0, pixels.Color(0, 0, 0));
|
||||||
pixels.show();
|
pixels.show();
|
||||||
|
|
||||||
|
// Setup TFT
|
||||||
|
tft.begin();
|
||||||
|
tft.setRotation(1);
|
||||||
|
screenClear();
|
||||||
|
tft.println("");
|
||||||
|
tft.setFont(&FreeMono9pt7b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Measure battery level and change NeoPixel accordingly
|
// Measure battery level and change NeoPixel accordingly
|
||||||
|
@ -67,3 +92,9 @@ void loop() {
|
||||||
|
|
||||||
delay(250);
|
delay(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear the screen
|
||||||
|
void screenClear() {
|
||||||
|
tft.setCursor(0, 0);
|
||||||
|
tft.fillScreen(RGB565(0, 0, 0));
|
||||||
|
}
|
|
@ -1 +1,4 @@
|
||||||
arduino-cli upload --fqbn adafruit:nrf52:feather52840 -p COM5
|
# Get list of boards
|
||||||
|
$COM_PORT=$(arduino-cli board list | Select-String -Pattern "adafruit:nrf52:feather52840" | %{ $_.ToString().Split(' ')[0]; })
|
||||||
|
Write-Host "Using serial port $($COM_PORT)"
|
||||||
|
arduino-cli upload --fqbn adafruit:nrf52:feather52840 -p $COM_PORT
|
||||||
|
|
Reference in a new issue