Browse Source

update

Finny_test
zwsd 3 years ago
parent
commit
01569c5a8e
  1. 4
      main/app_main.cpp
  2. 78
      main/light.c
  3. 8
      main/light.h

4
main/app_main.cpp

@ -117,9 +117,11 @@ void process_key_long_press_event(void)
/* 配网 */ /* 配网 */
if (!wifi_structer.wifi_distribution_network_flag) if (!wifi_structer.wifi_distribution_network_flag)
{ {
T_wifi_light_change_state(Connecting);
if (T_wifi_distribution_network()) if (T_wifi_distribution_network())
{ {
wifi_structer.wifi_distribution_network_flag = true; wifi_structer.wifi_distribution_network_flag = true;
T_wifi_light_change_state(ConnectionComplete);
} }
} }
} }
@ -156,7 +158,7 @@ extern "C" void app_main(void)
while (true) while (true)
{ {
T_debug_light_schedule(); T_debug_light_schedule();
T_light_flash_schedule();
T_light_schedule();
T_key_schedule(); T_key_schedule();
T_heating_plate_schedule(); T_heating_plate_schedule();
T_reaction_schedule(); T_reaction_schedule();

78
main/light.c

@ -77,6 +77,24 @@ void T_heating_plate_state_light_init(heating_plate_state_light_structer_t *heat
gpio_config(&gpio_heating_plate_state_light_init_structer); gpio_config(&gpio_heating_plate_state_light_init_structer);
} }
void T_heating_plate_light_change_state(heating_plate_state_t change_state)
{
heating_plate_state_light_structer_s->state = change_state;
heating_plate_state_light_structer_s->change_flag = true;
}
void T_heating_plate_light_set_rgb_by_state(heating_plate_state_t state)
{
if (state == NoHeat)
{
gpio_set_level(GPIO_HEATING_PLATE_STATE_LIGHT, 0);
}
else if (state == HeatComplete)
{
gpio_set_level(GPIO_HEATING_PLATE_STATE_LIGHT, 1);
}
}
// Reaction state light // Reaction state light
void T_reaction_state_light_init(reaction_state_light_structer_t *reaction_state_light_structer) void T_reaction_state_light_init(reaction_state_light_structer_t *reaction_state_light_structer)
{ {
@ -92,6 +110,24 @@ void T_reaction_state_light_init(reaction_state_light_structer_t *reaction_state
gpio_config(&gpio_reaction_state_light_init_structer); gpio_config(&gpio_reaction_state_light_init_structer);
} }
void T_reaction_light_change_state(reaction_state_t change_state)
{
reaction_state_light_structer_s->state = change_state;
reaction_state_light_structer_s->change_flag = true;
}
void T_reaction_light_set_rgb_by_state(reaction_state_t state)
{
if (state == NoReaction)
{
gpio_set_level(GPIO_REACTION_STATE_LIGHT, 0);
}
else if (state == ReactionComplete)
{
gpio_set_level(GPIO_REACTION_STATE_LIGHT, 1);
}
}
// WIFI state light // WIFI state light
void T_wifi_state_light_init(wifi_state_light_structer_t *wifi_state_light_structer) void T_wifi_state_light_init(wifi_state_light_structer_t *wifi_state_light_structer)
{ {
@ -107,6 +143,24 @@ void T_wifi_state_light_init(wifi_state_light_structer_t *wifi_state_light_struc
gpio_config(&gpio_wifi_state_light_init_structer); gpio_config(&gpio_wifi_state_light_init_structer);
} }
void T_wifi_light_change_state(wifi_state_t change_state)
{
wifi_state_light_structer_s->state = change_state;
wifi_state_light_structer_s->change_flag = true;
}
void T_wifi_light_set_rgb_by_state(wifi_state_t state)
{
if (state == NotConnected)
{
gpio_set_level(GPIO_WIFI_STATE_LIGHT, 0);
}
else if (state == ConnectionComplete)
{
gpio_set_level(GPIO_WIFI_STATE_LIGHT, 1);
}
}
void T_debug_light_schedule(void) void T_debug_light_schedule(void)
{ {
static uint32_t debug_light_time; static uint32_t debug_light_time;
@ -117,10 +171,26 @@ void T_debug_light_schedule(void)
} }
} }
void T_light_flash_schedule(void)
void T_light_schedule(void)
{ {
static uint32_t debug_light_time;
if (port_haspassedms(debug_light_time) > OTHER_LIGHT_TOGGLE_TIME)
static uint32_t light_ticket;
if (heating_plate_state_light_structer_s->change_flag)
{
T_heating_plate_light_set_rgb_by_state(heating_plate_state_light_structer_s->state);
heating_plate_state_light_structer_s->change_flag = false;
}
if (reaction_state_light_structer_s->change_flag)
{
T_reaction_light_set_rgb_by_state(reaction_state_light_structer_s->state);
reaction_state_light_structer_s->change_flag = false;
}
if (wifi_state_light_structer_s->change_flag)
{
T_reaction_light_set_rgb_by_state(wifi_state_light_structer_s->state);
wifi_state_light_structer_s->change_flag = false;
}
if (port_haspassedms(light_ticket) > OTHER_LIGHT_TOGGLE_TIME)
{ {
if (heating_plate_state_light_structer_s->state == Heating) if (heating_plate_state_light_structer_s->state == Heating)
{ {
@ -136,6 +206,6 @@ void T_light_flash_schedule(void)
{ {
T_light_toggle_level(GPIO_WIFI_STATE_LIGHT); T_light_toggle_level(GPIO_WIFI_STATE_LIGHT);
} }
debug_light_time = port_get_ticket();
light_ticket = port_get_ticket();
} }
} }

8
main/light.h

@ -63,13 +63,19 @@ void T_power_light_init(power_state_light_structer_t *power_state_light_structer
// Heating state light // Heating state light
void T_heating_plate_state_light_init(heating_plate_state_light_structer_t *heating_plate_state_light_structer); void T_heating_plate_state_light_init(heating_plate_state_light_structer_t *heating_plate_state_light_structer);
void T_heating_plate_light_change_state(heating_plate_state_t change_state);
void T_heating_plate_light_set_rgb_by_state(heating_plate_state_t state);
// Reaction state light // Reaction state light
void T_reaction_state_light_init(reaction_state_light_structer_t *reaction_state_light_structer); void T_reaction_state_light_init(reaction_state_light_structer_t *reaction_state_light_structer);
void T_reaction_light_change_state(reaction_state_t change_state);
void T_reaction_light_set_rgb_by_state(reaction_state_t state);
// WIFI state light // WIFI state light
void T_wifi_state_light_init(wifi_state_light_structer_t *wifi_state_light_structer); void T_wifi_state_light_init(wifi_state_light_structer_t *wifi_state_light_structer);
void T_wifi_light_change_state(wifi_state_t change_state);
void T_wifi_light_set_rgb_by_state(wifi_state_t state);
// Schedule // Schedule
void T_debug_light_schedule(void); void T_debug_light_schedule(void);
void T_light_flash_schedule(void);
void T_light_schedule(void);
Loading…
Cancel
Save