Add nerdy messages and display brightness
This commit is contained in:
parent
215d412778
commit
52726c263c
16
src/main.cpp
16
src/main.cpp
@ -22,6 +22,7 @@ NTPClient timeClient(ntpUDP, "pool.ntp.org", 3600, 43200000);
|
||||
// Define these in config.h
|
||||
const String Location = LOCATION;
|
||||
const String API_Key = API_KEY;
|
||||
int displayBrightness = 205;
|
||||
|
||||
void beep(int buzz) {
|
||||
tone(PIN_BUZZER, buzz, 100);
|
||||
@ -38,7 +39,8 @@ void initSystems() {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
Wire.begin(); // Initialize I2C
|
||||
Wire.setClock(400000L); // Set I2C to Fast Mode (400 kHz)
|
||||
|
||||
display.ssd1306_command(SSD1306_SETCONTRAST);
|
||||
display.ssd1306_command(displayBrightness); // Value between 0 and 255
|
||||
// Initialize the SSD1306 display
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Adjust I2C address if needed
|
||||
for(;;); // Don't proceed, loop forever
|
||||
@ -83,6 +85,13 @@ void commonButtonHandler() {
|
||||
if (!leftBeeped) {
|
||||
beep(1000); // Play beep sound
|
||||
leftBeeped = true; // Set beeped state
|
||||
displayBrightness -= 50;
|
||||
if (displayBrightness < 10 ) {
|
||||
displayBrightness = 255;
|
||||
}
|
||||
// Send the command to set the contrast
|
||||
display.ssd1306_command(SSD1306_SETCONTRAST);
|
||||
display.ssd1306_command(displayBrightness); // Value between 0 and 255
|
||||
// Handle left short press action here
|
||||
}
|
||||
}
|
||||
@ -96,6 +105,7 @@ void commonButtonHandler() {
|
||||
if (!middleBeeped) {
|
||||
beep(1000); // Play beep sound
|
||||
middleBeeped = true; // Set beeped state
|
||||
lastWeatherUpdate = millis() + weatherUpdateInterval + 1;
|
||||
// Handle middle short press action here
|
||||
}
|
||||
}
|
||||
@ -135,7 +145,6 @@ void commonButtonHandler() {
|
||||
if (!middleBeeped) {
|
||||
beep(1000); // Play beep sound
|
||||
middleBeeped = true; // Set beeped state
|
||||
lastWeatherUpdate += weatherUpdateInterval;
|
||||
// Handle middle long press action here
|
||||
}
|
||||
}
|
||||
@ -373,7 +382,7 @@ void displayWeatherData() {
|
||||
// If the text has completely scrolled off, reset scroll position to start from the right
|
||||
if (scrollPos < -stateWidth) {
|
||||
scrollPos = SCREEN_WIDTH;
|
||||
delay(3000);
|
||||
delay(4000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -426,6 +435,7 @@ void loop() {
|
||||
if (!is_display_off && (millis() - lastWeatherUpdate > weatherUpdateInterval)) {
|
||||
fetchWeatherData();
|
||||
lastWeatherUpdate = millis();
|
||||
scrollPos = SCREEN_WIDTH;
|
||||
}
|
||||
powerSaveCheck();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user