Changes on device

This commit is contained in:
Martin Bauer
2021-12-26 11:30:56 +01:00
parent da9373e74d
commit 59060d6636
5 changed files with 100 additions and 40 deletions

View File

@@ -42,6 +42,7 @@ struct MsgRfidTokenRead
struct MsgRotaryEncoder
{
int32_t position;
int32_t increment;
uint8_t direction;
};

View File

@@ -60,11 +60,20 @@ void setupRotaryEncoder()
ESP_ERROR_CHECK(rotary_encoder_set_queue(&info, eventQueueRotaryEncoder));
}
int32_t lastRotaryPosition = 0;
bool lastRotaryPositionValid = false;
void handleRotaryEncoder()
{
rotary_encoder_event_t event = {0};
if (xQueueReceive(eventQueueRotaryEncoder, &event, 0) == pdTRUE)
sendMessageToHost(MsgRotaryEncoder{event.state.position, (uint8_t)(event.state.direction)});
{
int32_t increment = 0;
if (lastRotaryPositionValid)
increment = lastRotaryPosition - event.state.position;
sendMessageToHost(MsgRotaryEncoder{event.state.position, increment, (uint8_t)(event.state.direction)});
lastRotaryPositionValid = true;
lastRotaryPosition = event.state.position;
}
}
// -------------------------------------------------- Buttons ----------------------------------------
@@ -190,12 +199,13 @@ void handleTouchInputs()
touch_pad_read(TOUCH_PAD_RIGHT_FOOT, &touchRightFoot);
touch_pad_read(TOUCH_PAD_LEFT_EAR, &touchLeftEar);
touch_pad_read(TOUCH_PAD_RIGHT_EAR, &touchRightEar);
//Serial.printf("Feet %d %d, Ears %d, %d\n", touchLeftFoot, touchRightFoot, touchLeftEar, touchRightEar);
//delay(100);
bool currentState[4];
currentState[int(TouchButton::LEFT_FOOT)] = touchLeftFoot < 380;
currentState[int(TouchButton::RIGHT_FOOT)] = touchRightFoot < 380;
currentState[int(TouchButton::LEFT_EAR)] = touchLeftEar < 430;
currentState[int(TouchButton::RIGHT_EAR)] = touchRightEar < 430;
currentState[int(TouchButton::RIGHT_EAR)] = touchRightEar < 400;
for (int i = 0; i < 4; ++i)
{