-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.h
125 lines (94 loc) · 2.29 KB
/
ui.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* ui.h
*
* Created on:
* Author:
*/
#ifndef UI_H
#define UI_H
#include <stdbool.h>
#include <stdint.h>
#include "lcd_i2c.h"
#define LCD_HARDWARE_BLINK_ON() lcd_blink_on();
#define LCD_HARDWARE_BLINK_OFF() lcd_blink_off();
// PAGE POSITIONS
#define SET_LBL_0_PG0_POS() lcd_set_cursor(0, 0) // time position
#define SET_LBL_1_PG0_POS() lcd_set_cursor(17, 0) // temperature position
// #define SET_LBL_X_PGX_POS() lcd_set_cursor(x, x)
/* PAGE 0*/
#define NUM_OF_LBL_PG0 2 // number of labels in page 0(time and temp)
#define NUM_OF_BTN_PG0 2 // number of buttons in page 0(enter and down)
#define LBL_0_PG0_SIZE 5 // time info character size
#define LBL_1_PG0_SIZE 3 //temperature info
/* PAGE X*/
// define your size of labels as above
#define NUM_OF_LBL_PGX x
#define NUM_OF_BTN_PG0 x
#define LBL_0_PGX_SIZE x
//button id (define your buttons as below how many you need like BTN_ENTER_PGX)
typedef enum
{
BTN_ENTER_PG0 = 0,
BTN_DOWN_PG0,
BTN_END_PG0,
}button_obj_name_pg0_t;
/* typedef enum
{
BTN_X_PGX = 0,
BTN_XX_PGX,
BTN_END_PGX,
}button_obj_name_pgx_t; */
//label id (define your labels as below how many you need like LBL_TIME_PGX)
typedef enum
{
LBL_TIME_PG0 = 0,
LBL_TEMP_PG0,
LBL_END_PG0,
}label_obj_name_pg0_t;
/* typedef enum
{
LBL_X_PGX = 0,
LBL_XX_PGX,
LBL_END_PGX,
}label_obj_name_pgx_t; */
//button functions
typedef struct
{
// add button features
void (*emit_btn_pressed)(void);
} button_t;
//label functions
typedef struct
{
// add label features
void (*set_text)(cons char*, uint8_t);
void (*set_visible)(bool);
} label_t;
typedef struct
{
button_t s_btn[NUM_OF_BTN_PG0];
label_t lbl[NUM_OF_LBL_PG0];
char lbl0[LBL_0_PG0_SIZE];
char lbl1[LBL_1_PG0_SIZE];
bool o_active; // is page active or not?
} page0_t;
extern page0_t s_pg0_obj;
// extern pagex_t s_pgx_obj;
/* APP DATA */
typedef struct
{
int i_hour;
int i_minute;
}pg0_data_t;
extern pg0_data_t s_pg0_data;
void ui_hide_all_pages(void);
void ui_page0_ctor(void);
void ui_page0_show(void);
inline void str_cpy(char *dest_str, const char *src_str, uint8_t b_size)
{
for(uint8_t i = 0; i < b_size; ++i)
{
dest_str[i] = src_str[i];
}
}
#endif /* MAIN_UI_H_ */