From 4ef00556e7cde38b3d321e1c80b2ff3f9ff3af2e Mon Sep 17 00:00:00 2001 From: Nidan Date: Mon, 11 Mar 2013 19:53:17 +0100 Subject: [PATCH] most software todos done --- TODO | 12 ++++++------ firmware/cup.c | 29 ++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index e96e5cf..b473ae7 100644 --- a/TODO +++ b/TODO @@ -1,11 +1,11 @@ -- entprellung des tasters - limiter nur bei brownout -- auto-aus nach 2 stunden -- rasten verändern (2.5°C) - gehäusefüße dran -- temperaturmaximum evtl reduzieren (80°C?) oderauchnicht -- beide temperaturmaxima gleich -- hochlganzpolieren +- hochglanzpolieren +done - entprellung des tasters +done - auto-aus nach 2 stunden +done - rasten verändern (2.5°C) +done - temperaturmaximum evtl reduzieren (80°C?) oderauchnicht +done - beide temperaturmaxima gleich "Langzeittests" - maximale temperatur diff --git a/firmware/cup.c b/firmware/cup.c index 1858121..6b99ac8 100644 --- a/firmware/cup.c +++ b/firmware/cup.c @@ -13,8 +13,9 @@ #define TIMEOUT 51 /* 2 seconds */ -const uint16_t LED_GREEN_TEMP = 300; -const uint16_t LED_RED_TEMP = 1000; +#define LED_GREEN_TEMP 300 +//#define LED_RED_TEMP 1000 +#define LED_RED_TEMP 800 #define TARGET_TEMP_MIN 300 #define TARGET_TEMP_MAX 1520 @@ -36,13 +37,20 @@ uint8_t heat_power = 0; // requested heating power; 0..255 uint8_t input_state = 0; uint8_t dev_state = 0; // whether the device is on or off +#define TOGGLE_TIMEOUT 5 #define TEN_SECONDS 256 +#define ONE_MINUTE 1536 +#define ONE_HOUR 92160 + +uint8_t toggle_timeout = 0; + uint16_t startup = TEN_SECONDS; uint8_t eeprom_write = 0; -#define ONE_MINUTE 1536 uint16_t eeprom_clk = ONE_MINUTE; +uint32_t shutdown = 2 * (uint32_t) ONE_HOUR; + /* gray code to change lookup table, index is old state .. new state */ int8_t state_change[16] = {0, 1, -1, 0, -1, 0, 0, 1, 1, 0, 0, -1, 0, -1, 1, 0}; //int8_t state_change[16] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0}; @@ -51,6 +59,7 @@ int8_t state_change[16] = {0, 1, -1, 0, -1, 0, 0, 1, 1, 0, 0, -1, 0, -1, 1, 0 ISR(TIM1_OVF_vect) { /* timeout for displaying target temperature */ + if(toggle_timeout) {toggle_timeout--;} if(setting_timeout) {setting_timeout--;} if(startup) {startup--;} if(eeprom_clk) {eeprom_clk--;} @@ -59,6 +68,8 @@ ISR(TIM1_OVF_vect) eeprom_write = 1; eeprom_clk = ONE_MINUTE; } + if(shutdown) {shutdown--;} + else {dev_state = 0;} /* incremtening softpwm, toggling output if needed */ heat_pwm++; @@ -92,20 +103,24 @@ ISR(PCINT0_vect) uint8_t diff = new_state ^ input_state; if(!diff) {return;} - if(diff & (1 << (TAST_PIN - 1)) && new_state & (1 << (TAST_PIN - 1))) + if(!toggle_timeout && diff & (1 << (TAST_PIN - 1)) && new_state & (1 << (TAST_PIN - 1))) { dev_state = !dev_state; + toggle_timeout = TOGGLE_TIMEOUT; } int8_t change = state_change[((input_state & 3) << 2) | (new_state & 3)]; if(change) { - target += change * 10; // 1 celsius per step - if(target < TARGET_TEMP_MIN) {target = TARGET_TEMP_MIN;} - else if(target > TARGET_TEMP_MAX) {target = TARGET_TEMP_MAX;} + target += change * 6;//0.6K * 4 per step 10; // 1 celsius per step + //if(target < TARGET_TEMP_MIN) {target = TARGET_TEMP_MIN;} + //else if(target > TARGET_TEMP_MAX) {target = TARGET_TEMP_MAX;} + if(target < LED_GREEN_TEMP) {target = LED_GREEN_TEMP;} + else if(target > LED_RED_TEMP) {target = LED_RED_TEMP;} setting_timeout = TIMEOUT; } + shutdown = 2 * (uint32_t) ONE_HOUR; input_state = new_state; }