This is a part of the Kinetiszer project.

Dependents:   SoundEngine

Committer:
Clemo
Date:
Tue Oct 28 12:19:22 2014 +0000
Revision:
0:5a419ba2726d
Error & warning free (I believe as I don't know how to clean).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Clemo 0:5a419ba2726d 1 #ifndef __KEYBOARD_H__
Clemo 0:5a419ba2726d 2 #define __KEYBOARD_H__
Clemo 0:5a419ba2726d 3
Clemo 0:5a419ba2726d 4
Clemo 0:5a419ba2726d 5 #include "board.h"
Clemo 0:5a419ba2726d 6
Clemo 0:5a419ba2726d 7
Clemo 0:5a419ba2726d 8 typedef enum
Clemo 0:5a419ba2726d 9 {
Clemo 0:5a419ba2726d 10 key_released = 0,
Clemo 0:5a419ba2726d 11 key_pressed
Clemo 0:5a419ba2726d 12 }
Clemo 0:5a419ba2726d 13 keyboard_key_press_t;
Clemo 0:5a419ba2726d 14
Clemo 0:5a419ba2726d 15
Clemo 0:5a419ba2726d 16 typedef struct
Clemo 0:5a419ba2726d 17 {
Clemo 0:5a419ba2726d 18 int8_t debounce;
Clemo 0:5a419ba2726d 19 keyboard_key_press_t value;
Clemo 0:5a419ba2726d 20 bool changed;
Clemo 0:5a419ba2726d 21 }
Clemo 0:5a419ba2726d 22 keyboard_key_data_t;
Clemo 0:5a419ba2726d 23
Clemo 0:5a419ba2726d 24
Clemo 0:5a419ba2726d 25 typedef struct
Clemo 0:5a419ba2726d 26 {
Clemo 0:5a419ba2726d 27 uint8_t port;
Clemo 0:5a419ba2726d 28 uint8_t pin;
Clemo 0:5a419ba2726d 29 uint8_t function;
Clemo 0:5a419ba2726d 30 keyboard_key_data_t data;
Clemo 0:5a419ba2726d 31 }
Clemo 0:5a419ba2726d 32 keyboard_key_t;
Clemo 0:5a419ba2726d 33
Clemo 0:5a419ba2726d 34
Clemo 0:5a419ba2726d 35 typedef struct
Clemo 0:5a419ba2726d 36 {
Clemo 0:5a419ba2726d 37 uint8_t col_port;
Clemo 0:5a419ba2726d 38 uint8_t col_pin;
Clemo 0:5a419ba2726d 39 uint8_t row_port;
Clemo 0:5a419ba2726d 40 uint8_t row_pin;
Clemo 0:5a419ba2726d 41 keyboard_key_data_t data;
Clemo 0:5a419ba2726d 42 }
Clemo 0:5a419ba2726d 43 keyboard_matrix_key_t;
Clemo 0:5a419ba2726d 44
Clemo 0:5a419ba2726d 45
Clemo 0:5a419ba2726d 46 typedef struct
Clemo 0:5a419ba2726d 47 {
Clemo 0:5a419ba2726d 48 int8_t value;
Clemo 0:5a419ba2726d 49 int8_t state;
Clemo 0:5a419ba2726d 50 uint8_t accelerator;
Clemo 0:5a419ba2726d 51 uint32_t timestamp;
Clemo 0:5a419ba2726d 52 int8_t state_sub;
Clemo 0:5a419ba2726d 53 }
Clemo 0:5a419ba2726d 54 keyboard_rotary_encoder_data_t;
Clemo 0:5a419ba2726d 55
Clemo 0:5a419ba2726d 56
Clemo 0:5a419ba2726d 57 #define KEY_DEBOUNCE_MIN (0)
Clemo 0:5a419ba2726d 58 #define KEY_DEBOUNCE_MAX (3)
Clemo 0:5a419ba2726d 59 #define KEY_PERIOD_MIN (10)
Clemo 0:5a419ba2726d 60 #define KEY_PERIOD_MAX (500)
Clemo 0:5a419ba2726d 61
Clemo 0:5a419ba2726d 62
Clemo 0:5a419ba2726d 63 void keyboard_init(void);
Clemo 0:5a419ba2726d 64 int8_t keyboard_key_is_debounced(int8_t debounce);
Clemo 0:5a419ba2726d 65 uint8_t keyboard_matrix_key_read(keyboard_matrix_key_t *p_key);
Clemo 0:5a419ba2726d 66 uint8_t keyboard_key_read(keyboard_key_t *p_key);
Clemo 0:5a419ba2726d 67 uint8_t keyboard_key_debounce(int8_t *p_debounce, uint8_t state);
Clemo 0:5a419ba2726d 68 uint32_t keyboard_scan_matrix(void);
Clemo 0:5a419ba2726d 69 uint32_t keyboard_scan_encoders(void);
Clemo 0:5a419ba2726d 70 void keyboard_encoder_speed(keyboard_rotary_encoder_data_t *p_encoder_data);
Clemo 0:5a419ba2726d 71 int8_t keyboard_encoder_tick(keyboard_key_t *p_key_a, keyboard_key_t *p_key_b, keyboard_rotary_encoder_data_t *p_encoder_data);
Clemo 0:5a419ba2726d 72 bool keyboard_get_pushbutton_changed(uint8_t key_nr);
Clemo 0:5a419ba2726d 73 keyboard_key_press_t keyboard_get_pushbutton(uint8_t key_nr, bool use);
Clemo 0:5a419ba2726d 74 void keyboard_set_pushbutton(uint8_t key_nr, keyboard_key_press_t value);
Clemo 0:5a419ba2726d 75 int8_t keyboard_get_rotary_encoder_value(uint8_t encoder_nr);
Clemo 0:5a419ba2726d 76 void keyboard_set_rotary_encoder_value(uint8_t encoder_nr, int8_t value);
Clemo 0:5a419ba2726d 77 uint8_t keyboard_get_rotary_encoder_accelerator(uint8_t encoder_nr);
Clemo 0:5a419ba2726d 78
Clemo 0:5a419ba2726d 79
Clemo 0:5a419ba2726d 80 #endif // __KEYBOARD_H__