diff --git a/.gitignore b/.gitignore
index cdfa015..8103628 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,5 @@
cmake-buid-debug
# Executables
-*.exe
\ No newline at end of file
+*.exe
+Debug
\ No newline at end of file
diff --git a/GccApplication3.atsln b/GccApplication3.atsln
new file mode 100644
index 0000000..dcbc6c4
--- /dev/null
+++ b/GccApplication3.atsln
@@ -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
diff --git a/GccApplication3.atsuo b/GccApplication3.atsuo
new file mode 100644
index 0000000..aa5615b
Binary files /dev/null and b/GccApplication3.atsuo differ
diff --git a/GccApplication3.cproj b/GccApplication3.cproj
index f37922e..4d1b3a6 100644
--- a/GccApplication3.cproj
+++ b/GccApplication3.cproj
@@ -99,6 +99,9 @@
compile
+
+ compile
+
compile
diff --git a/calculator.c b/calculator.c
index c6e609d..e310481 100644
--- a/calculator.c
+++ b/calculator.c
@@ -1,12 +1,12 @@
-#include
#include "calculator.h"
+
void handleCalc(struct calculator *calc, int input) {
switch (calc->state) {
case NUMBER_FIRST:
switch (input) {
case 0:
- calc->num1 = (calc->num1 * 10) + 7;
- break;
+ calc->num1 = (calc->num1 * 10) + 7;
+ break;
case 1:
calc->num1 = (calc->num1 * 10) + 8;
break;
@@ -131,7 +131,8 @@ void handleCalc(struct calculator *calc, int input) {
break;
}
}
-void clearCalc(struct calculator* calc) {
+
+void clearCalc(struct calculator *calc) {
calc->state = NUMBER_FIRST;
calc->operation = NO_OP;
calc->num1 = 0;
diff --git a/calculator.h b/calculator.h
index 802474d..0e74fb7 100644
--- a/calculator.h
+++ b/calculator.h
@@ -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_ */
\ No newline at end of file
diff --git a/main.c b/main.c
index a62a143..240bfc5 100644
--- a/main.c
+++ b/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;
}
}