Implement brightness handling
This commit is contained in:
parent
3584bcac40
commit
8b3b1ee58b
|
@ -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) {
|
||||
|
|
Reference in a new issue