]> git.ayabusa.dev Git - numworks-zeta-os.git/commitdiff
implemented the keyboard interface
authorayabusa <lebgpub@gmail.com>
Fri, 5 Apr 2024 16:15:37 +0000 (18:15 +0200)
committerayabusa <lebgpub@gmail.com>
Fri, 5 Apr 2024 16:15:37 +0000 (18:15 +0200)
numworks_port/README.md
numworks_port/build/Laplace/keyboard.o
numworks_port/build/Laplace/laplace.o
numworks_port/build/main.bin
numworks_port/build/main.elf
numworks_port/build/main.o
numworks_port/build/start_handler.o
numworks_port/src/Laplace/keyboard.c
numworks_port/src/Laplace/keyboard.h
numworks_port/src/main.c

index 8746b7b4c40e8699993cd9970857baf769a260b1..e3da20bd9a92b6e37f20c8adf8145662e89fa64b 100644 (file)
@@ -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
index 224bddf920496e6983ffe1f677e14707bb93e6ac..c52184b921b47e6b53f093e8b83454084295a78e 100644 (file)
Binary files a/numworks_port/build/Laplace/keyboard.o and b/numworks_port/build/Laplace/keyboard.o differ
index 2cb6cb80ea24d2d9372472c3addf3fe62dce1fc4..ac299558d1d9bdb813dced3616511ecd3827d8c3 100644 (file)
Binary files a/numworks_port/build/Laplace/laplace.o and b/numworks_port/build/Laplace/laplace.o differ
index db693a414c4fbc8c92d9422b1545feae7fd7e3bb..632f485714454486df4580b1082569772c62405b 100755 (executable)
Binary files a/numworks_port/build/main.bin and b/numworks_port/build/main.bin differ
index efdedeaaac0a7789fc95d172a6ae339bc47c9825..e8a3275eed6d41a53a8dcc5bf2dba654a365dc8a 100755 (executable)
Binary files a/numworks_port/build/main.elf and b/numworks_port/build/main.elf differ
index 00bb825ce85e6f55e006e1433f060520075cf1ea..1f8ae0c3c6114f7c38137bc92b93604388ac6eba 100644 (file)
Binary files a/numworks_port/build/main.o and b/numworks_port/build/main.o differ
index 5ffb6102af33a626cfe1c302131cc72bd754aaef..37f6436d3798c2f8d7abe302f59cd49e92ff3252 100644 (file)
Binary files a/numworks_port/build/start_handler.o and b/numworks_port/build/start_handler.o differ
index 46f2e134b61b599b204db6f03990e99d04f47346..ced4e4969a2c2e56110c33861f601092b97dfbac 100644 (file)
@@ -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;
+}
+
index 32d7b97d477637b943fa39a915c001eef8cea5dd..a06b45b5f671b2f9fb5c9be78bb6b8278dafec37 100644 (file)
@@ -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;
 };
 
-#include "gpio_helper.h"
 
 void keyboard_init();
-bool keyboard_scan();
+struct button* keyboard_scan();
 
 #endif
\ No newline at end of file
index 81f49068375942aac74aeaa61c6c7cf66fb3c3aa..9bf2e4ebbe050eeff9ece22e1e1a9c85692e3ae0 100644 (file)
@@ -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