diff --git a/spikes/lk_core_touch_sensor/main.cpp b/spikes/lk_core_touch_sensor/main.cpp index b34a1a4295..2493a47cb8 100644 --- a/spikes/lk_core_touch_sensor/main.cpp +++ b/spikes/lk_core_touch_sensor/main.cpp @@ -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); } }