From 600917b3c048e6a98fea754953112fffd4d76d03 Mon Sep 17 00:00:00 2001 From: Mourad Latoundji Date: Mon, 1 Aug 2022 14:25:23 +0200 Subject: [PATCH] :art: (spike): Update lk_core_touch_sensor --- drivers/CoreQDAC/tests/CoreQDAC_test.cpp | 4 +--- include/interface/drivers/QDAC.h | 13 ------------- spikes/lk_core_touch_sensor/main.cpp | 14 +++++++------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/CoreQDAC/tests/CoreQDAC_test.cpp b/drivers/CoreQDAC/tests/CoreQDAC_test.cpp index 5a804b184d..d2cc726183 100644 --- a/drivers/CoreQDAC/tests/CoreQDAC_test.cpp +++ b/drivers/CoreQDAC/tests/CoreQDAC_test.cpp @@ -89,8 +89,6 @@ TEST_F(CoreQDACTest, write) EXPECT_CALL(mocki2c, write).With(Args<1, 2>(expected_buffer)).Times(1); - EXPECT_CALL(mocki2c, write).With(Args<1, 2>(expected_buffer)).Times(1); - dac.write(leka::Channel::B, value_to_write); } @@ -110,7 +108,7 @@ TEST_F(CoreQDACTest, read) EXPECT_CALL(mocki2c, read) .WillOnce(DoAll(SetArrayArgument<1>(begin(expected_buffer), end(expected_buffer)), Return(0))); - auto data = dac.read(leka::Channel::A); + auto data = dac.read(mcp4728::channel::A); ASSERT_EQ(expected_data, data); } diff --git a/include/interface/drivers/QDAC.h b/include/interface/drivers/QDAC.h index 95b6a03281..adae6b87b6 100644 --- a/include/interface/drivers/QDAC.h +++ b/include/interface/drivers/QDAC.h @@ -18,17 +18,4 @@ class QDAC virtual void write(uint8_t channel, uint16_t data) = 0; virtual auto read(uint8_t channel) -> uint16_t = 0; }; - -namespace interface { - class QDAC - { - public: - virtual ~QDAC() = default; - - virtual void init() = 0; - virtual void write(Channel channel, uint16_t data, bool eeprom = false) = 0; - virtual auto read(Channel channel, bool eeprom = false) -> uint16_t = 0; - }; - -} // namespace interface } // namespace leka::interface 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); } }