Files
@ c1b2840961f0
Branch filter:
Location: therm-ng/inc/states.h
c1b2840961f0
1.8 KiB
text/plain
Hacking thermostatic mode into operation. This code needs some love.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #ifndef STATES_H
#define STATES_H
#include "stm32f3xx_hal.h"
#include "config.h"
typedef struct {
float temp;
uint8_t state_resume;
uint8_t state;
float setpoint;
uint8_t pid_enabled;
uint8_t error_code;
uint8_t setpoint_index;
} therm_status_t;
typedef union
{
struct {
uint32_t boottobrew;
uint32_t temp_units;
uint32_t windup_guard;
uint32_t k_p;
uint32_t k_i;
uint32_t k_d;
float temp_offset;
uint32_t ignore_error;
float setpoints[MAX_SETPOINTS];
uint32_t control_mode;
uint32_t sensor_type;
uint32_t plant_type;
uint32_t hysteresis;
uint32_t setpoint_count;
uint32_t setpoint_aux_select_enable;
} val;
uint16_t data[128];
} therm_settings_t;
enum tempunits {
TEMP_UNITS_CELSIUS = 0,
TEMP_UNITS_FAHRENHEIT,
};
enum state {
STATE_IDLE = 0,
STATE_SETSENSORTYPE,
STATE_SETMODE,
STATE_SETPLANTTYPE,
STATE_SETSETPOINTCOUNT,
STATE_SETSETPOINTAUXSELECTENABLE,
STATE_SETHYSTERESIS,
STATE_SETP,
STATE_SETI,
STATE_SETD,
STATE_SETSTEPS,
STATE_SETWINDUP,
STATE_SETBOOTTOBREW,
STATE_SETUNITS,
STATE_SETTEMPOFFSET,
STATE_PREHEAT,
STATE_MAINTAIN,
STATE_TC_ERROR,
STATE_RESET,
};
enum control_mode {
MODE_PID = 0,
MODE_THERMOSTAT,
};
enum plant_type {
PLANT_HEATER = 0,
PLANT_COOLER,
};
enum aux_select {
AUX_DISABLE = 0,
AUX_ENABLE,
};
enum GOTO_MODE {
#ifdef BOOTLOADER_SHORTCUT
MODE_BOOTLOADER,
#endif
MODE_HEAT,
MODE_SETUP,
MODE_RESET,
MODE_SIZE,
};
enum RESET_MODE {
RESET_REBOOT = 0,
RESET_DEFAULTS,
RESET_BOOTLOADER,
RESET_EXIT,
RESET_SIZE,
};
enum SENSOR_TYPE {
SENSOR_NTC = 0,
SENSOR_TC_K,
SENSOR_TC_E,
SENSOR_TC_N,
SENSOR_TC_R,
SENSOR_TC_S,
SENSOR_TC_T,
};
#endif
|