add calc impl
This commit is contained in:
parent
bc896de6b2
commit
c5fb133688
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ cmake-buid-debug
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
Debug
|
20
GccApplication3.atsln
Normal file
20
GccApplication3.atsln
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Atmel Studio Solution File, Format Version 11.00
|
||||
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "GccApplication3", "GccApplication3.cproj", "{94BBCABE-3E5B-448F-A40B-2B08DEF16444}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|AVR = Debug|AVR
|
||||
Release|AVR = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Debug|AVR.ActiveCfg = Debug|AVR
|
||||
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Debug|AVR.Build.0 = Debug|AVR
|
||||
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Release|AVR.ActiveCfg = Release|AVR
|
||||
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Release|AVR.Build.0 = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
BIN
GccApplication3.atsuo
Normal file
BIN
GccApplication3.atsuo
Normal file
Binary file not shown.
@ -99,6 +99,9 @@
|
||||
<Compile Include="calculator.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="calculator.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="keyboard.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include "calculator.h"
|
||||
|
||||
void handleCalc(struct calculator *calc, int input) {
|
||||
switch (calc->state) {
|
||||
case NUMBER_FIRST:
|
||||
@ -131,6 +131,7 @@ void handleCalc(struct calculator *calc, int input) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void clearCalc(struct calculator *calc) {
|
||||
calc->state = NUMBER_FIRST;
|
||||
calc->operation = NO_OP;
|
||||
|
@ -33,8 +33,9 @@ struct calculator {
|
||||
// 5 ñîñòîÿíèå àòîìàòà
|
||||
enum calculator_state state;
|
||||
};
|
||||
|
||||
void clearCalc(struct calculator *calc);
|
||||
|
||||
void handleCalc(struct calculator *calc, int input)
|
||||
void handleCalc(struct calculator *calc, int input);
|
||||
|
||||
#endif /* CALCULATOR_H_ */
|
41
main.c
41
main.c
@ -5,6 +5,7 @@
|
||||
#include "timer.h"
|
||||
#include "keyboard.h"
|
||||
#include "uart.h"
|
||||
#include "calculator.h"
|
||||
|
||||
void setup_registers() {
|
||||
MCUCR &= ~(1 << 4); // PUD
|
||||
@ -33,6 +34,8 @@ int main(void) {
|
||||
setup();
|
||||
puts("Hello\r\n");
|
||||
struct key keys[KEYS_AMOUNT];
|
||||
struct calculator calc;
|
||||
clearCalc(&calc);
|
||||
fill_buttons_names(keys);
|
||||
while(1) {
|
||||
get_physical_keys(keys);
|
||||
@ -44,43 +47,11 @@ int main(void) {
|
||||
if (down)
|
||||
{
|
||||
printf("%d", keys[i].button);
|
||||
handleCalc(&calc, keys[i].button);
|
||||
printf("num1: %d | num2: %d | result: %d | operation: %d | state: %d",
|
||||
calc.num1, calc.num2, calc.result, calc.operation, calc.state);
|
||||
}
|
||||
}
|
||||
|
||||
//down_amount = 0;
|
||||
//up_amoumt = 0;
|
||||
//
|
||||
//for (int i = 0; i < KEYS_AMOUNT; i++) {
|
||||
//if (keys[i].logical == false) {
|
||||
//down_amount++;
|
||||
//} else {
|
||||
//up_amoumt++;
|
||||
//}
|
||||
////bool up;
|
||||
////bool down;
|
||||
////get_event(&keys[i], &up, &down);
|
||||
////if (down) {
|
||||
////down_amount++;
|
||||
////}
|
||||
////else {
|
||||
////up_amoumt++;
|
||||
////}
|
||||
//}
|
||||
//diff = up_amoumt;
|
||||
////if (diff != diff_prev) {
|
||||
//for (int i = 0; i < KEYS_AMOUNT; i++) {
|
||||
//bool up, down;
|
||||
//get_event(&keys[i], &up, &down);
|
||||
////if (keys[i].logical == true) {
|
||||
////printf("%d", keys[i].button);
|
||||
////}
|
||||
//if (down) {
|
||||
////printf("%s\r\n", i);
|
||||
//printf("%d", keys[i].button);
|
||||
//}
|
||||
//}
|
||||
////}
|
||||
//diff_prev = diff;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user