123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #include "at32f403a_407.h"
- #include "io_utils.h"
- #include "FreeRTOS.h"
- #include "task.h"
- #include "settings_api.h"
- #include "mux.h"
- #include "analog_output.h"
- #include <stdio.h>
- bool save_mode = false;
- static uint16_t counter = 0;
- //
- void save_mode_init(void)
- {
- save_mode = settings.save_mode;
- save_mode ? mux_led_status(false) : mux_led_status(true);
- }
- //
- void save_mode_set(bool state)
- {
- save_mode = state;
- save_mode ? mux_led_status(false) : mux_led_status(true);
- }
- //
- bool save_mode_get(void)
- {
- return save_mode;
- }
- // Должна вызываться раз в секунду
- void save_mode_inc_cnt(void)
- {
- if (settings.save_mode)
- return;
- bool foo = counter++ > settings.save_delay ? true : false;
- save_mode_set(foo);
- }
- // Должна вызываться раз в секунду
- void save_mode_set_with_counter(void)
- {
- if (!settings.save_mode)
- return;
-
- if (counter++ > settings.save_delay) {
- if (!save_mode_get()) {
- save_mode_set(true);
- #if (MAO_4)
- ao_save_update(true);
- #endif
- }
- }
- }
- //
- void save_mode_reset_cnt(void)
- {
- counter = 0;
- save_mode_set(false);
- #if (MAO_4)
- ao_save_update(false);
- #endif
- }
|