heat control  r71
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
setup.c
Go to the documentation of this file.
1 /*
2  * setup.c
3  *
4  * Created on: Feb 23, 2014
5  * Author: woodz
6  */
7 
8 #include "types.h"
9 #include "setup.h"
10 #include "hc.h"
11 #include "lcdisp.h"
12 #include "lcd_lib.h"
13 #include "timer.h"
14 #include "comm.h"
15 
26  {"OIT", -32600, 32600, OFF_IN_TEMP, DT_INT, SG_MEAS},
27  {"ARV", 4500, 5500, ADC_REF_VOLTAGE, DT_UINT, SG_MEAS},
28  {"RCV", 10, 150, REV_CURRENT_VALUE, DT_UCHAR, SG_MEAS},
29  {"RRF", 5000, 65400, RR_IN, DT_UINT, SG_MEAS},
30  {"SMI", 1, 59, IV_SHOW, DT_UCHAR, SG_MEAS},
31  {"SDT", 5000, 32600, OUT_TMP_SHDN_TH, DT_INT, SG_CTRL},
32  {"SDD", 1, 10, SHTDN_DUR, DT_UCHAR, SG_CTRL},
33  {"ECD", 1, 255, ENG_CTRL_DUR, DT_UCHAR, SG_CTRL},
34 // {"TRD", 1, 100, OUT_TMP_RISE_DUR, DT_UCHAR, SG_CTRL},
35 // {"TDM", 1, 100, OUT_TMP_DEL_MULT, DT_UCHAR, SG_CTRL},
36  {"HCI", 1, 255, IV_HCREC, DT_UCHAR, SG_CTRL},
37  {"IVM", 1, 255, IV_MEAS, DT_UCHAR, SG_CTRL},
38  {"DET", 0, 10500, DELTA_TEMP, DT_UINT, SG_CTRL},
39  {"TAR", 10, 255, 120, DT_UCHAR, SG_CTRL}
40 };
41 
45 extern UINT g_setVals[NUM_SETUPS];
46 
50 void SetupInit(void) {
52 }
53 
60  UCHAR i=0;
61 
62  if(fromEep) {
63  for(i=0; i<NUM_SETUPS; ++i)
64  g_setVals[i] = eeprom_read_word(&ge_setups[i].value);
65  }
66  return g_setVals;
67 }
68 
73 void SetSetupValues(UINT* sv) {
74  UCHAR i=0;
75 
76  for(i=0; i<NUM_SETUPS; ++i) {
77  eeprom_update_word(&ge_setups[i].value, sv[i]);
78  }
79 }
80 
86 void DoSetup(BTN_CODE bc, OP_MODE* opm) {
87  static UCHAR id=0;
88 
89  if(bc == BC_DNUP_L) {
90  LCDclr();
91  if(*opm != OM_SETUP) {
92  *opm = OM_SETUP;
93  WriteSetupGroup(eeprom_read_byte(&ge_setups[id].group));
94  }
95  else {
97  *opm = SetLimitValue(*opm, DT_UCHAR, DIR_UP, OM_TMPCTRL, OP_MODES - 2);
98  return;
99  }
100  }
101  if(*opm != OM_SETUP)
102  return;
103  switch(bc) {
104  case BC_DNUP:
105  id = SetLimitValue(id, DT_UCHAR, DIR_UP, 0, NUM_SETUPS-1);
106  WriteSetupGroup(eeprom_read_byte(&ge_setups[id].group));
107  break;
108  case BC_UP:
109  g_setVals[id] = SetLimitValue(g_setVals[id], eeprom_read_byte(&ge_setups[id].type), DIR_UP, eeprom_read_word(&ge_setups[id].min), eeprom_read_word(&ge_setups[id].max));
110  break;
111  case BC_DN:
112  g_setVals[id] = SetLimitValue(g_setVals[id], eeprom_read_byte(&ge_setups[id].type), DIR_DOWN, eeprom_read_word(&ge_setups[id].min), eeprom_read_word(&ge_setups[id].max));
113  break;
114  default:
115  break;
116  }
117  PrintPage(id);
118 }
119 
124 void PrintPage(UCHAR id) {
125  //solve the page resolution by even / odd comparison of id
126  //if id is even, neighbor item is on id+1
127  //if id is odd, neighbor item is on id-1
128  //allow: flag for allow or disallow writing
129  static UCHAR allow = TRUE, oldTs = 1;
130  UCHAR ts = 0;
131  SETUP_ITEM si;
132 
133  //write time based, flash selected value
134  ts = GetTenthSec();
135  if(oldTs != ts && (ts == 0 || ts == 4))
136  {
137  oldTs = ts;
138  allow = !allow;
139  eeprom_read_block(&si, &ge_setups[id], SZ_SETUP_ITEM);
140  si.value = g_setVals[id];
141  WriteSetupValue(&si, allow, id);
142  id = (id & 0x01) == 0x01 ? id-1 : id+1;
143  if(id < NUM_SETUPS) {
144  eeprom_read_block(&si, &ge_setups[id], SZ_SETUP_ITEM);
145  si.value = g_setVals[id];
146  WriteSetupValue(&si, TRUE, id);
147  }
148  }
149 }
150 
156  LCDGotoXY(3, 0);
157  switch(bc) {
158 // case BC_NONE:
159 // LCDstring((UCHAR*)"no");
160 // break;
161  case BC_DN:
162  LCDstring((UCHAR*)"dn");
163  break;
164  case BC_UP:
165  LCDstring((UCHAR*)"up");
166  break;
167  case BC_DNUP:
168  LCDstring((UCHAR*)"du");
169  break;
170  case BC_DNUP_L:
171  LCDstring((UCHAR*)"dl");
172  break;
173  default:
174 // LCDstring((UCHAR*)" ");
175  break;
176  }
177 }
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
Definition: types.h:311
BTN_CODE
Definition: types.h:299
#define IV_MEAS
Definition: types.h:228
#define RR_IN
Definition: init.h:34
void LCDstring(uint8_t *data)
Definition: lcd_lib.c:369
#define NUM_MSR
Definition: setup.h:175
OP_MODE
Definition: types.h:146
UCHAR GetTenthSec(void)
interface to get the global tenth seconds
Definition: timer.c:192
#define MAX_ABS_INNER_TEMP
Definition: comm.h:70
UINT max
Definition: setup.h:59
#define ADC_REF_VOLTAGE
Definition: init.h:42
#define OFF_IN_TEMP
Definition: hc.h:105
#define NOM_IN_TMP
Definition: hc.h:44
UINT SetLimitValue(UINT val, DATTYPE dt, CHAR dir, INT min, INT max)
limiting values to constraints
Definition: types.c:13
#define MIN_ABS_INNER_TEMP
Definition: comm.h:74
void WriteSetupValue(SETUP_ITEM *si, UCHAR allow, UCHAR id)
put a setup item on screen, which consist of a name and a value spread over two lines ...
Definition: lcdisp.c:72
#define OP_MODES
Definition: types.h:184
#define OUT_TMP_SHDN_TH
Definition: hc.h:34
#define UCHAR
Definition: types.h:73
#define SZ_SETUP_ITEM
Definition: setup.h:42
#define IV_HCREC
Definition: hc.h:13
Definition: types.h:307
SETUP_ITEM EEMEM ge_setups[NUM_SETUPS]
Definition: setup.c:24
void WriteSetupGroup(UCHAR grp)
Definition: lcdisp.c:95
UCHAR group
Definition: setup.h:79
void LCDclr(void)
Definition: lcd_lib.c:361
void TestButton(BTN_CODE bc)
testing diferent button codes by screen visualization (inactive)
Definition: setup.c:155
Definition: types.h:315
void PrintPage(UCHAR id)
takes care of visualization on screen, flashes the selected setup value, identifies selected item and...
Definition: setup.c:124
#define SHTDN_DUR
Definition: hc.h:39
Definition: setup.h:89
#define ENG_CTRL_DUR
Definition: hc.h:19
UINT value
Definition: setup.h:63
#define REV_CURRENT_VALUE
Definition: init.h:27
#define NUM_SETUPS
Definition: setup.h:14
void SetupInit(void)
setup initialization at startup
Definition: setup.c:50
#define DELTA_TEMP
Definition: hc.h:8
#define TRUE
Definition: types.h:97
Definition: types.h:129
#define DIR_DOWN
Definition: types.h:382
void SetSetupValues(UINT *sv)
update payload values in from ram to eeprom
Definition: setup.c:73
#define IV_SHOW
Definition: types.h:282
Definition: types.h:125
#define DIR_UP
Definition: types.h:378
Definition: setup.h:93
MEASSET EEMEM ge_msRec[NUM_MSR]
Definition: setup.c:20
#define UINT
Definition: types.h:81
void DoSetup(BTN_CODE bc, OP_MODE *opm)
does the setup job, distinguishes data selection and modification dependent on user pressed buttons a...
Definition: setup.c:86
void LCDGotoXY(uint8_t x, uint8_t y)
Definition: lcd_lib.c:382
UINT g_setVals[NUM_SETUPS]
Definition: setup.h:103
Definition: types.h:206
UINT * GetSetupValues(UCHAR fromEep)
get payload values from specified memory location
Definition: setup.c:59
UINT min
Definition: setup.h:55
DATTYPE type
Definition: setup.h:67