diff --git a/Firmware-vscode/gpio.cpp b/Firmware-vscode/gpio.cpp index 341b09f..3c1d887 100644 --- a/Firmware-vscode/gpio.cpp +++ b/Firmware-vscode/gpio.cpp @@ -13,8 +13,9 @@ void gpio_init() gpioOK = gpio_port.begin(); if (!gpioOK) return; gpio_port.setClock(400000); + gpio_write_all(mem_get_gpio()); //Set output values first, since default value for output register is "all ON" uint8_t current_pin = 0; - for (uint8_t i = 0; i < arraySize(gpio_map); i++) + for (uint8_t i = 0; i < arraySize(gpio_map); i++) //Only then set pin modes so that they can actually become outputs { uint8_t state = i % 2 == 0 ? OUTPUT : INPUT; for (uint8_t j = 0; j < gpio_map[i]; j++) diff --git a/Firmware-vscode/mem.cpp b/Firmware-vscode/mem.cpp index 9907600..7941812 100644 --- a/Firmware-vscode/mem.cpp +++ b/Firmware-vscode/mem.cpp @@ -76,6 +76,11 @@ void mem_save() mem_save_array_b(ee_cooler_enable, enableCooler, arraySize(ee_cooler_enable)); } +uint16_t mem_get_gpio() +{ + return eeprom_read_word(&ee_gpio); +} + void mem_load() { Setpoint = eeprom_read_float(&ee_setpoint); @@ -97,7 +102,6 @@ void mem_load() distillExtraPower = eeprom_read_float(&ee_distillation_bias); distillTempWindow = eeprom_read_float(&ee_distillation_window); rampStepLimit = eeprom_read_float(&ee_ramp_step); - gpio_write_all(eeprom_read_word(&ee_gpio)); cjc = eeprom_read_byte(&ee_cjc); mem_load_array_b(ee_cooler_enable, enableCooler, arraySize(ee_cooler_enable)); } diff --git a/Firmware-vscode/thermo.h b/Firmware-vscode/thermo.h index db3b8b9..7ca90c4 100644 --- a/Firmware-vscode/thermo.h +++ b/Firmware-vscode/thermo.h @@ -173,6 +173,7 @@ void mem_set_first_run(); void mem_save(); void mem_load(); void mem_save_persistent(); +uint16_t mem_get_gpio(); #pragma endregion