Skip to content

Commit

Permalink
🎨 (spike): Update lk_core_touch_sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
MMyster committed Aug 1, 2022
1 parent 09a9f56 commit 3421be3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions spikes/lk_core_touch_sensor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,26 @@ auto main() -> int
rtos::ThisThread::sleep_for(2s);

sensor.init();
sensor.reset();

resetByTouchAndRelease();

calibration();
// calibration();

log_info("Touch the sensor ! \n\n");
rtos::ThisThread::sleep_for(1s);

auto previousState = bool {};
auto lastState = bool {};
auto currentState = bool {};

while (true) {
previousState = sensor.read();
if (!lastState && previousState) {
currentState = sensor.read();
if (currentState && !previousState) {
log_info("The sensor is touched");
} else if (lastState && !previousState) {
} else if (!currentState && previousState) {
log_info("The sensor is released");
}
lastState = previousState;

previousState = currentState;
rtos::ThisThread::sleep_for(100ms);
}
}

0 comments on commit 3421be3

Please sign in to comment.