Merge remote-tracking branch 'root/master' into dev

1.2-legacy
geeksville 2020-06-24 14:08:36 -07:00
commit 5687bd09c6
3 zmienionych plików z 24 dodań i 0 usunięć

Wyświetl plik

@ -136,6 +136,9 @@ Periodic ledPeriodic(ledBlinker);
void userButtonPressed() { void userButtonPressed() {
powerFSM.trigger(EVENT_PRESS); powerFSM.trigger(EVENT_PRESS);
} }
void userButtonPressedLong(){
screen.adjustBrightness();
}
#ifndef NO_ESP32 #ifndef NO_ESP32
void initWifi() void initWifi()
@ -197,10 +200,12 @@ void setup()
#ifdef BUTTON_PIN #ifdef BUTTON_PIN
userButton = OneButton(BUTTON_PIN, true, true); userButton = OneButton(BUTTON_PIN, true, true);
userButton.attachClick(userButtonPressed); userButton.attachClick(userButtonPressed);
userButton.attachDuringLongPress(userButtonPressedLong);
#endif #endif
#ifdef BUTTON_PIN_ALT #ifdef BUTTON_PIN_ALT
userButtonAlt = OneButton(BUTTON_PIN_ALT, true, true); userButtonAlt = OneButton(BUTTON_PIN_ALT, true, true);
userButtonAlt.attachClick(userButtonPressed); userButtonAlt.attachClick(userButtonPressed);
userButton.attachDuringLongPress(userButtonPressedLong);
#endif #endif
#ifdef LED_PIN #ifdef LED_PIN
pinMode(LED_PIN, OUTPUT); pinMode(LED_PIN, OUTPUT);

Wyświetl plik

@ -732,4 +732,19 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
display->drawLogBuffer(x, yo); display->drawLogBuffer(x, yo);
} }
//adjust Brightness cycle trough 1 to 254 as long as attachDuringLongPress is true
void Screen::adjustBrightness(){
if (brightness == 254)
{
brightness = 0;
} else {
brightness++;
}
int width = brightness / 1.984375;
dispdev.drawRect( 0, 30, 128, 4);
dispdev.fillRect(0, 30, width, 4);
dispdev.display();
dispdev.setBrightness(brightness);
}
} // namespace meshtastic } // namespace meshtastic

Wyświetl plik

@ -117,6 +117,10 @@ class Screen : public PeriodicTask
/// Handles a button press. /// Handles a button press.
void onPress() { enqueueCmd(CmdItem{.cmd = Cmd::ON_PRESS}); } void onPress() { enqueueCmd(CmdItem{.cmd = Cmd::ON_PRESS}); }
// Implementation to Adjust Brightness
void adjustBrightness();
int brightness = 150;
/// Starts showing the Bluetooth PIN screen. /// Starts showing the Bluetooth PIN screen.
// //
// Switches over to a static frame showing the Bluetooth pairing screen // Switches over to a static frame showing the Bluetooth pairing screen