This repository has been archived by the owner on Sep 17, 2022. It is now read-only.
forked from lokthelok/aj2019-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
100 lines (84 loc) · 2.45 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
97
98
99
100
/**
Generated Main Source File
Company:
Microchip Technology Inc.
File Name:
main.c
Summary:
This is the main file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
Description:
This header file provides implementations for driver APIs for all modules selected in the GUI.
Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
Device : PIC12LF1572
Driver Version : 2.00
*/
#include "mcc_generated_files/mcc.h"
#include <stdint.h>
#include <stdbool.h>
#include "aj_hal.h"
#include "game.h"
#include "machine.h"
#include "flashValue.h"
bool buttons[3];
void main(void) {
// initialize the device
SYSTEM_Initialize();
setupLEDs(2000);
machine_warn_user();
game_initialise();
while (1) {
//Wait for Button 'Event'
bool waitingForButton = 1;
do {
checkButtons(buttons);
if(buttons[0] == 1 || buttons[1] == 1 || buttons[2] == 1)
{
waitingForButton = 0;
}
} while (waitingForButton);
//Wait for Debounce / Second Button
__delay_ms(300);
//Re-Check after Debounce
checkButtons(buttons);
//Check which buttons
if(buttons[1] == 1 && buttons[2] == 1)
{
//Connect Score - Two Left Buttons
machine_notify_user();
flashValue(123);
machine_warn_user();
game_initialise();
}
else if(buttons[0] == 1 && buttons[1] == 1)
{
//Game Score - Two Right Buttons
machine_notify_user();
flashValue(game_topscore());
machine_warn_user();
game_initialise();
}
else
{
Led button_pressed;
if(buttons[0]) button_pressed = green;
if(buttons[1]) button_pressed = yellow;
if(buttons[2]) button_pressed = red;
setLED(2000, button_pressed);
//Wait for Release
bool waitingForRelease = 1;
do {
checkButtons(buttons);
if(buttons[0] == 0 & buttons[1] == 0 && buttons[2] == 0)
{
waitingForRelease = 0;
}
} while (waitingForRelease);
setLED(0, button_pressed);
game_check_it(button_pressed);
}
}
}
/**
End of File
*/