MCPcopy Create free account
hub / github.com/cifertech/nRFBox / toggleOption

Function toggleOption

nRFBox_V2/setting.cpp:30–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28bool buttonSelectPressed = false;
29
30void toggleOption(int option) {
31 if (option == 0) {
32 neoPixelActive = !neoPixelActive;
33 EEPROM.write(EEPROM_ADDRESS_NEOPIXEL, neoPixelActive);
34 EEPROM.commit();
35 Serial.print("NeoPixel is now ");
36 Serial.println(neoPixelActive ? "Enabled" : "Disabled");
37 } else if (option == 1) {
38 uint8_t brightnessPercent = map(oledBrightness, 0, 255, 0, 100); // Map to 0-100
39 brightnessPercent += 10; // Increment brightness by 10%
40 if (brightnessPercent > 100) brightnessPercent = 0; // Wrap around to 0
41 oledBrightness = map(brightnessPercent, 0, 100, 0, 255); // Map back to 0-255
42
43 u8g2.setContrast(oledBrightness); // Apply the brightness
44 EEPROM.write(EEPROM_ADDRESS_BRIGHTNESS, oledBrightness);
45 EEPROM.commit();
46
47 Serial.print("Brightness set to: ");
48 Serial.print(brightnessPercent);
49 Serial.println("%");
50 }
51}
52
53void handleButtons() {
54 if (!digitalRead(BUTTON_UP)) {

Callers 1

handleButtonsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected