Skip to content

Commit

Permalink
firmware: app: tasks: heater_controller: Change last_mode variable to…
Browse files Browse the repository at this point in the history
… an array to control both channels individually #142
  • Loading branch information
ramonborba committed Feb 8, 2023
1 parent 3511329 commit a46cd60
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions firmware/app/tasks/heater_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ void vTaskHeaterController(void)
void heater_control(int channel, uint32_t mode, uint32_t duty_cycle)
{

static uint32_t last_mode = HEATER_AUTOMATIC_MODE;
static uint32_t last_mode[2] = { HEATER_AUTOMATIC_MODE };

switch(mode)
{
case HEATER_AUTOMATIC_MODE:
{
temperature_t temp = 0;

if (last_mode != HEATER_AUTOMATIC_MODE)
if (last_mode[channel] != HEATER_AUTOMATIC_MODE)
{
if (heater_on_off_init())
{
Expand All @@ -120,7 +120,7 @@ void heater_control(int channel, uint32_t mode, uint32_t duty_cycle)
sys_log_print_msg(" failed on/off initialization!");
sys_log_new_line();
}
last_mode = HEATER_AUTOMATIC_MODE;
last_mode[channel] = HEATER_AUTOMATIC_MODE;
}


Expand Down Expand Up @@ -149,7 +149,7 @@ void heater_control(int channel, uint32_t mode, uint32_t duty_cycle)
}
case HEATER_MANUAL_MODE:
{
if (last_mode != HEATER_MANUAL_MODE)
if (last_mode[channel] != HEATER_MANUAL_MODE)
{
if (heater_init())
{
Expand All @@ -158,7 +158,7 @@ void heater_control(int channel, uint32_t mode, uint32_t duty_cycle)
sys_log_print_msg(" failed manual mode initialization!");
sys_log_new_line();
}
last_mode = HEATER_MANUAL_MODE;
last_mode[channel] = HEATER_MANUAL_MODE;
}
if (heater_set_actuator(channel, (float)duty_cycle) != 0)
{
Expand Down

0 comments on commit a46cd60

Please sign in to comment.