General improvements

This commit is contained in:
Tomislav Kopić 2024-11-09 07:54:39 +01:00
parent 32689e6f35
commit 86d5bcc729

View File

@ -42,6 +42,9 @@ void initSystems() {
pinMode(PIN_BUZZER, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
Wire.begin(); // Initialize I2C
Wire.setClock(400000); // Set I2C to Fast Mode (400 kHz)
// Initialize the SSD1306 display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Adjust I2C address if needed
for(;;); // Don't proceed, loop forever
@ -242,7 +245,7 @@ bool fetchWeatherData() {
int scrollPos = SCREEN_WIDTH; // Global variable to keep track of the scroll position
unsigned long lastScrollTime = 0; // To control the scroll speed
const int scrollDelay = 40; // Delay in milliseconds between scroll updates
const int scrollDelay = 30; // Delay in milliseconds between scroll updates
void displayWeatherData() {
display.clearDisplay();
@ -311,6 +314,8 @@ void setup(void) {
void loop() {
timeClient.update();
commonButtonHandler();
displayWeatherData();
if (display_override && (millis() - lastDisplayOverride > displayOverrideTimeout)){
display_override = false;
lastDisplayOverride = millis();
@ -319,7 +324,5 @@ void loop() {
fetchWeatherData();
lastWeatherUpdate = millis();
}
displayWeatherData();
powerSaveCheck();
commonButtonHandler();
}