Minor changes
This commit is contained in:
parent
5fe0a6d3e4
commit
17f212cf43
45
main.c
45
main.c
@ -5,12 +5,12 @@
|
||||
#include "timer.h"
|
||||
#include "keyboard.h"
|
||||
#include "uart.h"
|
||||
#include "calculator.h"
|
||||
#include "spi_master.h"
|
||||
|
||||
void setup_registers() {
|
||||
MCUCR &= ~(1 << 4); // PUD
|
||||
MCUCR &= ~(1 << 5);
|
||||
MCUCR &= ~(1 << 6);
|
||||
MCUCR &= ~(1 << 5);
|
||||
MCUCR &= ~(1 << 6);
|
||||
MCUCR &= ~(1 << 7);
|
||||
DDRD &= 0x0F;
|
||||
PORTD |= 0xF0;
|
||||
@ -21,21 +21,23 @@ void setup_registers() {
|
||||
|
||||
void setup() {
|
||||
USART_Init(MYUBRR);
|
||||
SPI_MasterInit();
|
||||
setup_timer();
|
||||
setup_registers();
|
||||
}
|
||||
|
||||
int up_amoumt = 0;
|
||||
int down_amount = 0;
|
||||
int diff = 0;
|
||||
int diff_prev = 0;
|
||||
|
||||
int main(void) {
|
||||
puts("Program started\r\n");
|
||||
|
||||
setup();
|
||||
|
||||
struct calculator calc;
|
||||
puts("Hello\r\n");
|
||||
struct key keys[KEYS_AMOUNT];
|
||||
|
||||
fill_buttons_names(keys);
|
||||
struct calculator calc;
|
||||
clearCalc(&calc);
|
||||
|
||||
fill_buttons_names(keys);
|
||||
while(1) {
|
||||
get_physical_keys(keys);
|
||||
get_logical_keys(keys);
|
||||
@ -43,15 +45,18 @@ int main(void) {
|
||||
for (int i = 0; i < KEYS_AMOUNT; i++) {
|
||||
bool up, down;
|
||||
get_event(&keys[i], &up, &down);
|
||||
if (down) {
|
||||
if (down)
|
||||
{
|
||||
//printf("button %d\r\n", keys[i].button);
|
||||
handleCalc(&calc, keys[i].button);
|
||||
printf("-------\r\n");
|
||||
printf("%d\r\n", keys[i].button);
|
||||
printf("%li\r\n", calc.num1);
|
||||
printf("%li\r\n", calc.num2);
|
||||
printf("%li\r\n", calc.result);
|
||||
printf("%d\r\n", calc.operation);
|
||||
printf("%d\r\n", calc.state);
|
||||
output_on_display(&calc);
|
||||
//printf("-----\r\n");
|
||||
//printf("%ld\r\n", calc.num1);
|
||||
//printf("%ld\r\n", calc.num2);
|
||||
//printf("%ld\r\n", calc.result);
|
||||
//printf("%d\r\n", calc.operation);
|
||||
//printf("%d\r\n", calc.state);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,8 +77,8 @@ int printf( const char * format, ... )
|
||||
va_start (args, format);
|
||||
size_t s = vsprintf (buffer,format, args);
|
||||
for(size_t i = 0; i < s; i++){
|
||||
while (!(UCSR0A & (1<<UDREn)));
|
||||
UDR0 = buffer[i];
|
||||
while (!(UCSR0A & (1<<UDREn)));
|
||||
UDR0 = buffer[i];
|
||||
}
|
||||
va_end (args);
|
||||
return s;
|
||||
|
Loading…
Reference in New Issue
Block a user