Load calibration when SD card is inserted.
* Load calibration when SD card is inserted and controller is not yet calibrated * Fix #7: LED0 blinks when SD is inserted / removed.
This commit is contained in:
parent
58937b46f6
commit
227562cf3c
@ -44,6 +44,7 @@
|
|||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
#include <reflow-controller/reflow-menu.h>
|
#include <reflow-controller/reflow-menu.h>
|
||||||
#include <reflow-controller/safety/safety-controller.h>
|
#include <reflow-controller/safety/safety-controller.h>
|
||||||
|
#include <reflow-controller/settings/settings.h>
|
||||||
|
|
||||||
static void setup_nvic_priorities(void)
|
static void setup_nvic_priorities(void)
|
||||||
{
|
{
|
||||||
@ -191,7 +192,12 @@ static void zero_ccm_ram(void)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
bool cal_active;
|
||||||
|
float offset;
|
||||||
|
float sens;
|
||||||
|
int status;
|
||||||
bool sd_card_mounted = false;
|
bool sd_card_mounted = false;
|
||||||
|
bool sd_old;
|
||||||
shellmatta_handle_t shell_handle;
|
shellmatta_handle_t shell_handle;
|
||||||
int menu_wait_request;
|
int menu_wait_request;
|
||||||
uint64_t quarter_sec_timestamp = 0ULL;
|
uint64_t quarter_sec_timestamp = 0ULL;
|
||||||
@ -204,7 +210,25 @@ int main(void)
|
|||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
if (systick_ticks_have_passed(quarter_sec_timestamp, 250)) {
|
if (systick_ticks_have_passed(quarter_sec_timestamp, 250)) {
|
||||||
|
sd_old = sd_card_mounted;
|
||||||
sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted);
|
sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted);
|
||||||
|
|
||||||
|
if (sd_old != sd_card_mounted) {
|
||||||
|
led_set(0, 1);
|
||||||
|
} else {
|
||||||
|
led_set(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sd_card_mounted && !sd_old) {
|
||||||
|
adc_pt1000_get_resistance_calibration(NULL, NULL, &cal_active);
|
||||||
|
if (!cal_active) {
|
||||||
|
status = settings_load_calibration(&sens, &offset);
|
||||||
|
if (!status) {
|
||||||
|
adc_pt1000_set_resistance_calibration(offset, sens, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
quarter_sec_timestamp = systick_get_global_tick();
|
quarter_sec_timestamp = systick_get_global_tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user