Skip to content

Commit 668b85b

Browse files
ci(pre-commit): Apply automatic fixes
1 parent e5ff857 commit 668b85b

File tree

2 files changed

+50
-70
lines changed

2 files changed

+50
-70
lines changed

variants/sensebox_mcu_esp32s2/APOTA.ino

Lines changed: 47 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77
#include <Update.h>
88
#include <Wire.h>
99
#ifdef DISPLAY_ENABLED
10-
#define SCREEN_WIDTH 128
10+
#define SCREEN_WIDTH 128
1111
#define SCREEN_HEIGHT 64
12-
#define OLED_RESET -1
12+
#define OLED_RESET -1
1313
#include <Adafruit_GFX.h>
1414
#include <Adafruit_SSD1306.h>
1515
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
1616
#include <Adafruit_NeoPixel.h>
1717
Adafruit_NeoPixel rgb_led_1 = Adafruit_NeoPixel(1, 1, NEO_GRB + NEO_KHZ800);
1818

19-
2019
#endif
2120
#include "esp_partition.h"
2221
#include "esp_ota_ops.h"
@@ -25,7 +24,6 @@ Adafruit_NeoPixel rgb_led_1 = Adafruit_NeoPixel(1, 1, NEO_GRB + NEO_KHZ800);
2524
String ssid;
2625
uint8_t mac[6];
2726

28-
2927
// Create an instance of the server
3028
WebServer server(80);
3129
bool displayEnabled;
@@ -36,48 +34,35 @@ volatile bool doublePressDetected = false; // Flag für Doppeldruck
3634
const unsigned long doublePressInterval = 500; // Max. Zeit (in ms) zwischen zwei Drücken für Doppeldruck
3735
volatile int pressCount = 0; // Zählt die Button-Drucke
3836

39-
const unsigned char epd_bitmap_wifi [] PROGMEM = {
40-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x01,
42-
0xff, 0xf0, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x1f, 0xe0, 0xff, 0x00, 0x00,
43-
0x00, 0x3f, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x7c, 0x00, 0x03, 0xe0, 0x00, 0x00, 0xf0, 0x00, 0x01,
44-
0xf0, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x78, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x38, 0x00, 0x07, 0x80,
45-
0x00, 0x00, 0x1c, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x7f, 0xe0, 0x0e, 0x00,
46-
0x0c, 0x01, 0xff, 0xf0, 0x06, 0x00, 0x00, 0x07, 0xff, 0xfc, 0x02, 0x00, 0x00, 0x0f, 0x80, 0x3e,
47-
0x00, 0x00, 0x00, 0x1f, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x07, 0x80, 0x00, 0x00, 0x38,
48-
0x00, 0x03, 0xc0, 0x00, 0x00, 0x70, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x70, 0x00, 0x00, 0xc0, 0x00,
49-
0x00, 0x20, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0,
50-
0x00, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x01, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0x01,
51-
0xc0, 0x78, 0x00, 0x00, 0x00, 0x03, 0x80, 0x38, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00,
52-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54-
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
55-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
37+
const unsigned char epd_bitmap_wifi[] PROGMEM = {
38+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39+
0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x01, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x1f, 0xe0, 0xff, 0x00, 0x00,
40+
0x00, 0x3f, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x7c, 0x00, 0x03, 0xe0, 0x00, 0x00, 0xf0, 0x00, 0x01, 0xf0, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x78, 0x00,
41+
0x03, 0xc0, 0x00, 0x00, 0x38, 0x00, 0x07, 0x80, 0x00, 0x00, 0x1c, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x7f, 0xe0, 0x0e, 0x00,
42+
0x0c, 0x01, 0xff, 0xf0, 0x06, 0x00, 0x00, 0x07, 0xff, 0xfc, 0x02, 0x00, 0x00, 0x0f, 0x80, 0x3e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x0f, 0x00, 0x00,
43+
0x00, 0x1c, 0x00, 0x07, 0x80, 0x00, 0x00, 0x38, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x70, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x70, 0x00, 0x00, 0xc0, 0x00,
44+
0x00, 0x20, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00,
45+
0x00, 0x01, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x03, 0x80, 0x38, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00,
46+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
48+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
5749
};
5850

5951
// 'checkmark', 44x44px
60-
const unsigned char epd_bitmap_checkmark [] PROGMEM = {
61-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
65-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00,
66-
0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00,
67-
0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78,
68-
0x00, 0x00, 0x00, 0x0e, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x0f,
69-
0x83, 0xc0, 0x00, 0x00, 0x00, 0x07, 0xc7, 0x80, 0x00, 0x00, 0x00, 0x03, 0xef, 0x00, 0x00, 0x00,
70-
0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00,
71-
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
75-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
77-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
52+
const unsigned char epd_bitmap_checkmark[] PROGMEM = {
53+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56+
0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00,
57+
0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xf0, 0x00, 0x00,
58+
0x00, 0x0f, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x0f, 0x83, 0xc0, 0x00, 0x00, 0x00, 0x07, 0xc7, 0x80, 0x00, 0x00, 0x00, 0x03, 0xef, 0x00, 0x00, 0x00,
59+
0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
60+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
7864
};
7965

80-
8166
void IRAM_ATTR handleButtonPress() {
8267
unsigned long currentTime = millis(); // Hole aktuelle Zeit
8368

@@ -96,8 +81,7 @@ void IRAM_ATTR handleButtonPress() {
9681

9782
// Funktion zum Wechseln der Boot-Partition auf OTA1
9883
void setBootPartitionToOTA0() {
99-
const esp_partition_t* ota0_partition = esp_partition_find_first(
100-
ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, NULL);
84+
const esp_partition_t *ota0_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, NULL);
10185

10286
if (ota0_partition) {
10387
// Setze OTA1 als neue Boot-Partition
@@ -127,20 +111,19 @@ void displayStatusBar(int progress) {
127111
display.setCursor(22, 22);
128112
display.println("hochgeladen!");
129113

130-
display.fillRect(0, SCREEN_HEIGHT - 24, SCREEN_WIDTH-4, 8, BLACK); // Clear status bar area
131-
display.drawRect(0, SCREEN_HEIGHT - 24, SCREEN_WIDTH-4, 8, WHITE); // Draw border
132-
int filledWidth = (progress * SCREEN_WIDTH-4) / 100; // Calculate progress width
133-
display.fillRect(1, SCREEN_HEIGHT - 23, filledWidth-4, 6, WHITE); // Fill progress bar
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
134118

135-
display.setCursor((SCREEN_WIDTH/2)-12, SCREEN_HEIGHT - 10);
119+
display.setCursor((SCREEN_WIDTH / 2) - 12, SCREEN_HEIGHT - 10);
136120
display.setTextSize(1);
137121
display.setTextColor(WHITE, BLACK);
138122
display.print(progress);
139123
display.println(" %");
140124
display.display();
141125
}
142126

143-
144127
void displayWelcomeScreen() {
145128
display.clearDisplay();
146129

@@ -157,7 +140,7 @@ void displayWelcomeScreen() {
157140

158141
// Display SSID
159142
display.setCursor(40, 43);
160-
display.setTextSize(1); // Larger text for SSID
143+
display.setTextSize(1); // Larger text for SSID
161144
display.print(ssid);
162145

163146
display.display();
@@ -180,15 +163,12 @@ void displaySuccessScreen() {
180163
display.display();
181164
}
182165

183-
void wipeDisplay(){
184-
display.clearDisplay();
185-
display.println("");
186-
display.display();
166+
void wipeDisplay() {
167+
display.clearDisplay();
168+
display.println("");
169+
display.display();
187170
}
188171

189-
190-
191-
192172
void setupWiFi() {
193173
WiFi.macAddress(mac);
194174
char macLastFour[5];
@@ -210,18 +190,19 @@ void setupWiFi() {
210190
void setupOTA() {
211191
// Handle updating process
212192
server.on(
213-
"/sketch", HTTP_POST, []() {
193+
"/sketch", HTTP_POST,
194+
[]() {
214195
server.sendHeader("Connection", "close");
215196
server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK");
216197
ESP.restart();
217198
},
218199
[]() {
219-
HTTPUpload& upload = server.upload();
200+
HTTPUpload &upload = server.upload();
220201

221202
if (upload.status == UPLOAD_FILE_START) {
222203
Serial.setDebugOutput(true);
223204
size_t fsize = UPDATE_SIZE_UNKNOWN;
224-
if(server.clientContentLength() > 0){
205+
if (server.clientContentLength() > 0) {
225206
fsize = server.clientContentLength();
226207
}
227208
Serial.printf("Receiving Update: %s, Size: %d\n", upload.filename.c_str(), fsize);
@@ -236,7 +217,7 @@ void setupOTA() {
236217
Update.printError(Serial);
237218
} else {
238219
int progress = (Update.progress() * 100) / Update.size();
239-
displayStatusBar(progress); // Update progress on status bar
220+
displayStatusBar(progress); // Update progress on status bar
240221
}
241222
} else if (upload.status == UPLOAD_FILE_END) {
242223
if (Update.end(true)) { //true to set the size to the current progress
@@ -249,7 +230,8 @@ void setupOTA() {
249230
Serial.setDebugOutput(false);
250231
}
251232
yield();
252-
});
233+
}
234+
);
253235
}
254236

255237
void setup() {
@@ -287,14 +269,14 @@ void loop() {
287269
Serial.println("Doppeldruck erkannt!");
288270
setBootPartitionToOTA0();
289271
#ifdef DISPLAY_ENABLED
290-
display.setCursor(0,0);
272+
display.setCursor(0, 0);
291273
display.setTextSize(1);
292-
display.setTextColor(WHITE,BLACK);
274+
display.setTextColor(WHITE, BLACK);
293275
display.println("");
294276
display.display();
295277
delay(50);
296278
#endif
297279
// Neustart, um von der neuen Partition zu booten
298280
esp_restart();
299281
}
300-
}
282+
}

variants/sensebox_mcu_esp32s2/variant.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,19 @@ void initVariant(void) {
5454
}
5555
} else if (buttonPressed) {
5656
// When the button is pressed and then released, boot into the OTA1 partition
57-
const esp_partition_t* ota1_partition = esp_partition_find_first(
58-
ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, NULL);
57+
const esp_partition_t *ota1_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, NULL);
5958

6059
if (ota1_partition) {
6160
esp_err_t err = esp_ota_set_boot_partition(ota1_partition);
6261
if (err == ESP_OK) {
6362
esp_restart(); // restart, to boot OTA1 partition
6463
} else {
65-
ESP_LOGE("OTA", "Error setting OTA1 partition: %s", esp_err_to_name(err));
64+
ESP_LOGE("OTA", "Error setting OTA1 partition: %s", esp_err_to_name(err));
6665
}
6766
}
6867
// Abort after releasing the button
6968
break;
7069
}
7170
}
7271
}
73-
74-
}
72+
}

0 commit comments

Comments
 (0)