I2C Implementation (#84)
This commit is contained in:
committed by
GitHub
parent
881c8517bf
commit
d8731eaa17
@@ -3,6 +3,7 @@
|
||||
#include "lvgl.h"
|
||||
#include "TactilityCore.h"
|
||||
#include "Ui/LvglKeypad.h"
|
||||
#include "Hal/I2c/I2c.h"
|
||||
#include <driver/i2c.h>
|
||||
|
||||
#define TAG "tdeck_keyboard"
|
||||
@@ -11,14 +12,8 @@ typedef struct {
|
||||
lv_indev_t* device;
|
||||
} KeyboardData;
|
||||
|
||||
static inline esp_err_t keyboard_i2c_read(uint8_t* output) {
|
||||
return i2c_master_read_from_device(
|
||||
TDECK_KEYBOARD_I2C_BUS_HANDLE,
|
||||
TDECK_KEYBOARD_SLAVE_ADDRESS,
|
||||
output,
|
||||
1,
|
||||
configTICK_RATE_HZ / 10
|
||||
);
|
||||
static inline bool keyboard_i2c_read(uint8_t* output) {
|
||||
return tt::hal::i2c::masterRead(TDECK_KEYBOARD_I2C_BUS_HANDLE, TDECK_KEYBOARD_SLAVE_ADDRESS, output, 1);
|
||||
}
|
||||
|
||||
void keyboard_wait_for_response() {
|
||||
@@ -26,7 +21,7 @@ void keyboard_wait_for_response() {
|
||||
bool awake = false;
|
||||
uint8_t read_buffer = 0x00;
|
||||
do {
|
||||
awake = keyboard_i2c_read(&read_buffer) == ESP_OK;
|
||||
awake = keyboard_i2c_read(&read_buffer);
|
||||
if (!awake) {
|
||||
tt::delay_ms(100);
|
||||
}
|
||||
@@ -51,7 +46,7 @@ static void keyboard_read_callback(TT_UNUSED lv_indev_t* indev, lv_indev_data_t*
|
||||
data->key = 0;
|
||||
data->state = LV_INDEV_STATE_RELEASED;
|
||||
|
||||
if (keyboard_i2c_read(&read_buffer) == ESP_OK) {
|
||||
if (keyboard_i2c_read(&read_buffer)) {
|
||||
if (read_buffer == 0 && read_buffer != last_buffer) {
|
||||
TT_LOG_I(TAG, "Released %d", last_buffer);
|
||||
data->key = last_buffer;
|
||||
|
||||
Reference in New Issue
Block a user