add mode parameter to write_mode to avoid PB bounce

pico-v0.39
alanbjohnston 3 years ago committed by GitHub
parent 5969171c5b
commit 0112404ac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4461,7 +4461,7 @@ void prompt_for_input() {
Serial.println("d Change debug mode");
Serial.println("w Connect to WiFi\n");
Serial.printf("Software version v0.38 \nConfig file /sim.cfg contains %s %d %f %f %s\n\n", callsign, reset_count, lat_file, long_file, sim_yes);
Serial.printf("Software version v0.39 \nConfig file /sim.cfg contains %s %d %f %f %s\n\n", callsign, reset_count, lat_file, long_file, sim_yes);
switch(mode) {
@ -4902,7 +4902,7 @@ void read_mode() {
char buff[32];
File mode_file = LittleFS.open("/.mode", "r");
if (!mode_file) {
write_mode();
write_mode(mode);
} else {
if (mode_file.read((uint8_t *)buff, 31)) {
// Serial.println("Reading mode from .mode file");
@ -4915,13 +4915,13 @@ void read_mode() {
}
}
void write_mode() {
void write_mode(int save_mode) {
char buff[32];
Serial.println("Writing .mode file");
File mode_file = LittleFS.open("/.mode", "w+");
sprintf(buff, "%d", mode);
sprintf(buff, "%d", save_mode);
if (debug_mode) {
Serial.println("Writing string");
print_string(buff);
@ -4979,8 +4979,8 @@ void get_input() {
/// }
int old_mode = mode;
bool config_done = false;
mode = new_mode; // change modes if button pressed
write_mode();
// mode = new_mode; // change modes if button pressed
write_mode(new_mode);
Serial.println("Rebooting...");
watchdog_reboot (0, SRAM_END, 10); // restart Pico

Loading…
Cancel
Save

Powered by TurnKey Linux.