added get_key() function to Laplace

This commit is contained in:
ayabusa 2024-04-15 19:03:58 +02:00
parent 6e5e5ddda6
commit 3a4fa32c93
7 changed files with 22 additions and 8 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -90,3 +90,14 @@ struct button* keyboard_scan(){
return result_button_list;
}
/* Scans the specified key and return true if pressed
It's more performant that scanning the whole keyboard */
bool get_key(char row, uint8_t column){
for(int i = 0; i < number_of_rows; i++){
if(row==row_list[i]){
activate_row(i);
return(read_input_pin(GPIO_C, column));
}
}
return false;
}

View File

@ -23,4 +23,8 @@ void keyboard_init();
You can find the button struct definition in keyboard.h */
struct button* keyboard_scan();
/* Scans the specified key and return true if pressed
It's more performant that scanning the whole keyboard */
bool get_key(char row, uint8_t column);
#endif

View File

@ -5,10 +5,10 @@ void main_entry(){
// init all the peripherals
laplace_init();
ms_wait(2000);
set_led_green(true);
// infinite loop
while (1){
/*
struct button * keyboard_state = keyboard_scan();
for(int i =0; i < 54; i++){
@ -26,14 +26,13 @@ void main_entry(){
set_led_green(false);
}
}
if(keyboard_state[i].column == 2 && keyboard_state[i].row == 'H'){
if(keyboard_state[i].state){
}*/
if(get_key('G', 3)){
set_led_red(true);
}else{
set_led_red(false);
}
}
}
}
}