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