Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/fw/drivers/touch/cst816/cst816.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static PebbleMutex *s_i2c_lock;

static void prv_exti_cb(bool *should_context_switch);
static void cst816_hw_reset(void);
void touch_sensor_set_enabled(bool enabled);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is called before implementation, so declare it here.


static bool prv_read_data(uint16_t register_address, uint8_t *result, uint16_t size, bool is_work_mode) {
mutex_lock(s_i2c_lock);
Expand Down Expand Up @@ -251,14 +252,17 @@ void touch_sensor_init(void) {
static void prv_process_pending_messages(void* context) {
s_callback_scheduled = false;

const uint64_t current_time_ms = ticks_to_milliseconds(rtc_get_ticks());
uint8_t data[CST816_TOUCH_DATA_SIZE] = {0};
bool rv = prv_read_data(CST816_TOUCH_DATA_REG, data, CST816_TOUCH_DATA_SIZE, 1);
if (!rv) {
PBL_LOG_ERR("Failed to read touch data, dropping event");
PBL_LOG_ERR("Failed to read touch data, trying to recover");
touch_handle_update(0, TouchState_FingerUp, NULL, 0, current_time_ms);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if there was no down event before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when it happens on touch down status, the upper layer may not know the hardware been reset with default FingerUp status, so force report the FingerUp event to upper layer.

exti_disable(CST816->int_exti);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do hw reset, don't know if the INT pin is stable or not, so force disable interrupt during reset cycle.

touch_sensor_set_enabled(true);
return;
}

const uint64_t current_time_ms = ticks_to_milliseconds(rtc_get_ticks());
uint8_t press = data[0] & 0x0F;
GPoint point = {
.x = (((uint16_t)(data[1] & 0x0F)) << 8) | data[2],
Expand Down
Loading