@@ -72,45 +72,29 @@ void initVariant(void) {
72
72
.loop_count = 0
73
73
};
74
74
75
- uint8_t pixel[3 ] = { 0x10 , 0x00 , 0x00 }; // green
76
- blinkLED (pixel, led_chan, ws2812_encoder, tx_config);
77
-
78
75
// define button pin
79
- pinMode (0 , INPUT_PULLUP);
80
-
81
- // keep button pressed
82
- unsigned long pressStartTime = 0 ;
83
- bool buttonPressed = false ;
84
-
85
- // Wait 3.5 seconds for the button to be pressed
86
- unsigned long startTime = millis ();
76
+ pinMode (47 , INPUT_PULLUP);
87
77
88
78
// Check if button is pressed
89
- while (millis () - startTime < 3500 ) {
90
- if (digitalRead (0 ) == LOW) {
91
- if (!buttonPressed) {
92
- // The button was pressed
93
- buttonPressed = true ;
94
- }
95
- } else if (buttonPressed) {
96
- // When the button is pressed and then released, boot into the OTA1 partition
97
- const esp_partition_t *ota1_partition = esp_partition_find_first (ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, NULL );
79
+ if (digitalRead (47 ) == LOW) {
80
+ // When the button is pressed and then released, boot into the OTA1 partition
81
+ const esp_partition_t *ota1_partition = esp_partition_find_first (ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, NULL );
98
82
99
- if (ota1_partition) {
100
- esp_err_t err = esp_ota_set_boot_partition (ota1_partition);
101
- if (err == ESP_OK) {
102
- uint8_t pixel[3 ] = { 0x00 , 0x00 , 0x10 }; // blue
103
- blinkLED (pixel, led_chan, ws2812_encoder, tx_config);
104
- esp_restart (); // restart, to boot OTA1 partition
105
- } else {
106
- uint8_t pixel[3 ] = { 0x00 , 0x10 , 0x00 }; // red
107
- blinkLED (pixel, led_chan, ws2812_encoder, tx_config);
108
- ESP_LOGE (" OTA" , " Error setting OTA1 partition: %s" , esp_err_to_name (err));
109
- }
83
+ if (ota1_partition) {
84
+ esp_err_t err = esp_ota_set_boot_partition (ota1_partition);
85
+ if (err == ESP_OK) {
86
+ uint8_t pixel[3 ] = { 0x00 , 0x00 , 0x10 }; // blue
87
+ blinkLED (pixel, led_chan, ws2812_encoder, tx_config);
88
+ esp_restart (); // restart, to boot OTA1 partition
89
+ } else {
90
+ uint8_t pixel[3 ] = { 0x00 , 0x10 , 0x00 }; // red
91
+ blinkLED (pixel, led_chan, ws2812_encoder, tx_config);
92
+ ESP_LOGE (" OTA" , " Error setting OTA1 partition: %s" , esp_err_to_name (err));
110
93
}
111
- // Abort after releasing the button
112
- break ;
113
94
}
95
+ } else {
96
+ uint8_t pixel[3 ] = { 0x10 , 0x00 , 0x00 }; // green
97
+ blinkLED (pixel, led_chan, ws2812_encoder, tx_config);
114
98
}
115
99
}
116
100
}
0 commit comments