Electronic Load  1.0
Programmable Constant Current Sink
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
control.h File Reference
Include dependency graph for control.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  button_s
 Variables for a button-control. More...
 
union  control_t
 The control_t is a union of all possible control types. More...
 
struct  enterNumber_s
 parameter set for enterNumber() More...
 
struct  enterNumberVariable_s
 
struct  refresh_s
 Variables for an auto-refresh-control. More...
 
struct  text_s
 Variables for a text-control. More...
 

Macros

#define CONTROL_ENTER_NUMBER_MAX_SIZE   7
 Maximum size of enterNumber-string (including the 0-Terminator) More...
 

Typedefs

typedef struct button_s ctlButton_t
 Variables for a button-control. More...
 
typedef struct enterNumber_s ctlEnterNumber_t
 parameter set for enterNumber() More...
 
typedef struct refresh_s ctlRefresh_t
 Variables for an auto-refresh-control. More...
 
typedef struct text_s ctlText_t
 Variables for a text-control. More...
 
typedef struct enterNumberVariable_s enterNumberVariable_t
 

Enumerations

enum  buttonRet_t { CANCEL =1, ENTER, BACK, START }
 
enum  CONTROL_RET {
  CONTROL_NOTHING, CONTROL_CANCEL, CONTROL_ENTER, CONTROL_CHANGE,
  CONTROL_EXIT, CONTROL_ERROR
}
 Return values for a control. More...
 
enum  controlType_t {
  CONTROL_TEXTLA, CONTROL_BUTTON, CONTROL_ENTERNUMBER, CONTROL_REFRESH,
  CONTROL_TERMINATOR
}
 
enum  drawMode_t { CONTROL_DRAW_MODE_NORMAL, CONTROL_DRAW_MODE_EDIT, CONTROL_DRAW_MODE_SELECT }
 mode for drawing controls More...
 

Functions

CONTROL_RET EnterNumber (ctlEnterNumber_t *val, drawMode_t mode)
 Enter a Number via Keyboard and/or Encoder. More...
 
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 exits the control with cancel. More...
 
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 the control with cancel. More...
 
void EnterNumberSetValue (ctlEnterNumber_t *ctl, double val)
 Sets the Value. More...
 

Variables

bool cursorOn
 True if the Cursor has to be displayed. More...
 
uint8_t cursorPos
 Actual position of the Cursor (0=Left) More...
 

Macro Definition Documentation

◆ CONTROL_ENTER_NUMBER_MAX_SIZE

#define CONTROL_ENTER_NUMBER_MAX_SIZE   7

Maximum size of enterNumber-string (including the 0-Terminator)

Typedef Documentation

◆ enterNumberVariable_t

◆ ctlEnterNumber_t

parameter set for enterNumber()

◆ ctlButton_t

typedef struct button_s ctlButton_t

Variables for a button-control.

◆ ctlText_t

typedef struct text_s ctlText_t

Variables for a text-control.

◆ ctlRefresh_t

typedef struct refresh_s ctlRefresh_t

Variables for an auto-refresh-control.

The structure provides a callback function which has to draw the value. It will be called in regular intervals to actualize its content.

Enumeration Type Documentation

◆ CONTROL_RET

Return values for a control.

Enumerator
CONTROL_NOTHING 

Nothing happened. Only used with enterNumber.

CONTROL_CANCEL 

User canceled the input. You should set it back to the value you saved before calling the control for the first time.

CONTROL_ENTER 

User completed the input. You can take its value for serious.

CONTROL_CHANGE 

The value has changed but neither Enter nor Cancel was pressed. Use it to update a DAC for example.

CONTROL_EXIT 

Nothing happened. This is only used with MODE_SELECT.

CONTROL_ERROR 

An error occurred. Do not use the input value.

◆ buttonRet_t

Enumerator
CANCEL 
ENTER 
BACK 
START 

◆ controlType_t

Enumerator
CONTROL_TEXTLA 

Left-adjusted Textvalue.

CONTROL_BUTTON 

A Button.

CONTROL_ENTERNUMBER 

An enterNumber-type.

CONTROL_REFRESH 

An Item that will be refreshed periodically (for displaying real-time-values)

CONTROL_TERMINATOR 

Indicating the end of the List.

◆ drawMode_t

enum drawMode_t

mode for drawing controls

Enumerator
CONTROL_DRAW_MODE_NORMAL 

The control is drawn as static (not selected and not active)

CONTROL_DRAW_MODE_EDIT 

The control is in edit mode.

CONTROL_DRAW_MODE_SELECT 

The control is drawn as selected. Pressing enter will change to MODE_EDIT.

Function Documentation

◆ EnterNumber()

CONTROL_RET EnterNumber ( ctlEnterNumber_t val,
drawMode_t  mode 
)

Enter a Number via Keyboard and/or Encoder.

Parameters
valPointer to input data structure
modeThe draw mode
Returns
see CONTROL_RET

The value-member must be set to a default value before calling this function. The value is a pattern consisting of digits and optionally a period. The length of the pattern is constant and the period cannot be moved. The period must not be the very first or last character! The user then may modify the value. If return is != CONTROL_ENTER the value should not be used since it may have been erroneously modified by the user.
If return is CONTROL_CHANGE you may process the change but should call the function again (with the same val) to allow the user to continue with his input.
To keep this function non-blocking it will return CONRTOL_NOTHING if no key- or encoder event is pending. Call it again as soon as you find time to until it returns CONTROL_ENTER or CONTROL_CANCEL. You can specify a change-callback function which is called every time the value is changed by the encoder.

Here is the call graph for this function:

◆ EnterNumberSetValue()

void EnterNumberSetValue ( ctlEnterNumber_t ctl,
double  val 
)

Sets the Value.

Parameters
ctlThe address of the EnterNumber struct
valThe desired Value

◆ 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 the control with cancel.

This function must be called when the user enters the control.

Parameters
valPointer to enterNumber-struct

◆ 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 exits the control with cancel.

This function must be called when the user exits the control with the cancel key.

Parameters
valPointer to enterNumber-struct
Here is the call graph for this function:

Variable Documentation

◆ cursorOn

bool cursorOn

True if the Cursor has to be displayed.

◆ cursorPos

uint8_t cursorPos

Actual position of the Cursor (0=Left)