Electronic Load 1.0 Programmable Constant Current Sink

control.h
Go to the documentation of this file.
1 /*
2 * control.h
3 *
4 * Created: 22.08.2011 15:57:22
5 * Author: rolo
6 */
7
8
9 #ifndef CONTROL_H_
10 #define CONTROL_H_
11
12 #include "stdint.h"
13 #include "lcd.h"
14
15 #define CONTROL_ENTER_NUMBER_MAX_SIZE 7
16
17 extern bool cursorOn;
18 extern uint8_t cursorPos;
19
22 typedef enum { CONTROL_NOTHING,
23 CONTROL_CANCEL,
24 CONTROL_ENTER,
25 CONTROL_CHANGE,
26 CONTROL_EXIT,
27 CONTROL_ERROR
28 } CONTROL_RET;
29
30 typedef enum { CANCEL=1,ENTER,BACK,START } buttonRet_t;
31 typedef enum { CONTROL_TEXTLA,
32 CONTROL_BUTTON,
33 CONTROL_ENTERNUMBER,
34 CONTROL_REFRESH,
35 CONTROL_TERMINATOR
36 } controlType_t;
37
38 typedef struct enterNumberVariable_s
39 {
40 char value[CONTROL_ENTER_NUMBER_MAX_SIZE];
41 char *suffix_s;
42 char oldValue[CONTROL_ENTER_NUMBER_MAX_SIZE];
43 uint8_t curPos;
44 }enterNumberVariable_t;
45
48 typedef struct enterNumber_s
49 {
50 const controlType_t type;
51 uint8_t pos;
52 void (*changeCallback)(CONTROL_RET action,struct enterNumber_s *control,uint8_t param);
53 uint8_t param;
54 enterNumberVariable_t *var;
55 } ctlEnterNumber_t;
56
59 typedef struct button_s
60 {
61 const controlType_t type;
62 uint8_t pos;
63 const char *txtIndex;
64 } ctlButton_t;
65
68 typedef struct text_s
69 {
70 const controlType_t type;
71 uint8_t pos;
72 const char *txtIndex;
73 uint8_t nPar;
74 }ctlText_t;
75
82 typedef struct refresh_s
83 {
84 const controlType_t type;
85 uint8_t pos;
86 void (*callback)(uint8_t param);
87 uint8_t param;
88 }ctlRefresh_t;
89
92 typedef union
93 {
94 ctlText_t text;
95 ctlButton_t button;
96 ctlEnterNumber_t EnterNumber;
97 ctlRefresh_t refresh;
98 } control_t;
99
100
103 typedef enum
104 { CONTROL_DRAW_MODE_NORMAL,
105 CONTROL_DRAW_MODE_EDIT,
106 CONTROL_DRAW_MODE_SELECT
107 } drawMode_t;
108
109 extern CONTROL_RET EnterNumber(ctlEnterNumber_t *val,drawMode_t mode);
110
111 void EnterNumberSetValue(ctlEnterNumber_t *ctl,double val);
112 void EnterNumberSaveValue(ctlEnterNumber_t *val);
113 void EnterNumberRestoreValue(ctlEnterNumber_t *val);
114
115 #endif /* IN5DIGIT_H_ */
CONTROL_CANCEL
User canceled the input. You should set it back to the value you saved before calling the control for...
Definition: control.h:23
enterNumber_s::param
uint8_t param
Is passed to the callback function.
Definition: control.h:53
enterNumber_s
parameter set for enterNumber()
Definition: control.h:48
CONTROL_TERMINATOR
Indicating the end of the List.
Definition: control.h:35
CANCEL
Definition: control.h:30
ctlRefresh_t
struct refresh_s ctlRefresh_t
Variables for an auto-refresh-control.
refresh_s
Variables for an auto-refresh-control.
Definition: control.h:82
enterNumberVariable_s::curPos
uint8_t curPos
cursor position (0=left)
Definition: control.h:43
enterNumberVariable_s
Definition: control.h:38
refresh_s::pos
uint8_t pos
Position (see also to LCD_LINEn)
Definition: control.h:85
enterNumber_s::pos
uint8_t pos
Position (see also to LCD_LINEn)
Definition: control.h:51
text_s::nPar
uint8_t nPar
Numeric parameter which can be used in the text (%d)
Definition: control.h:73
enterNumber_s::var
enterNumberVariable_t * var
Definition: control.h:54
cursorPos
uint8_t cursorPos
Actual position of the Cursor (0=Left)
Definition: control.c:31
buttonRet_t
buttonRet_t
Definition: control.h:30
START
Definition: control.h:30
enterNumberVariable_s::suffix_s
char * suffix_s
This String is displayed after the value. Normally the physical unit (e.g. mA)
Definition: control.h:41
control_t::button
ctlButton_t button
A Button.
Definition: control.h:95
enterNumberVariable_s::value
char value[CONTROL_ENTER_NUMBER_MAX_SIZE]
The five digits plus string terminator.
Definition: control.h:40
CONTROL_ENTER_NUMBER_MAX_SIZE
#define CONTROL_ENTER_NUMBER_MAX_SIZE
Maximum size of enterNumber-string (including the 0-Terminator)
Definition: control.h:15
ENTER
Definition: control.h:30
ctlEnterNumber_t
struct enterNumber_s ctlEnterNumber_t
parameter set for enterNumber()
enterNumberVariable_t
struct enterNumberVariable_s enterNumberVariable_t
button_s::txtIndex
const char * txtIndex
Definition: control.h:63
CONTROL_TEXTLA
Left-adjusted Textvalue.
Definition: control.h:31
BACK
Definition: control.h:30
enterNumber_s::type
const controlType_t type
The type of control.
Definition: control.h:50
EnterNumberSaveValue
void EnterNumberSaveValue(ctlEnterNumber_t *val)
Saves the Value of the Input Field Purpose is to reset it to the original value when the user exits t...
Definition: control.c:59
CONTROL_BUTTON
A Button.
Definition: control.h:32
CONTROL_ENTERNUMBER
An enterNumber-type.
Definition: control.h:33
CONTROL_REFRESH
An Item that will be refreshed periodically (for displaying real-time-values)
Definition: control.h:34
EnterNumberSetValue
void EnterNumberSetValue(ctlEnterNumber_t *ctl, double val)
Sets the Value.
Definition: control.c:228
text_s::pos
uint8_t pos
Position (see also to LCD_LINEn)
Definition: control.h:71
EnterNumberRestoreValue
void EnterNumberRestoreValue(ctlEnterNumber_t *val)
Restores the old Value of the Input Field Purpose is to reset it to the original value when the user ...
Definition: control.c:73
CONTROL_EXIT
Nothing happened. This is only used with MODE_SELECT.
Definition: control.h:26
EnterNumber
CONTROL_RET EnterNumber(ctlEnterNumber_t *val, drawMode_t mode)
Enter a Number via Keyboard and/or Encoder.
Definition: control.c:105
text_s
Variables for a text-control.
Definition: control.h:68
CONTROL_ERROR
An error occurred. Do not use the input value.
Definition: control.h:27
button_s::pos
uint8_t pos
Position (see also to LCD_LINEn)
Definition: control.h:62
control_t
The control_t is a union of all possible control types.
Definition: control.h:92
lcd.h
control_t::refresh
ctlRefresh_t refresh
An Auto-Refresh-Item.
Definition: control.h:97
controlType_t
controlType_t
Definition: control.h:31
CONTROL_CHANGE
The value has changed but neither Enter nor Cancel was pressed. Use it to update a DAC for example.
Definition: control.h:25
CONTROL_ENTER
User completed the input. You can take its value for serious.
Definition: control.h:24
refresh_s::param
uint8_t param
Parameter for the callback function.
Definition: control.h:87
drawMode_t
drawMode_t
mode for drawing controls
Definition: control.h:103
text_s::type
const controlType_t type
Definition: control.h:70
CONTROL_NOTHING
Nothing happened. Only used with enterNumber.
Definition: control.h:22
CONTROL_DRAW_MODE_EDIT
The control is in edit mode.
Definition: control.h:105
CONTROL_RET
CONTROL_RET
Return values for a control.
Definition: control.h:22
enterNumberVariable_s::oldValue
char oldValue[CONTROL_ENTER_NUMBER_MAX_SIZE]
This value will be restored if the user hits cancel.
Definition: control.h:42
button_s
Variables for a button-control.
Definition: control.h:59
CONTROL_DRAW_MODE_NORMAL
The control is drawn as static (not selected and not active)
Definition: control.h:104
CONTROL_DRAW_MODE_SELECT
The control is drawn as selected. Pressing enter will change to MODE_EDIT.
Definition: control.h:106
ctlButton_t
struct button_s ctlButton_t
Variables for a button-control.
refresh_s::type
const controlType_t type
Definition: control.h:84
text_s::txtIndex
const char * txtIndex
Definition: control.h:72
ctlText_t
struct text_s ctlText_t
Variables for a text-control.
enterNumber_s::changeCallback
void(* changeCallback)(CONTROL_RET action, struct enterNumber_s *control, uint8_t param)
if not 0, this function is called every time the value changes
Definition: control.h:52
control_t::EnterNumber
ctlEnterNumber_t EnterNumber
An input Field for numerical Values.
Definition: control.h:96
refresh_s::callback
void(* callback)(uint8_t param)
Callback function which has to draw the value.
Definition: control.h:86
button_s::type
const controlType_t type
Definition: control.h:61
control_t::text
ctlText_t text
A static Text.
Definition: control.h:94
cursorOn
bool cursorOn
True if the Cursor has to be displayed.
Definition: control.c:30