display_line(5, 0, line);
snprintf(line, DISP_LLEN, "Mode: %c", heat_mode);
display_line(6, 0, line);
+ snprintf(line, DISP_LLEN, "v0.8 - 0.3.2", heat_mode);
+ display_line(7, 0, line);
/* Update Oled display */
ssd130x_display_full_screen(&display);
#include "uSD.h"
-#define MODULE_VERSION 0x05
+#define MODULE_VERSION 0x08
#define MODULE_NAME "Scialys uC"
/* Period (in ms) of the decrementer handler from the systick interrupt */
#define DEC_PERIOD 100
/* Period (in ms) of the handler for the command value update */
-#define CMD_UPD_PERIOD 200
+#define CMD_UPD_PERIOD 100
/* NOTE : All temperatures are stored as decidegrees */
/* Max water temperature. Internal protection which cannot be overriden by configuration */
uint32_t forced_heater_mode = 0;
uint32_t forced_heater_delay = 0;
uint32_t forced_heater_time = 0;
+uint8_t manual_forced_heater = 0;
uint8_t error_shutdown = 0;
static uint16_t snapval_solar = 0;
static uint16_t snapval_home = 0;
-#define NB_VAL 20
+#define NB_VAL 5
static void track_isnail_values(void)
{
static uint16_t isnail_solar_values[NB_VAL];
}
/* Handle the power command */
-#define CMD_UP_DELAY_RESET_VALUE 5
+#define CMD_UP_DELAY_RESET_VALUE 3
void handle_cmd_update(uint32_t curent_tick)
{
static uint8_t cmd = 0;
/* Forced heating mode */
if ((forced_heater_delay == 0) && (forced_heater_time > 0)) {
cmd = FORCED_MODE_VALUE;
+ goto cmd_update_end;
+ }
+ if (manual_forced_heater > 0) {
+ cmd = FORCED_MODE_VALUE;
+ goto cmd_update_end;
}
/* Entering forced heating mode from temperature getting below threshold,
* wait some delay before effective forced heating */
forced_heater_delay = FORCED_HEATER_DELAY;
forced_heater_time = FORCED_HEATER_DELAY + FORCED_HEATER_DURATION;
}
- } else if (moyenne_solar < (moyenne_home - 64)) {
+ }
+ if (moyenne_solar < (moyenne_home - 64)) {
/* Low production mode */
if (cmd > 0) {
cmd--;
}
cmd_update_end:
+ if ((cmd > 0) || (force_fan == 1)) {
+ fan_on = 1;
+ gpio_set(fan_ctrl);
+ } else {
+ fan_on = 0;
+ gpio_clear(fan_ctrl);
+ }
command_val = cmd;
/* Set Control Output duty cycle */
set_ctrl_duty_cycle(100 - cmd);
(deci_degrees_disp < ((MAX_INTERNAL_TEMP) / 2))) {
error_shutdown = 0;
}
- /* If internal temperature is above 32°C, then turn on fan. Turn off when back to under 28°C */
- if ((deci_degrees_power > FAN_ON_INTERNAL_TEMP_POWER) || (deci_degrees_disp > FAN_ON_INTERNAL_TEMP) ||
- (force_fan != 0)) {
- fan_on = 1;
- gpio_set(fan_ctrl);
- } else if ((deci_degrees_power < FAN_OFF_INTERNAL_TEMP_POWER) && (deci_degrees_disp < FAN_OFF_INTERNAL_TEMP)) {
- fan_on = 0;
- gpio_clear(fan_ctrl);
- }
/* Get thermocouple value */
if (1) {
if (manual_activation_request == -1) {
uprintf(UART0, "Entering manual forced mode for %d ticks\n", manual_activation_request);
manual_activation_request = MANUAL_ACTIVATION_DURATION;
- forced_heater_time = FORCED_HEATER_DURATION;
+ manual_forced_heater = 1;
}
if (manual_activation_request < 10) {
uprintf(UART0, "Leaving manual forced mode\n");