/
main.cpp
73 lines (64 loc) · 1.6 KB
/
main.cpp
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
#include "System.h"
#include "Display.h"
#include "Interface.h"
#include "Signals.h"
const int SHORT_DELAY = 1000;
extern Display tft;
Console c(USART2, 115200);
Screen mainScreen = Screen(&tft);
Screen settingsScreen = Screen(&tft);
extern "C" void TIM3_IRQHandler(void) {
if (TIM_GetITStatus (TIM3, TIM_IT_Update) != RESET) {
TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
int val = ecg.read();
c.print(val);
c.print("\n");
}
}
void MainScreenInit(void){
tft.fillScreen(RA8875_BLACK);
tft.showGrid();
mainScreen.initialDraw();
}
void SettingsScreenInit(void){
tft.fillScreen(RA8875_BLACK);
tft.showGrid();
settingsScreen.initialDraw();
}
void systemInit() {
adcInit();
tft.startup();
composeMainScreen(mainScreen);
composeSettingsScreen(settingsScreen);
connectSignalsToScreen(mainScreen);
enableSignalAcquisition();
}
int main(void)
{
c.configure();
c.print("\n");
c.print("Starting FreePulse...\n");
systemInit();
c.print("Welcome!\n");
while (1) {
MainScreenInit();
delay(SHORT_DELAY);
tft.clearTouchEvents();
while (currentMode == home) {
mainScreen.update(SHORT_DELAY);
mainScreen.propogateTouch();
tft.drawPixel(tft.touch_points[0],tft.touch_points[1], RA8875_WHITE);
}
if (currentMode == settings) {
SettingsScreenInit();
delay(SHORT_DELAY);
tft.clearTouchEvents();
while (currentMode == settings) {
settingsScreen.update(SHORT_DELAY);
settingsScreen.propogateTouch();
tft.drawPixel(tft.touch_points[0],tft.touch_points[1], RA8875_WHITE);
}
}
}
return 0;
}