forked from jim17/memtype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuif.c
58 lines (50 loc) · 1.15 KB
/
uif.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "uif.h"
#include "usi.h"
#include "uib.h"
#include "crd.h"
#include "opt.h"
#include "print.h"
#include "version.h"
/* public variable */
uint8_t UIF_state;
uint8_t UIF_credIndex = 0;
uint8_t UIF_optionsIndex = 0;
uint8_t UIF_userInputIndex = 0;
const char uif_initStr[] PROGMEM = MEMTYPE_VERSION_STR;
void UIF_Init(void){
UIF_state = START;
printStr((void*)uif_initStr, FLASH);
}
void UIF_Task(void){
if((UIB_buttonChanged == 1u) && (UIB_buttonPressed != NOT_PRESSED))
{
switch(UIF_state)
{
case START:
UIF_state = USER_INPUT;
print_deleteStr();
USI_Init();
break;
case OPTIONS:
OPT_fsm(UIB_buttonPressed);
break;
case USER_INPUT:
USI_fsm(UIB_buttonPressed);
break;
default: //CREDENTIALS
CRD_fsm(UIB_buttonPressed);
break;
}
}
}
void UIF_increment(uint8_t* val, uint8_t max){
*val = ((*val)+1) % max;
}
void UIF_decrement(uint8_t* val, uint8_t max){
if((*val) == 0) {
*val = (max-1);
}
else {
*val = (*val)-1;
}
}