80828aa021
Tweaks for fan service to keep it offline more frequently and scale up faster ; wil adjust polling interval after further testing and verification
Replace pimoroni fan shim
Replaced with argon fan ; will be adding fan speed based on temp to piframe-go soon
Debug console
Closing / wontfix as this is well outside the scope of PiFrame. Moved to a personal project instead.
Debug console
// Varous system / library includes
#include <Adafruit_NeoPixel.h>
// Debugging via serial monitor (don't turn this on unless you're hacking on the firmware code)
#define DEBUG true
// Battery level measurement
#define VBATPIN A6
float measuredVBat;
float batteryPercent;
#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
void setup() {
// 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.begin();
pixels.clear();
pixels.setBrightness(10);
// 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.setPixelColor(0, pixels.Color(0, 0, 0));
pixels.show();
}
// Measure battery level and change NeoPixel accordingly
void batteryLevel() {
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;
if (batteryPercent >= 0.75) {
pixels.setPixelColor(0, pixels.Color(0, 255, 0));
}
else if (batteryPercent >= 0.50) {
pixels.setPixelColor(0, pixels.Color(255, 255, 0));
}
else if (batteryPercent >= 0.25) {
pixels.setPixelColor(0, pixels.Color(255, 128, 0));
}
else {
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
}
pixels.show();
if (DEBUG) {
Serial.print("VBat: " ); Serial.println(measuredVBat);
Serial.print("Bat %: "); Serial.println(batteryPercent);
}
}
void loop() {
// Update battery level as appropriate
batteryLevel();
delay(250);
}
1b5d77e07a
Tweak string format, exit if config changes -- let monit and / or systemd restart if the config changes on disk out from under the running app ; will add save/exit button later to ensure that making changes via the config ui doesn't cause the app to restart after every change