Skip to content

Commit

Permalink
✨ (RobotKit): Add CoreHTS and link to BLE service
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Feb 2, 2024
1 parent ce584c6 commit 390f898
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ target_link_libraries(LekaOS
IMUKit
MotionKit
EventLoopKit
CoreHTS
)

target_link_custom_leka_targets(LekaOS)
15 changes: 15 additions & 0 deletions app/os/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "CoreFlashManagerIS25LP016D.h"
#include "CoreFont.hpp"
#include "CoreGraphics.hpp"
#include "CoreHTS.h"
#include "CoreI2C.h"
#include "CoreInterruptIn.h"
#include "CoreJPEG.hpp"
Expand Down Expand Up @@ -150,6 +151,17 @@ namespace factory_reset {

} // namespace factory_reset

namespace temperature_humidity {

namespace internal {

auto i2c = CoreI2C {PinName::SENSOR_IMU_TH_I2C_SDA, PinName::SENSOR_IMU_TH_I2C_SCL};
}

auto sensor = CoreHTS {internal::i2c};

} // namespace temperature_humidity

namespace leds {

namespace internal {
Expand Down Expand Up @@ -418,6 +430,8 @@ namespace robot {
internal::timeout_state_transition,
internal::timeout_autonomous_activities,
battery::cells,
temperature_humidity::sensor,
temperature_humidity::sensor,
internal::serialnumberkit,
firmware::kit,
motors::left::motor,
Expand Down Expand Up @@ -562,6 +576,7 @@ auto main() -> int
commandkit.registerCommand(command::list);
activitykit.registerActivities(activities::activities);

temperature_humidity::sensor.init();
imu::lsm6dsox.init();
imukit.init();

Expand Down
21 changes: 16 additions & 5 deletions libs/RobotKit/include/RobotController.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "interface/drivers/FirmwareUpdate.h"
#include "interface/drivers/LCD.hpp"
#include "interface/drivers/Motor.h"
#include "interface/drivers/TemperatureSensor.h"
#include "interface/drivers/Timeout.h"
#include "interface/libs/LedKit.h"
#include "interface/libs/VideoKit.h"
Expand All @@ -51,15 +52,18 @@ class RobotController : public interface::RobotController

explicit RobotController(interface::Timeout &timeout_state_internal, interface::Timeout &timeout_state_transition,
interface::Timeout &timeout_autonomous_activities, interface::Battery &battery,
SerialNumberKit &serialnumberkit, interface::FirmwareUpdate &firmware_update,
interface::Motor &motor_left, interface::Motor &motor_right, interface::LED &ears,
interface::LED &belt, interface::LedKit &ledkit, interface::LCD &lcd,
interface::VideoKit &videokit, BehaviorKit &behaviorkit, CommandKit &cmdkit,
RFIDKit &rfidkit, ActivityKit &activitykit)
interface::TemperatureSensor &temperature_sensor,
interface::HumiditySensor &humidity_sensor, SerialNumberKit &serialnumberkit,
interface::FirmwareUpdate &firmware_update, interface::Motor &motor_left,
interface::Motor &motor_right, interface::LED &ears, interface::LED &belt,
interface::LedKit &ledkit, interface::LCD &lcd, interface::VideoKit &videokit,
BehaviorKit &behaviorkit, CommandKit &cmdkit, RFIDKit &rfidkit, ActivityKit &activitykit)
: _timeout_state_internal(timeout_state_internal),
_timeout_state_transition(timeout_state_transition),
_timeout_autonomous_activities(timeout_autonomous_activities),
_battery(battery),
_temperature_sensor(temperature_sensor),
_humidity_sensor(humidity_sensor),
_serialnumberkit(serialnumberkit),
_firmware_update(firmware_update),
_motor_left(motor_left),
Expand Down Expand Up @@ -482,6 +486,11 @@ class RobotController : public interface::RobotController

_battery_kit.startEventHandler();

_service_monitoring.onTemperatureHumidityRequested([this]() {
_service_monitoring.setTemperature(_temperature_sensor.getTemperatureCelsius());
_service_monitoring.setHumidity(_humidity_sensor.getRelativeHumidity());

Check warning on line 491 in libs/RobotKit/include/RobotController.h

View check run for this annotation

Codecov / codecov/patch

libs/RobotKit/include/RobotController.h#L490-L491

Added lines #L490 - L491 were not covered by tests
});

_ble.onConnectionCallback([this] { raise(event::ble_connection {}); });

_ble.onDisconnectionCallback([this] { raise(event::ble_disconnection {}); });
Expand Down Expand Up @@ -561,6 +570,8 @@ class RobotController : public interface::RobotController
interface::Battery &_battery;
BatteryKit _battery_kit {_battery};
uint8_t _minimal_battery_level_to_update {25};
interface::TemperatureSensor &_temperature_sensor;
interface::HumiditySensor &_humidity_sensor;

SerialNumberKit &_serialnumberkit;

Expand Down
6 changes: 6 additions & 0 deletions libs/RobotKit/tests/RobotController_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "mocks/leka/LedKit.h"
#include "mocks/leka/MCU.h"
#include "mocks/leka/PwmOut.h"
#include "mocks/leka/TemperatureSensor.h"
#include "mocks/leka/Timeout.h"
#include "mocks/leka/VideoKit.h"
#include "mocks/mbed/DigitalOut.h"
Expand Down Expand Up @@ -84,6 +85,9 @@ class RobotControllerTest : public testing::Test
mock::MCU mock_mcu {};
SerialNumberKit serialnumberkit {mock_mcu, SerialNumberKit::DEFAULT_CONFIG};

mock::TemperatureSensor temperature_sensor {};
mock::HumiditySensor humidity_sensor {};

mock::FirmwareUpdate firmware_update {};

mock::CoreLED mock_ears;
Expand Down Expand Up @@ -115,6 +119,8 @@ class RobotControllerTest : public testing::Test
timeout_state_transition,
timeout_autonomous_activities,
battery,
temperature_sensor,
humidity_sensor,
serialnumberkit,
firmware_update,
mock_motor_left,
Expand Down

0 comments on commit 390f898

Please sign in to comment.