-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
96 lines (77 loc) · 1.49 KB
/
main.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
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
#include "config.h"
#include "display.h"
#include "adc.h"
#include "output_normal.h"
#include "output_midi.h"
#include <util/delay.h>
#include "input.h"
#include "menu.h"
#include <avr/io.h>
#include <avr/interrupt.h>
int main() {
initLcd();
putsLcd("Loading...");
rotaryInit();
buttonsInit();
outputInit();
adcInit();
_delay_ms(100);
lcd_t lcd;
int i,j;
for(i = 0; i < LCD_LINES; i++) {
for(j = 0; j < LCD_CHARS; j++) {
lcd[i][j]=0x20;
}
}
unsigned int heartbeat=0;
unsigned char buttons=0;
buttons = buttonsHandleWait();
if(buttons & BTN_SHOOT) {
mainLock();
}
menuInit();
// outputNormalInit();
// outputMidiInit();
while(1) {
heartbeat++;
char tmp = buttonsHandle();
if (tmp != -1)
buttons = tmp;
outputHandleLoop();
if(isLocked()) {
if(! (buttons & BTN_SHOOT)) {
mainUnlock();
break;
}
clearLcd(lcd);
putsLcd("SAFETY LOCK ACTIVE!");
_delay_ms(500);
continue;
}
if(buttons & BTN_SHOOT) {
PORTD |= LED_SHOOT;
outputEnable();
} else {
PORTD &= ~(LED_SHOOT);
outputDisable();
}
if(buttons & BTN_CONFIRM) {
mainLock();
menuEnter(lcd);
buttons = buttonsHandleWait();
mainUnlock();
}
if (heartbeat<LCD_REFRESH)
continue;
clearLcd(lcd);
outputHandleDisp(lcd);
putsAtLcd("Vbat: ", &lcd[3][0]);
printIntAtLcd(adcConvert(ADC_BAT), &lcd[3][6]);
putsAtLcd("mV", &lcd[3][10]);
outputHandleDisp(lcd);
putsAtLcd(getOutputName(), &lcd[3][14]);
redrawLcd(lcd);
heartbeat=0;
}
return 0;
}