Browse Source

Implement brightness handling

master
Mike C 6 years ago
parent
commit
8b3b1ee58b
  1. 5
      src/src.ino

5
src/src.ino

@ -18,7 +18,7 @@
// Objects / values / etc
MAX1704 fuelGauge;
float charge_percent;
uint16_t brightness;
uint8_t brightness;
uint16_t color;
bool always_on = false;
Adafruit_NeoPixel neopix = Adafruit_NeoPixel(NEO_PIX_NUM, NEO_PIN, NEO_GRB + NEO_KHZ800);
@ -61,7 +61,7 @@ void setup() {
void loop() {
// Read various values needed
charge_percent = fuelGauge.stateOfCharge(); // Battery level
brightness = analogRead(POT_BRIGHT_PIN); // Brightness (0-1023)
brightness = map(analogRead(POT_BRIGHT_PIN), 0, 1023, 0, 255); // Brightness (0-1023) mapped to 0-255
color = analogRead(POT_COLOR_PIN); // Color (0-1023 mapped to color wheel)
always_on = (digitalRead(BUTTON_CAP_TOGGLE) == HIGH); // Toggle button pressed == ALWAYS ON
@ -69,6 +69,7 @@ void loop() {
neopix.setPixelColor(0, neopix.Color(255, 255, 255)); // White
neopix.setPixelColor(1, neopix.Color(0, 0, 255)); // Blue
neopix.show();
neopix.setBrightness(brightness);
// Debugging code
if (DEBUG) {

Loading…
Cancel
Save