From a56e47eb7f714dc687684c6ed99d82f18636e2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=91=D0=B0=D1=82?= =?UTF-8?q?=D1=83=D1=85=D1=82=D0=B8=D0=BD?= Date: Sat, 3 Jun 2023 19:13:55 +0300 Subject: [PATCH] Minor changes --- calculator.c | 12 +++++++----- calculator.h | 12 ++++++++++++ keyboard.c | 9 +++++++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/calculator.c b/calculator.c index c2757c8..ff98de5 100644 --- a/calculator.c +++ b/calculator.c @@ -5,8 +5,8 @@ void handleCalc(struct calculator *calc, int input) { 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; @@ -124,16 +124,18 @@ void handleCalc(struct calculator *calc, int input) { break; case RESULT: switch (input) { - case 13: - clearCalc(calc); case 14: clearCalc(calc); break; + case 13: + clearCalc(calc); + break; } 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 0bc6b07..68b42de 100644 --- a/calculator.h +++ b/calculator.h @@ -1,3 +1,13 @@ +/* + * calculator.h + * + * Created: 29.05.2023 12:01:39 + * Author: mrnek + */ + + +#ifndef CALCULATOR_H_ +#define CALCULATOR_H_ enum calculator_state { NUMBER_FIRST, @@ -27,3 +37,5 @@ struct calculator { void clearCalc(struct calculator *calc); void handleCalc(struct calculator *calc, int input); + +#endif /* CALCULATOR_H_ */ \ No newline at end of file diff --git a/keyboard.c b/keyboard.c index dce7867..2dc69df 100644 --- a/keyboard.c +++ b/keyboard.c @@ -9,6 +9,7 @@ #include #include "keyboard.h" #include "timer.h" +#include "func.h" #define MASK_PIND 0b11110000 @@ -18,7 +19,7 @@ void get_physical_keys(struct key *keys) { uint8_t row; for (int i = 0; i < KEYS_AMOUNT / 4; i++) { PORTC &= ~(1 << i); - for(volatile long i = 0; i < 1000; i++){}; + delay(); row = PIND & MASK_PIND; if (row & (1 << 4)) keys[i * 4].physical = false; else keys[i * 4].physical = true; if (row & (1 << 5)) keys[i * 4 + 1].physical = false; else keys[i * 4 + 1].physical = true; @@ -36,8 +37,9 @@ void get_logical_keys(struct key *undc_keys) { undc_keys[i].logical = undc_keys[i].physical; set_key_event(&undc_keys[i]); } - } else { + } else { undc_keys[i].time = timestamp; + } } } @@ -48,6 +50,9 @@ void fill_buttons_names(struct key *buttons) { } } +/************************************************************************/ +/* */ +/************************************************************************/ static void set_key_event(struct key *button) { if (button->logical == true) { button->on_down = true;