enum menu_list {
MAIN_MENU,
- FORCE_MODE,
- DATE_CONFIG,
+ AUTO_FORCE,
+ MANUAL_FORCE,
LIMITS,
- RESET_CONFIG,
- SAVE_CONFIG,
- TEST_MODE,
+ DATE_CONFIG,
+ SAVE_RAZ,
NB_MENU, /* This one must be the last */
};
static const char* menu_titles[] = {
- [MAIN_MENU] = "Menu principal",
- [FORCE_MODE] = "Marche Forcee",
- [DATE_CONFIG] = "Regl. Heure",
+ [MAIN_MENU] = "Configuration",
+ [AUTO_FORCE] = "MF auto.",
+ [MANUAL_FORCE] = "MF manuelle",
[LIMITS] = "Regl. Limites",
- [SAVE_CONFIG] = "Save config",
- [RESET_CONFIG] = "Reset config",
- [TEST_MODE] = "Test mode",
+ [DATE_CONFIG] = "Regl. Heure",
+ [SAVE_RAZ] = "Enreg. / RaZ",
};
static uint8_t current_menu = MAIN_MENU;
-static uint8_t current_entry = FORCE_MODE;
+static uint8_t current_entry = AUTO_FORCE;
+
+/* Auto Force */
+enum auto_force_list {
+ AUTO_FORCE_START_TEMP,
+ AUTO_FORCE_TARGET_TEMP,
+ AUTO_FORCE_DELAY,
+ AUTO_FORCE_DURATION,
+ AUTO_FORCE_VALUE,
+ AUTO_FORCE_TYPE,
+ AUTO_FORCE_NB_MENU, /* This one must be the last */
+};
+static const char* auto_force_titles[] = {
+ [AUTO_FORCE_START_TEMP] = "Temp. Min",
+ [AUTO_FORCE_TARGET_TEMP] = "Temp. Cible",
+ [AUTO_FORCE_DELAY] = "Delais",
+ [AUTO_FORCE_DURATION] = "Duree",
+ [AUTO_FORCE_VALUE] = "Valeur Cmd",
+ [AUTO_FORCE_TYPE] = "Type Cible",
+};
+static uint8_t auto_force_cur_menu = AUTO_FORCE_START_TEMP;
+static uint8_t auto_force_cur_entry = AUTO_FORCE_START_TEMP;
-enum force_mode_list {
- MANUAL_FORCE_MODE,
- AUTO_FORCE_MODE,
- FORCE_NB_MENU, /* This one must be the last */
+
+/* Manual Force */
+enum manual_force_list {
+ MANUAL_FORCE_TARGET_TEMP,
+ MANUAL_FORCE_DURATION,
+ MANUAL_FORCE_VALUE,
+ MANUAL_FORCE_TYPE,
+ MANUAL_FORCE_NB_MENU, /* This one must be the last */
};
-static const char* force_modes_titles[] = {
- [MANUAL_FORCE_MODE] = "Manuelle",
- [AUTO_FORCE_MODE] = "Automatique",
+static const char* manual_force_titles[] = {
+ [MANUAL_FORCE_TARGET_TEMP] = "Temp. Cible",
+ [MANUAL_FORCE_DURATION] = "Duree",
+ [MANUAL_FORCE_VALUE] = "Valeur Cmd",
+ [MANUAL_FORCE_TYPE] = "Type Cible",
};
-static uint8_t force_cur_menu = MANUAL_FORCE_MODE;
-static uint8_t force_cur_entry = MANUAL_FORCE_MODE;
+static uint8_t manual_force_cur_menu = MANUAL_FORCE_TARGET_TEMP;
+static uint8_t manual_force_cur_entry = MANUAL_FORCE_TARGET_TEMP;
+/* Limits */
enum limits_menu_list {
TEMP_MAX,
PMAX_GRID,
PMAX_PROD,
+ POK_PROD,
PMAX_CONSO,
LOAD_TYPE,
- FORCED_MODE_VAL,
LIM_NB_MENU, /* This one must be the last */
};
static const char* limits_modes_titles[] = {
- [TEMP_MAX] = "Temp Max",
- [PMAX_GRID] = "Pmax Abon.",
- [PMAX_PROD] = "Pmax Prod.",
+ [TEMP_MAX] = "Temp. Max",
+ [PMAX_GRID] = "P Max Abon.",
+ [PMAX_PROD] = "P Max Prod.",
+ [POK_PROD] = "P OK Prod.",
[PMAX_CONSO] = "P Charge",
[LOAD_TYPE] = "Type Charge",
- [FORCED_MODE_VAL] = "Force Val",
};
static uint8_t limits_cur_menu = TEMP_MAX;
static uint8_t limits_cur_entry = TEMP_MAX;
-enum test_menu_list {
+enum conf_menu_list {
+ SAVE_CONFIG,
+ RESET_CONFIG,
TEST_FAN,
TEST_12V,
TEST_CMDV,
- TEST_NB_MENU, /* This one must be the last */
+ CONF_NB_MENU, /* This one must be the last */
};
-static const char* test_modes_titles[] = {
- [TEST_FAN] = "Fan",
- [TEST_12V] = "DC 12V",
- [TEST_CMDV] = "CMD Val",
+static const char* conf_titles[] = {
+ [SAVE_CONFIG] = "Enregistrer",
+ [RESET_CONFIG] = "RaZ config",
+ [TEST_FAN] = "T. Fan",
+ [TEST_12V] = "T. DC12V",
+ [TEST_CMDV] = "T. Cmd",
};
+static uint8_t conf_cur_menu = SAVE_CONFIG;
+static uint8_t conf_cur_entry = SAVE_CONFIG;
+
extern uint8_t force_fan;
extern int8_t force_cmd;
extern uint32_t zc_cnt;
extern void DC_switch_start();
-static uint8_t test_cur_entry = TEST_FAN;
+
+static const char* force_types_str[] = {
+ [FORCE_TYPE_OFF] = "Off",
+ [FORCE_TYPE_MIN] = "Min",
+ [FORCE_TYPE_MAX] = "Max",
+ [FORCE_TYPE_TIMER] = "Timer",
+ [FORCE_TYPE_TARGET] = "Cible",
+};
+
+static const char* load_types_str[] = {
+ [LOAD_TYPE_AC_RES] = "AC Res",
+ [LOAD_TYPE_AC_IND] = "AC Ind",
+ [LOAD_TYPE_DC] = "DC",
+};
/* Current sub-menu level. main menu is level 0 */
int sub_menu_level = 0;
+#define BUTTONS_ACTS_DEFAULT() \
+ if (button & BUTTON_LEFT) { sub_menu_level = 1; } \
+ if (button & BUTTON_OK) { sub_menu_level = 0; current_menu = MAIN_MENU; }
/* Configuraton menu handler
* Return 0 to get back to
*/
int config_interface_handle(void)
{
- char line[DISP_LLEN];
int interface_mode = MODE_CONFIG;
uint8_t button = 0;
switch (current_menu) {
case MAIN_MENU: {
int i = 0;
+ /* Display main menu */
for (i = 1; i < NB_MENU; i++) {
if (i != current_entry) {
display_line(i + 1, 2, menu_titles[i]);
} else {
- snprintf(line, DISP_LLEN, " >%s", menu_titles[i]);
- display_line(i + 1, 0, line);
+ dprintf(i + 1, 0, " >%s", menu_titles[i]);
}
}
+ /* Button up/down : select next/previous entry */
if (button & BUTTON_UP) {
current_entry -= 1;
}
} else if (current_entry == 0) {
current_entry = NB_MENU - 1;
}
+ /* Enter sub-menu */
if (button & BUTTON_RIGHT) {
current_menu = current_entry;
sub_menu_level = 1;
}
+ /* Exit menu */
if (button & (BUTTON_LEFT | BUTTON_OK)) {
interface_mode = MODE_RUN;
}
}
break;
case DATE_CONFIG: {
- static uint8_t date_idx = 0;
- snprintf(line, DISP_LLEN, "%c", 0x60);
- display_line(3, 6 + (date_idx * 3), line);
- rtc_pcf85363_time_read(&rtc_conf, &now);
- snprintf(line, DISP_LLEN, "%02xh%02x:%02x", now.hour, now.min, now.sec);
- display_line(4, 6, line);
- snprintf(line, DISP_LLEN, "%c", 0x7F);
- display_line(5, 6 + (date_idx * 3), line);
- if ((button & BUTTON_RIGHT) && (date_idx < 2)) {
+ static uint8_t date_idx = 0; /* Where to put the arrows */
+ uint8_t line_num = 0;
+ /* Read current date and time */
+ rtc_pcf85363_time_read_dec(&rtc_conf, &now);
+ /* Display date and time */
+ dprintf(3, 4, "20%02u-%02u-%02u", now.year, now.month, now.day);
+ dprintf(5, 6, "%02uh%02u:%02u", now.hour, now.min, now.sec);
+ /* Display arrows on top/bottom of current field */
+ line_num = 2 + ((date_idx > 2) ? 2 : 0);
+ display_arrows(line_num, (line_num + 2), (7 + ((date_idx % 3) * 3)));
+ /* Update current field ? */
+ if ((button & BUTTON_RIGHT) && (date_idx < 5)) {
date_idx++;
}
if ((button & BUTTON_LEFT) && (date_idx > 0)) {
date_idx--;
}
if (button & (BUTTON_UP | BUTTON_DOWN)) {
- uint32_t seconds = rtc_pcf85363_daytime_to_seconds(&now);
- uint32_t add[6] = {
- 3600, 60, 1,
- (23 * 3600), (23* 3600 + 59 * 60), (23 * 3600 + 59 * 60 + 59),
- };
- if (button & BUTTON_UP) {
- if (seconds < add[date_idx + 3]) {
- seconds += add[date_idx];
- } else {
- seconds -= add[date_idx + 3];
- }
- } else {
- if (seconds < add[date_idx]) {
- seconds += add[date_idx + 3];
- } else {
- seconds -= add[date_idx];
- }
+ int8_t add = 1;
+ if (button & BUTTON_DOWN) {
+ add = -1;
+ }
+ switch (date_idx) {
+ case 0:
+ now.year += add;
+ if (now.year > 99) { now.year = 0; }
+ break;
+ case 1:
+ now.month += add;
+ if (now.month > 12) { now.month = 1; }
+ if (now.month == 0) { now.month = 12; }
+ break;
+ case 2:
+ now.day += add;
+ if (now.day > 31) { now.day = 1; }
+ if (now.day == 0) { now.day = 31; }
+ break;
+ case 3:
+ now.hour += add;
+ if (now.hour > 100) { now.hour = 23; }
+ if (now.hour > 23) { now.hour = 0; }
+ break;
+ case 4:
+ now.min += add;
+ if (now.min > 100) { now.min = 59; }
+ if (now.min > 59) { now.min = 0; }
+ break;
+ case 5:
+ now.sec += add;
+ if (now.sec > 59) { now.sec = 0; }
+ break;
}
- rtc_pcf85363_seconds_to_daytime(&now, seconds);
- rtc_pcf85363_time_write(&rtc_conf, &now);
+ rtc_pcf85363_time_write_dec(&rtc_conf, &now);
}
if (button & BUTTON_OK) {
sub_menu_level = 0;
if (i != limits_cur_entry) {
display_line(i + 2, 3, limits_modes_titles[i]);
} else {
- snprintf(line, DISP_LLEN, " >%s", limits_modes_titles[i]);
- display_line(i + 2, 0, line);
+ dprintf(i + 2, 0, " >%s", limits_modes_titles[i]);
}
}
if (button & BUTTON_UP) {
if (button & BUTTON_DOWN) {
limits_cur_entry += 1;
}
- if (limits_cur_entry >= LIM_NB_MENU) {
- limits_cur_entry = 0;
- } else if (limits_cur_entry == 0xFF) {
+ if (limits_cur_entry == 0xFF) {
limits_cur_entry = LIM_NB_MENU - 1;
+ } else if (limits_cur_entry >= LIM_NB_MENU) {
+ limits_cur_entry = 0;
}
if (button & (BUTTON_OK | BUTTON_RIGHT)) {
limits_cur_menu = limits_cur_entry;
display_line(1, 1, limits_modes_titles[limits_cur_menu]);
switch (limits_cur_menu) {
case TEMP_MAX:
- snprintf(line, DISP_LLEN, " %c", 0x60);
- display_line(3, 1, line);
- snprintf(line, DISP_LLEN, "Abs. max: %d %cC", sc_conf.conf_max_temp / 100, 0x24);
- display_line(4, 1, line);
- snprintf(line, DISP_LLEN, " %c", 0x7f);
- display_line(5, 1, line);
+ display_arrows(4, 6, 12);
+ dprintf(5, 1, "Abs. max: %2u %cC", (sc_conf.conf_max_temp / 100), 0x24);
if (button & BUTTON_UP) {
- if (sc_conf.conf_max_temp <= 8500) {
- sc_conf.conf_max_temp += 500;
+ if (sc_conf.conf_max_temp <= 8900) {
+ sc_conf.conf_max_temp += 100;
} else {
sc_conf.conf_max_temp = 9000;
}
}
if (button & BUTTON_DOWN) {
- if (sc_conf.conf_max_temp > 500) {
- sc_conf.conf_max_temp -= 500;
+ if (sc_conf.conf_max_temp > 2000) {
+ sc_conf.conf_max_temp -= 100;
} else {
- sc_conf.conf_max_temp = 0;
+ sc_conf.conf_max_temp = 2000;
}
}
- if (button & BUTTON_LEFT) {
- sub_menu_level = 1;
- }
- if (button & BUTTON_OK) {
- sub_menu_level = 0;
- current_menu = MAIN_MENU;
- }
- break;
- case FORCED_MODE_VAL:
+ BUTTONS_ACTS_DEFAULT();
break;
case PMAX_GRID:
- /* remember to update max_intensity */
+ display_arrows(4, 6, 11);
+ dprintf(5, 1, "P. abo.: %2u kW", sc_conf.grid_power_limit);
+ if (button & BUTTON_UP) {
+ sc_conf.grid_power_limit++;
+ if (sc_conf.grid_power_limit > 36) {
+ sc_conf.grid_power_limit = 0;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.grid_power_limit--;
+ if (sc_conf.grid_power_limit > 36) {
+ sc_conf.grid_power_limit = 36;
+ }
+ }
+ update_max_intensity();
+ BUTTONS_ACTS_DEFAULT();
break;
case PMAX_PROD:
- /* remember to update sunny_days_prod_value */
+ display_arrows(4, 6, 8);
+ dprintf(5, 1, "P. : %4u W", sc_conf.source_power_max);
+ if (button & BUTTON_UP) {
+ sc_conf.source_power_max += 50;
+ if (sc_conf.source_power_max > 36000) {
+ sc_conf.source_power_max = 0;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.source_power_max -= 50;
+ if (sc_conf.source_power_max > 36000) {
+ sc_conf.source_power_max = 36000;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ case POK_PROD:
+ display_arrows(4, 6, 8);
+ dprintf(5, 1, "P. : %4u W", sc_conf.source_has_power_ok);
+ if (button & BUTTON_UP) {
+ sc_conf.source_has_power_ok += 50;
+ if (sc_conf.source_has_power_ok > 36000) {
+ sc_conf.source_has_power_ok = 0;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.source_has_power_ok -= 50;
+ if (sc_conf.source_has_power_ok > 36000) {
+ sc_conf.source_has_power_ok = 36000;
+ }
+ }
+ update_sunny_days_prod_value();
+ BUTTONS_ACTS_DEFAULT();
break;
case PMAX_CONSO:
+ display_arrows(4, 6, 8);
+ dprintf(5, 1, "P. : %4u W", sc_conf.load_power_max);
+ if (button & BUTTON_UP) {
+ sc_conf.load_power_max += 50;
+ if (sc_conf.load_power_max > 3000) {
+ sc_conf.load_power_max = 0;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.load_power_max -= 50;
+ if (sc_conf.load_power_max > 3000) {
+ sc_conf.load_power_max = 3000;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
break;
case LOAD_TYPE:
+ display_arrows(4, 6, 11);
+ dprintf(5, 1, "Type: %s", load_types_str[sc_conf.load_type]);
+ if (button & BUTTON_UP) {
+ sc_conf.load_type++;
+ if (sc_conf.load_type >= NB_LOAD_TYPES) {
+ sc_conf.load_type = 0;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.load_type--;
+ if (sc_conf.load_type >= NB_LOAD_TYPES) {
+ sc_conf.load_type = (NB_LOAD_TYPES - 1);
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
break;
}
}
}
break;
- case FORCE_MODE: {
+ case AUTO_FORCE: {
if (sub_menu_level == 1) {
int i = 0;
- for (i = 0; i < FORCE_NB_MENU; i++) {
- if (i != force_cur_entry) {
- display_line(i + 2, 3, force_modes_titles[i]);
+ for (i = 0; i < AUTO_FORCE_NB_MENU; i++) {
+ if (i != auto_force_cur_entry) {
+ display_line(i + 2, 3, auto_force_titles[i]);
} else {
- snprintf(line, DISP_LLEN, " ->%s", force_modes_titles[i]);
- display_line(i + 2, 0, line);
+ dprintf(i + 2, 0, " ->%s", auto_force_titles[i]);
}
}
if (button & BUTTON_UP) {
- force_cur_entry -= 1;
+ auto_force_cur_entry -= 1;
}
if (button & BUTTON_DOWN) {
- force_cur_entry += 1;
+ auto_force_cur_entry += 1;
}
- if (force_cur_entry >= FORCE_NB_MENU) {
- force_cur_entry = 0;
- } else if (force_cur_entry == 0xFF) {
- force_cur_entry = FORCE_NB_MENU - 1;
+ if (auto_force_cur_entry >= AUTO_FORCE_NB_MENU) {
+ auto_force_cur_entry = 0;
+ } else if (auto_force_cur_entry == 0xFF) {
+ auto_force_cur_entry = AUTO_FORCE_NB_MENU - 1;
}
if (button & (BUTTON_OK | BUTTON_RIGHT)) {
- force_cur_menu = force_cur_entry;
+ auto_force_cur_menu = auto_force_cur_entry;
sub_menu_level = 2;
}
if (button & BUTTON_LEFT) {
sub_menu_level = 0;
current_menu = MAIN_MENU;
}
- } else {
+ } else { /* sub_menu_level == 2 */
+ display_line(1, 1, auto_force_titles[auto_force_cur_menu]);
+ switch (auto_force_cur_menu) {
+ case AUTO_FORCE_START_TEMP:
+ display_arrows(4, 6, 11);
+ dprintf(5, 1, "T. min.: %2u %cC", (sc_conf.enter_forced_mode_temp / 100), 0x24);
+ if (button & BUTTON_UP) {
+ sc_conf.enter_forced_mode_temp += 100;
+ /* 60°C is already too high for this module to be of any use */
+ if (sc_conf.enter_forced_mode_temp >= 6000) {
+ sc_conf.enter_forced_mode_temp = 200;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.enter_forced_mode_temp -= 100;
+ /* 2°C : kind of frost protection */
+ if (sc_conf.enter_forced_mode_temp < 200) {
+ sc_conf.enter_forced_mode_temp = 6000;
+ }
+ }
+ /* Make sure the target temp is at least 5°C above enter temp. */
+ if (sc_conf.enter_forced_mode_temp > (sc_conf.auto_forced_target_heater_temp - 500)) {
+ sc_conf.auto_forced_target_heater_temp = sc_conf.enter_forced_mode_temp + 500;
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ case AUTO_FORCE_TARGET_TEMP:
+ display_arrows(4, 6, 12);
+ dprintf(5, 1, "T. cible: %2u %cC", (sc_conf.auto_forced_target_heater_temp / 100), 0x24);
+ if (button & BUTTON_UP) {
+ sc_conf.auto_forced_target_heater_temp += 100;
+ if (sc_conf.auto_forced_target_heater_temp >= 9000) {
+ sc_conf.auto_forced_target_heater_temp = sc_conf.enter_forced_mode_temp + 500;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.auto_forced_target_heater_temp -= 100;
+ /* Make sure the target temp is at least 5°C above enter temp. */
+ if (sc_conf.auto_forced_target_heater_temp < (sc_conf.enter_forced_mode_temp + 500)) {
+ sc_conf.auto_forced_target_heater_temp = 9000;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ case AUTO_FORCE_DELAY:
+ display_arrows(4, 6, 9);
+ dprintf(5, 1, "Delais: %d h", sc_conf.auto_forced_heater_delay);
+ if (button & BUTTON_UP) {
+ sc_conf.auto_forced_heater_delay++;
+ if (sc_conf.auto_forced_heater_delay >= 5) {
+ sc_conf.auto_forced_heater_delay = 0;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.auto_forced_heater_delay--;
+ if (sc_conf.auto_forced_heater_delay > 5) {
+ sc_conf.auto_forced_heater_delay = 5;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ case AUTO_FORCE_DURATION:
+ display_arrows(4, 6, 9);
+ dprintf(5, 1, "Duree : %d h", sc_conf.auto_forced_heater_duration);
+ if (button & BUTTON_UP) {
+ sc_conf.auto_forced_heater_duration++;
+ if (sc_conf.auto_forced_heater_duration > 5) {
+ sc_conf.auto_forced_heater_duration = 1;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.auto_forced_heater_duration--;
+ if (sc_conf.auto_forced_heater_duration < 1 ) {
+ sc_conf.auto_forced_heater_duration = 5;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ case AUTO_FORCE_VALUE:
+ display_arrows(4, 6, 10);
+ dprintf(5, 1, "Cmd. : %3u %", sc_conf.auto_forced_mode_value);
+ if (button & BUTTON_UP) {
+ sc_conf.auto_forced_mode_value += 5;
+ if (sc_conf.auto_forced_mode_value > 100) {
+ sc_conf.auto_forced_mode_value = 25;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.auto_forced_mode_value -= 5;
+ if (sc_conf.auto_forced_mode_value < 25 ) {
+ sc_conf.auto_forced_mode_value = 100;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ case AUTO_FORCE_TYPE:
+ display_arrows(4, 6, 10);
+ dprintf(5, 1, "Type : %s", force_types_str[sc_conf.auto_force_type]);
+ if (button & BUTTON_UP) {
+ sc_conf.auto_force_type++;
+ if (sc_conf.auto_force_type >= NB_FORCE_TYPE) {
+ sc_conf.auto_force_type = 0;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.auto_force_type--;
+ if (sc_conf.auto_force_type >= NB_FORCE_TYPE ) {
+ sc_conf.auto_force_type = NB_FORCE_TYPE - 1;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ }
}
}
break;
- case TEST_MODE: {
- int i = 0;
- uint8_t states[3];
+ case MANUAL_FORCE: {
+ if (sub_menu_level == 1) {
+ int i = 0;
+ for (i = 0; i < MANUAL_FORCE_NB_MENU; i++) {
+ if (i != manual_force_cur_entry) {
+ display_line(i + 2, 3, manual_force_titles[i]);
+ } else {
+ dprintf(i + 2, 0, " ->%s", manual_force_titles[i]);
+ }
+ }
+ if (button & BUTTON_UP) {
+ manual_force_cur_entry -= 1;
+ }
+ if (button & BUTTON_DOWN) {
+ manual_force_cur_entry += 1;
+ }
+ if (manual_force_cur_entry >= MANUAL_FORCE_NB_MENU) {
+ manual_force_cur_entry = 0;
+ } else if (manual_force_cur_entry == 0xFF) {
+ manual_force_cur_entry = MANUAL_FORCE_NB_MENU - 1;
+ }
+ if (button & (BUTTON_OK | BUTTON_RIGHT)) {
+ manual_force_cur_menu = manual_force_cur_entry;
+ sub_menu_level = 2;
+ }
+ if (button & BUTTON_LEFT) {
+ sub_menu_level = 0;
+ current_menu = MAIN_MENU;
+ }
+ } else { /* sub_menu_level == 2 */
+ display_line(1, 1, manual_force_titles[manual_force_cur_menu]);
+ switch (manual_force_cur_menu) {
+ case MANUAL_FORCE_TARGET_TEMP:
+ display_arrows(4, 6, 12);
+ dprintf(5, 1, "T. cible: %2u %cC", (sc_conf.manual_target_heater_temp / 100), 0x24);
+ if (button & BUTTON_UP) {
+ sc_conf.manual_target_heater_temp += 100;
+ if (sc_conf.manual_target_heater_temp >= 9000) {
+ sc_conf.manual_target_heater_temp = 1000;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.manual_target_heater_temp -= 100;
+ if (sc_conf.manual_target_heater_temp < 1000) {
+ sc_conf.manual_target_heater_temp = 9000;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ case MANUAL_FORCE_DURATION:
+ display_arrows(4, 6, 9);
+ dprintf(5, 1, "Duree : %d h", sc_conf.manual_activation_duration);
+ if (button & BUTTON_UP) {
+ sc_conf.manual_activation_duration++;
+ if (sc_conf.manual_activation_duration > 5) {
+ sc_conf.manual_activation_duration = 1;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.manual_activation_duration--;
+ if (sc_conf.manual_activation_duration < 1 ) {
+ sc_conf.manual_activation_duration = 5;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ case MANUAL_FORCE_VALUE:
+ display_arrows(4, 6, 10);
+ dprintf(5, 1, "Cmd. : %3u %", sc_conf.manual_forced_mode_value);
+ if (button & BUTTON_UP) {
+ sc_conf.manual_forced_mode_value += 5;
+ if (sc_conf.manual_forced_mode_value > 100) {
+ sc_conf.manual_forced_mode_value = 25;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.manual_forced_mode_value -= 5;
+ if (sc_conf.manual_forced_mode_value < 25 ) {
+ sc_conf.manual_forced_mode_value = 100;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ case MANUAL_FORCE_TYPE:
+ display_arrows(4, 6, 10);
+ dprintf(5, 1, "Type : %s", force_types_str[sc_conf.manual_force_type]);
+ if (button & BUTTON_UP) {
+ sc_conf.manual_force_type++;
+ if (sc_conf.manual_force_type >= NB_FORCE_TYPE) {
+ sc_conf.manual_force_type = 0;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ sc_conf.manual_force_type--;
+ if (sc_conf.manual_force_type >= NB_FORCE_TYPE ) {
+ sc_conf.manual_force_type = NB_FORCE_TYPE - 1;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ }
+ }
+ }
+ break;
+ case SAVE_RAZ: {
+ if (sub_menu_level == 1) {
+ int i = 0;
+ uint8_t states[3];
- states[TEST_FAN] = force_fan;
- states[TEST_12V] = (zc_cnt != 0) ? 1 : 0;
- states[TEST_CMDV] = (force_cmd != -1) ? 1 : 0;
+ states[0] = force_fan; /* TEST_FAN */
+ states[1] = (zc_cnt != 0) ? 1 : 0; /* TEST_12V */
+ states[2] = (force_cmd != -1) ? force_cmd : 0; /* TEST_CMDV */
- for (i = 0; i < TEST_NB_MENU; i++) {
- if (i != test_cur_entry) {
- display_line(i + 2, 3, test_modes_titles[i]);
- } else {
- snprintf(line, DISP_LLEN, " ->%s : %d", test_modes_titles[i], states[i]);
- display_line(i + 2, 0, line);
+ for (i = 0; i < CONF_NB_MENU; i++) {
+ if (i != conf_cur_entry) {
+ display_line(i + 2, 3, conf_titles[i]);
+ } else if (i >= TEST_FAN) {
+ dprintf(i + 2, 0, " ->%s : %d", conf_titles[i], states[i - TEST_FAN]);
+ } else {
+ dprintf(i + 2, 0, " ->%s", conf_titles[i]);
+ }
}
- }
- if (button & BUTTON_UP) {
- test_cur_entry -= 1;
- }
- if (button & BUTTON_DOWN) {
- test_cur_entry += 1;
- }
- if (test_cur_entry >= TEST_NB_MENU) {
- test_cur_entry = 0;
- } else if (test_cur_entry == 0xFF) {
- test_cur_entry = TEST_NB_MENU - 1;
- }
- if (button & (BUTTON_LEFT | BUTTON_RIGHT)) {
- switch (test_cur_entry) {
+ if (button & BUTTON_UP) {
+ conf_cur_entry -= 1;
+ }
+ if (button & BUTTON_DOWN) {
+ conf_cur_entry += 1;
+ }
+ if (conf_cur_entry >= CONF_NB_MENU) {
+ conf_cur_entry = 0;
+ } else if (conf_cur_entry == 0xFF) {
+ conf_cur_entry = CONF_NB_MENU - 1;
+ }
+ if (button & (BUTTON_OK | BUTTON_RIGHT)) {
+ conf_cur_menu = conf_cur_entry;
+ sub_menu_level = 2;
+ }
+ if (button & BUTTON_LEFT) {
+ sub_menu_level = 0;
+ current_menu = MAIN_MENU;
+ }
+ } else { /* sub_menu_level == 2 */
+ display_line(1, 1, conf_titles[conf_cur_menu]);
+ switch (conf_cur_menu) {
case TEST_FAN:
force_fan = !force_fan;
+ dprintf(4, 1, "Fan turned %s", ((force_fan == 0) ? "OFF" : "ON"));
+ sub_menu_level = 1;
break;
case TEST_12V:
/* Generate a fake zero-cross detect by calling the handler directly */
DC_switch_start();
+ display_line(4, 1, "DC Test ON");
+ display_line(5, 2, "(Reset for OFF)");
+ sub_menu_level = 1;
break;
case TEST_CMDV:
- if (force_cmd >= 0) {
- force_cmd = -1;
- } else {
- force_cmd = 50;
+ display_arrows(4, 6, 10);
+ dprintf(5, 1, "Cmd. : %3u %", ((force_cmd >= 0) ? force_cmd : 0));
+ if (button & BUTTON_UP) {
+ if (force_cmd < 0) {
+ force_cmd = 0;
+ }
+ force_cmd += 5;
+ if (force_cmd > 100) {
+ force_cmd = 100;
+ }
+ }
+ if (button & BUTTON_DOWN) {
+ force_cmd -= 5;
+ if (force_cmd < 0 ) {
+ force_cmd = -1;
+ }
+ }
+ BUTTONS_ACTS_DEFAULT();
+ break;
+ case SAVE_CONFIG: {
+ display_line(2, 1, "Sauver config ?");
+ display_line(5, 1, "Valider = OK");
+ display_line(6, 1, "Gauche = Annul");
+ if (button & BUTTON_LEFT) {
+ sub_menu_level = 0;
+ current_menu = MAIN_MENU;
+ }
+ if (button & BUTTON_OK) {
+ int ret = 0;
+ erase_screen_content();
+ display_line(4, 2, "Saving ...");
+ ret = scialys_user_flash_update();
+ uprintf(UART0, "\nFlash update from menu: %d\n", ret);
+ msleep(1500);
+ sub_menu_level = 0;
+ current_menu = MAIN_MENU;
+ }
+ }
+ break;
+ case RESET_CONFIG: {
+ display_line(2, 1, "Efface Config ?");
+ display_line(5, 1, "Valider = OK");
+ display_line(6, 1, "Gauche = Annul");
+ if (button & BUTTON_LEFT) {
+ sub_menu_level = 0;
+ current_menu = MAIN_MENU;
+ }
+ if (button & BUTTON_OK) {
+ erase_screen_content();
+ display_line(4, 8, "Chargement ...");
+ sc_conf.conf_version = 0x00;
+ scialys_check_config();
+ uprintf(UART0, "\nSystem defaults reloaded from menu\n");
+ msleep(500);
+ sub_menu_level = 0;
+ current_menu = MAIN_MENU;
+ }
}
- default:
break;
}
}
- if (button & BUTTON_OK) {
- sub_menu_level = 0;
- current_menu = MAIN_MENU;
- }
- }
- break;
- case SAVE_CONFIG: {
- snprintf(line, DISP_LLEN, "Sauver config ?");
- display_line(2, 1, line);
- snprintf(line, DISP_LLEN, "Valider = OK");
- display_line(5, 1, line);
- snprintf(line, DISP_LLEN, "Gauche = Annul");
- display_line(6, 1, line);
- if (button & BUTTON_LEFT) {
- sub_menu_level = 0;
- current_menu = MAIN_MENU;
- }
- if (button & BUTTON_OK) {
- int ret = 0;
- erase_screen_content();
- snprintf(line, DISP_LLEN, "Saving ...");
- display_line(4, 2, line);
- ret = scialys_user_flash_update();
- uprintf(UART0, "\nFlash update from menu: %d\n", ret);
- msleep(1500);
- sub_menu_level = 0;
- current_menu = MAIN_MENU;
- }
- }
- break;
- case RESET_CONFIG: {
- snprintf(line, DISP_LLEN, "Efface Config ?");
- display_line(2, 1, line);
- snprintf(line, DISP_LLEN, "Valider = OK");
- display_line(5, 1, line);
- snprintf(line, DISP_LLEN, "Gauche = Annul");
- display_line(6, 1, line);
- if (button & BUTTON_LEFT) {
- sub_menu_level = 0;
- current_menu = MAIN_MENU;
- }
- if (button & BUTTON_OK) {
- erase_screen_content();
- snprintf(line, DISP_LLEN, "Chargement ...");
- display_line(4, 8, line);
- sc_conf.conf_version = 0x00;
- scialys_check_config();
- uprintf(UART0, "\nSystem defaults reloaded from menu\n");
- msleep(500);
- sub_menu_level = 0;
- current_menu = MAIN_MENU;
- }
}
break;
default: