diff --git a/numworks_port/README.md b/numworks_port/README.md index 8746b7b..e3da20b 100644 --- a/numworks_port/README.md +++ b/numworks_port/README.md @@ -12,7 +12,7 @@ This is a bare metal os attempt on the numworks n0110 ### Zeta bare minimum - [x] Working thing - [x] Led interface -- [ ] Keyboard interface +- [x] Keyboard interface - [ ] Set clock and all - [ ] adapt ms_wait() and us_wait() - [ ] Screen interface diff --git a/numworks_port/build/Laplace/keyboard.o b/numworks_port/build/Laplace/keyboard.o index 224bddf..c52184b 100644 Binary files a/numworks_port/build/Laplace/keyboard.o and b/numworks_port/build/Laplace/keyboard.o differ diff --git a/numworks_port/build/Laplace/laplace.o b/numworks_port/build/Laplace/laplace.o index 2cb6cb8..ac29955 100644 Binary files a/numworks_port/build/Laplace/laplace.o and b/numworks_port/build/Laplace/laplace.o differ diff --git a/numworks_port/build/main.bin b/numworks_port/build/main.bin index db693a4..632f485 100755 Binary files a/numworks_port/build/main.bin and b/numworks_port/build/main.bin differ diff --git a/numworks_port/build/main.elf b/numworks_port/build/main.elf index efdedea..e8a3275 100755 Binary files a/numworks_port/build/main.elf and b/numworks_port/build/main.elf differ diff --git a/numworks_port/build/main.o b/numworks_port/build/main.o index 00bb825..1f8ae0c 100644 Binary files a/numworks_port/build/main.o and b/numworks_port/build/main.o differ diff --git a/numworks_port/build/start_handler.o b/numworks_port/build/start_handler.o index 5ffb610..37f6436 100644 Binary files a/numworks_port/build/start_handler.o and b/numworks_port/build/start_handler.o differ diff --git a/numworks_port/src/Laplace/keyboard.c b/numworks_port/src/Laplace/keyboard.c index 46f2e13..ced4e49 100644 --- a/numworks_port/src/Laplace/keyboard.c +++ b/numworks_port/src/Laplace/keyboard.c @@ -41,6 +41,7 @@ const uint8_t number_of_rows = 9; const uint8_t number_of_columns = 6; +const char row_list[9] = {'B', 'A', 'C', 'D', 'E', 'F', 'G', 'H', 'I'}; void keyboard_init(){ for (int i = 0; i < number_of_rows; i++){ @@ -57,12 +58,6 @@ void keyboard_init(){ } } -bool keyboard_scan(){ - set_output_pin(GPIO_A, 6, true); - bool key_state = read_input_pin(GPIO_C, 3); - return key_state; - // A LOT TODO -} void activate_row(uint8_t row_nb){ // set all row to 0 and then reenable selected row @@ -71,4 +66,22 @@ void activate_row(uint8_t row_nb){ } set_output_pin(GPIO_A, row_nb, false); us_wait(100); -} \ No newline at end of file +} + +struct button* keyboard_scan(){ + static struct button result_button_list[54] = {}; + uint8_t i = 0; + for(int r = 0; r < number_of_rows; r++){ + activate_row(r); + + for(int c = 0; c < number_of_columns; c++){ + bool key_state = read_input_pin(GPIO_C, c); + result_button_list[i].row = row_list[r]; + result_button_list[i].column = c + 1; + result_button_list[i].state = key_state; + i++; + } + } + return result_button_list; +} + diff --git a/numworks_port/src/Laplace/keyboard.h b/numworks_port/src/Laplace/keyboard.h index 32d7b97..a06b45b 100644 --- a/numworks_port/src/Laplace/keyboard.h +++ b/numworks_port/src/Laplace/keyboard.h @@ -7,21 +7,16 @@ #ifndef KEYBOARD_H #define KEYBOARD_H -enum PIN_ROW { - A = 1, - B = 0, - C = 2, - D = 3, - E = 4, - F = 5, - G = 6, - H = 7, - I = 8 -}; - #include "gpio_helper.h" +struct button{ + uint8_t column; + char row; + bool state; +}; + + void keyboard_init(); -bool keyboard_scan(); +struct button* keyboard_scan(); #endif \ No newline at end of file diff --git a/numworks_port/src/main.c b/numworks_port/src/main.c index 81f4906..9bf2e4e 100644 --- a/numworks_port/src/main.c +++ b/numworks_port/src/main.c @@ -8,11 +8,17 @@ void main_entry(){ set_led_green(true); while (1) { - /*if(keyboard_scan()){ - set_led_green(true); - }else{ - set_led_green(false); - }*/ + struct button * keyboard_state = keyboard_scan(); + for(int i =0; i < 54; i++){ + if(keyboard_state[i].column == 4 && keyboard_state[i].row == 'H'){ + if(keyboard_state[i].state){ + set_led_green(true); + }else{ + set_led_green(false); + } + break; + } + } } } \ No newline at end of file