-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBackertrapAdaApp.cpp
More file actions
120 lines (95 loc) · 2.17 KB
/
BackertrapAdaApp.cpp
File metadata and controls
120 lines (95 loc) · 2.17 KB
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
// Copyright (C) 2015 Frode Roxrud Gill
// See LICENSE file for GPLv3 license
#include "BackertrapAdaApp.h"
#include "3rd-party/Atmel/common/boards/board.h"
BackertrapAdaApp::BackertrapAdaApp()
{
}
BackertrapAdaApp::~BackertrapAdaApp()
{
}
bool BackertrapAdaApp::Init()
{
if (!m_timer_manager.Init())
return false;
board_init();
pmic_init();
if (!m_button_manager.Init() ||
!m_display_manager.Init() ||
!m_page_manager.Init())
{
return false;
}
#if 0
touch_init();
adc_sensors_init();
// Initialize USB CDC class
cdc_start();
// Display a splash screen showing button functions
button_splash();
// Set timezone from EEPROM or to a default value
timezone_init();
/* Main loop. Read keyboard status and pass input to menu system.
* When an element has been selected in the menu, it will return the
* index of the element that should be run. This can be an application
* or another menu.
*/
while (true) {
// (re)initialize menu system
gfx_mono_menu_init(&main_menu);
do {
do {
keyboard_get_key_state(&input);
// Wait for key release
} while (input.type != KEYBOARD_RELEASE);
// Send key to menu system
menu_status = gfx_mono_menu_process_key(&main_menu, input.keycode);
// Wait for something useful to happen in the menu system
} while (menu_status == GFX_MONO_MENU_EVENT_IDLE);
switch (menu_status) {
case 0:
ntc_sensor_application();
break;
case 1:
lightsensor_application();
break;
case 2:
production_date_application();
break;
case 3:
date_time_application();
break;
case 4:
// Toggle LCD Backlight
gpio_toggle_pin(NHD_C12832A1Z_BACKLIGHT);
break;
case GFX_MONO_MENU_EVENT_EXIT:
// Fall trough to default and show button splash
default:
button_splash();
break;
};
}
#endif
return true;
}
void BackertrapAdaApp::Run()
{
m_power_manager.RegisterActivity(); //Activate backlight and backlight timeout
m_page_manager.PushPage(Page::BOOTPAGE);
while(true)
{
m_power_manager.SleepIDLE();
}
}
/********************************/
BackertrapAdaApp g_app;
BackertrapAdaApp* APP() {return &g_app;}
int main()
{
if (g_app.Init())
{
g_app.Run();
}
return 0;
}