@@ -28,11 +28,11 @@ uint8_t mac[6];
2828WebServer server (80 );
2929bool displayEnabled;
3030
31- const int BUTTON_PIN = 0 ; // GPIO für den Button
32- volatile unsigned long lastPressTime = 0 ; // Zeitpunkt des letzten Drucks
33- volatile bool doublePressDetected = false ; // Flag für Doppeldruck
34- const unsigned long doublePressInterval = 500 ; // Max. Zeit (in ms) zwischen zwei Drücken für Doppeldruck
35- volatile int pressCount = 0 ; // Zählt die Button-Drucke
31+ const int BUTTON_PIN = 0 ; // GPIO for the button
32+ volatile unsigned long lastPressTime = 0 ; // Time of last button press
33+ volatile bool doublePressDetected = false ; // Flag for double press
34+ const unsigned long doublePressInterval = 500 ; // Max. time (in ms) between two presses for double press
35+ volatile int pressCount = 0 ; // Counts the button presses
3636
3737const unsigned char epd_bitmap_wifi[] PROGMEM = {
3838 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
@@ -64,31 +64,32 @@ const unsigned char epd_bitmap_checkmark[] PROGMEM = {
6464};
6565
6666void IRAM_ATTR handleButtonPress () {
67- unsigned long currentTime = millis (); // Hole aktuelle Zeit
67+ unsigned long currentTime = millis (); // Get current time
6868
69- // Vermeidung von Prellen: Wenn der aktuelle Druck zu nahe am letzten liegt, ignoriere ihn
69+ // Debounce: If the current press is too close to the last one, ignore it
7070 if (currentTime - lastPressTime > 50 ) {
71- pressCount++; // Zähle den Button-Druck
72- lastPressTime = currentTime; // Aktualisiere die Zeit des letzten Drückens
71+ pressCount++; // Count the button press
7372
74- // Überprüfe, ob dies der zweite Druck innerhalb des Double-Press-Intervalls ist
73+ // Check if this is the second press within the double-press interval
7574 if (pressCount == 2 && (currentTime - lastPressTime <= doublePressInterval)) {
76- doublePressDetected = true ; // Doppeldruck erkannt
77- pressCount = 0 ; // Zähler zurücksetzen
75+ doublePressDetected = true ; // Double press detected
76+ pressCount = 0 ; // Reset counter
7877 }
78+
79+ lastPressTime = currentTime; // Update the time of the last press
7980 }
8081}
8182
82- // Funktion zum Wechseln der Boot-Partition auf OTA1
83+ // Function to switch the boot partition to OTA1
8384void setBootPartitionToOTA0 () {
8485 const esp_partition_t *ota0_partition = esp_partition_find_first (ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, NULL );
8586
8687 if (ota0_partition) {
87- // Setze OTA1 als neue Boot-Partition
88+ // Set OTA1 as new boot partition
8889 esp_ota_set_boot_partition (ota0_partition);
8990 Serial.println (" Boot partition changed to OTA0. Restarting..." );
9091
91- // Neustart, um von der neuen Partition zu booten
92+ // Restart to boot from the new partition
9293 esp_restart ();
9394 } else {
9495 Serial.println (" OTA1 partition not found!" );
@@ -111,12 +112,12 @@ void displayStatusBar(int progress) {
111112 display.setCursor (22 , 22 );
112113 display.println (" hochgeladen!" );
113114
114- display.fillRect (0 , SCREEN_HEIGHT - 24 , SCREEN_WIDTH - 4 , 8 , BLACK); // Clear status bar area
115- display.drawRect (0 , SCREEN_HEIGHT - 24 , SCREEN_WIDTH - 4 , 8 , WHITE); // Draw border
116- int filledWidth = (progress * SCREEN_WIDTH - 4 ) / 100 ; // Calculate progress width
117- display.fillRect (1 , SCREEN_HEIGHT - 23 , filledWidth - 4 , 6 , WHITE); // Fill progress bar
115+ display.fillRect (0 , SCREEN_HEIGHT - 24 , SCREEN_WIDTH- 4 , 8 , BLACK); // Clear status bar area
116+ display.drawRect (0 , SCREEN_HEIGHT - 24 , SCREEN_WIDTH- 4 , 8 , WHITE); // Draw border
117+ int filledWidth = (progress * SCREEN_WIDTH- 4 ) / 100 ; // Calculate progress width
118+ display.fillRect (1 , SCREEN_HEIGHT - 23 , filledWidth- 4 , 6 , WHITE); // Fill progress bar
118119
119- display.setCursor ((SCREEN_WIDTH / 2 ) - 12 , SCREEN_HEIGHT - 10 );
120+ display.setCursor ((SCREEN_WIDTH/ 2 )- 12 , SCREEN_HEIGHT - 10 );
120121 display.setTextSize (1 );
121122 display.setTextColor (WHITE, BLACK);
122123 display.print (progress);
@@ -134,9 +135,9 @@ void displayWelcomeScreen() {
134135 display.setCursor (40 , 13 );
135136 display.setTextSize (1 );
136137 display.setTextColor (WHITE, BLACK);
137- display.println (" Verbinde dich" );
138+ display.println (" Verbinde dich" ); // "Connect"
138139 display.setCursor (60 , 27 );
139- display.println (" mit:" );
140+ display.println (" mit:" ); // "with"
140141
141142 // Display SSID
142143 display.setCursor (40 , 43 );
@@ -156,9 +157,9 @@ void displaySuccessScreen() {
156157 display.setCursor (48 , 22 );
157158 display.setTextSize (1 );
158159 display.setTextColor (WHITE, BLACK);
159- display.println (" Erfolgreich" );
160+ display.println (" Erfolgreich" ); // "Successfully"
160161 display.setCursor (48 , 36 );
161- display.println (" hochgeladen!" );
162+ display.println (" hochgeladen!" ); // "uploaded!"
162163
163164 display.display ();
164165}
@@ -175,15 +176,15 @@ void setupWiFi() {
175176 snprintf (macLastFour, sizeof (macLastFour), " %02X%02X" , mac[4 ], mac[5 ]);
176177 ssid = " senseBox:" + String (macLastFour);
177178
178- // Definiere die IP-Adresse, Gateway und Subnetzmaske
179- IPAddress local_IP (192 , 168 , 1 , 1 ); // Die neue IP-Adresse
180- IPAddress gateway (192 , 168 , 1 , 1 ); // Gateway-Adresse (kann gleich der IP des APs sein )
181- IPAddress subnet (255 , 255 , 255 , 0 ); // Subnetzmaske
179+ // Define the IP address, gateway, and subnet mask
180+ IPAddress local_IP (192 , 168 , 1 , 1 ); // The new IP address
181+ IPAddress gateway (192 , 168 , 1 , 1 ); // Gateway address (can be the same as the AP's IP )
182+ IPAddress subnet (255 , 255 , 255 , 0 ); // Subnet mask
182183
183- // Setze die IP-Adresse, Gateway und Subnetzmaske des Access Points
184+ // Set the IP address, gateway, and subnet mask of the access point
184185 WiFi.softAPConfig (local_IP, gateway, subnet);
185186
186- // Starte den Access Point
187+ // Start the access point
187188 WiFi.softAP (ssid.c_str ());
188189}
189190
@@ -242,10 +243,10 @@ void setup() {
242243 rgb_led_1.setPixelColor (0 , rgb_led_1.Color (51 , 51 , 255 ));
243244 rgb_led_1.show ();
244245
245- // Button-Pin als Input konfigurieren
246+ // Configure button pin as input
246247 pinMode (BUTTON_PIN, INPUT_PULLUP);
247248
248- // Interrupt für den Button
249+ // Interrupt for the button
249250 attachInterrupt (digitalPinToInterrupt (BUTTON_PIN), handleButtonPress, FALLING);
250251
251252#ifdef DISPLAY_ENABLED
@@ -266,7 +267,7 @@ void loop() {
266267#endif
267268
268269 if (doublePressDetected) {
269- Serial.println (" Doppeldruck erkannt!" );
270+ Serial.println (" Doppeldruck erkannt!" ); // "Double press detected!"
270271 setBootPartitionToOTA0 ();
271272#ifdef DISPLAY_ENABLED
272273 display.setCursor (0 , 0 );
@@ -276,7 +277,7 @@ void loop() {
276277 display.display ();
277278 delay (50 );
278279#endif
279- // Neustart, um von der neuen Partition zu booten
280+ // Restart to boot from the new partition
280281 esp_restart ();
281282 }
282283}
0 commit comments