#include #include #include #include #include "timer.h" #include "keyboard.h" #include "uart.h" #include "calculator.h" void setup_registers() { MCUCR &= ~(1 << 4); // PUD MCUCR &= ~(1 << 5); MCUCR &= ~(1 << 6); MCUCR &= ~(1 << 7); DDRD &= 0x0F; PORTD |= 0xF0; DDRC = 0b111111; PORTC = 0b001111; } void setup() { USART_Init(MYUBRR); setup_timer(); setup_registers(); } int up_amoumt = 0; int down_amount = 0; int diff = 0; int diff_prev = 0; 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); get_logical_keys(keys); for (int i = 0; i < KEYS_AMOUNT; i++) { bool up, down; get_event(&keys[i], &up, &down); 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); } } } } int puts(const char * __str){ int len = strlen(__str); for(size_t i = 0; i < len; i++){ while (!(UCSR0A & (1<