mirror of
https://github.com/ayabusa/Numworks-zeta-os.git
synced 2024-11-24 03:43:25 +00:00
implemented the keyboard interface
This commit is contained in:
parent
24773004b4
commit
1ef815d5a8
@ -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
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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
|
||||
@ -72,3 +67,21 @@ void activate_row(uint8_t row_nb){
|
||||
set_output_pin(GPIO_A, row_nb, false);
|
||||
us_wait(100);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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
|
@ -8,11 +8,17 @@ void main_entry(){
|
||||
set_led_green(true);
|
||||
while (1)
|
||||
{
|
||||
/*if(keyboard_scan()){
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user