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 Oct 5, 2022
1 parent 4cce4e3 commit 600917b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
4 changes: 1 addition & 3 deletions drivers/CoreQDAC/tests/CoreQDAC_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}
Expand Down
13 changes: 0 additions & 13 deletions include/interface/drivers/QDAC.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 600917b

Please sign in to comment.