-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
75 lines (61 loc) · 1.67 KB
/
main.c
File metadata and controls
75 lines (61 loc) · 1.67 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
/* +--------------------------------------------+ */
/* | Zenit Multimeter | */
/* | main.c | */
/* | (c)copyright nitram147 [Martin Ersek] 2018 | */
/* +--------------------------------------------+ */
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdlib.h>
#include <string.h>
#include "lcd.h"
#include "uart.h"
#include "esp.h"
#include "parser.h"
#include "calibration.h"
#include "spi.h"
#include "buttons_switches.h"
#include "measure.h"
#include "display.h"
#define WELCOME_TEXT "Zenit Multimeter"
void after_start(){
//initialize LCD display
lcd_init(LCD_DISP_ON);
//retrieve calibration constants
init_calibration_constants();
//enable serial communication
enable_uart();
//itialize SPI bus
spi_init();
//initialize buttons ADC and set buttons color to none
buttons_init();
//display welcome text and wait a little bit
lcd_puts_fixed(WELCOME_TEXT);
_delay_ms(2000);
}
int main(){
//wait until device get to the steady state
_delay_ms(500);
//run after start routines
after_start();
//because we don't want to do measurement in each iteration of infinity loop
uint8_t tmp_measure_it = 1;
uint8_t tmp_count_to_measure = 0;
//infinity loop
while(1){
//set measurement flag to 1 each fifth loop
if(tmp_count_to_measure > 5){
tmp_measure_it = 1;
tmp_count_to_measure = 0;
}else{
tmp_measure_it = 0;
tmp_count_to_measure++;
}
//check is any button is pressed and evaluate pertaining function
evaluate_buttons();
//display contents pertaining to selected device mode
display_actual_mode_content(tmp_measure_it);
_delay_ms(50);
}
return 0;
}