Skip to content

Commit

Permalink
🚚 (drivers): Rename remove LK prefix from LKCoreBattery driver
Browse files Browse the repository at this point in the history
Rename LKCoreBattery to CoreBattery
  • Loading branch information
Kabroc committed Jun 28, 2021
1 parent 3bde82f commit e392e10
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ add_subdirectory(${DRIVERS_DIR}/LKCoreVideo)

# Sensors drivers
add_subdirectory(${DRIVERS_DIR}/CoreHTS)
add_subdirectory(${DRIVERS_DIR}/LKCoreBattery)
add_subdirectory(${DRIVERS_DIR}/CoreBattery)
add_subdirectory(${DRIVERS_DIR}/LKCoreMicrophone)
add_subdirectory(${DRIVERS_DIR}/LKCoreLightSensor)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
# Copyright 2021 APF France handicap
# SPDX-License-Identifier: Apache-2.0

add_library(LKCoreBattery STATIC)
add_library(CoreBattery STATIC)

target_include_directories(LKCoreBattery
target_include_directories(CoreBattery
PUBLIC
include
)

target_sources(LKCoreBattery
target_sources(CoreBattery
PRIVATE
source/LKCoreBattery.cpp
source/CoreBattery.cpp
)

target_link_libraries(LKCoreBattery mbed-os)
target_link_libraries(CoreBattery mbed-os)

if (${CMAKE_PROJECT_NAME} STREQUAL "LekaOSUnitTests")

leka_unit_tests_sources(
tests/LKCoreBattery_test.cpp
tests/CoreBattery_test.cpp
)

endif()
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

namespace leka {

class LKCoreBattery
class CoreBattery
{
public:
explicit LKCoreBattery(PinName pin) : _pin {mbed::AnalogIn(pin)} {};
explicit CoreBattery(PinName pin) : _pin {mbed::AnalogIn(pin)} {};

float readVoltage(void);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Copyright 2021 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#include "LKCoreBattery.h"
#include "CoreBattery.h"

namespace leka {

float LKCoreBattery::readVoltage(void)
float CoreBattery::readVoltage(void)
{
return _pin.read();
}
Expand Down
44 changes: 44 additions & 0 deletions drivers/CoreBattery/tests/CoreBattery_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Leka - LekaOS
// Copyright 2021 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#include "CoreBattery.h"

#include "gtest/gtest.h"
#include "stubs/mbed/AnalogIn.h"

using namespace leka;

CoreBattery corebattery(PinName::BATTERY_VOLTAGE);

float test_set_Voltage(float value)
{
spy_AnalogIn_setValue(value);
return value;
}

TEST(CoreBatteryTest, initialization)
{
ASSERT_NE(&corebattery, nullptr);
}

TEST(CoreBatteryTest, readMinVoltage)
{
auto expected = test_set_Voltage(0.0f);

ASSERT_EQ(expected, corebattery.readVoltage());
}

TEST(CoreBatteryTest, readMiddleVoltage)
{
auto expected = test_set_Voltage(0.25f);

ASSERT_EQ(expected, corebattery.readVoltage());
}

TEST(CoreBatteryTest, readMaxVoltage)
{
auto expected = test_set_Voltage(1.0f);

ASSERT_EQ(expected, corebattery.readVoltage());
}
44 changes: 0 additions & 44 deletions drivers/LKCoreBattery/tests/LKCoreBattery_test.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion spikes/lk_sensors_battery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ target_sources(spike_lk_sensors_battery

target_link_libraries(spike_lk_sensors_battery
FileManager
LKCoreBattery
CoreBattery
CoreMotor
)

Expand Down
4 changes: 2 additions & 2 deletions spikes/lk_sensors_battery/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include "rtos/ThisThread.h"
#include "rtos/Thread.h"

#include "CoreBattery.h"
#include "CoreMotor.h"
#include "FATFileSystem.h"
#include "HelloWorld.h"
#include "LKCoreBattery.h"
#include "LogKit.h"
#include "SDBlockDevice.h"
#include "Utils.h"
Expand All @@ -38,7 +38,7 @@ auto main() -> int
HelloWorld hello;
hello.start();

auto battery = LKCoreBattery {PinName::BATTERY_VOLTAGE};
auto battery = CoreBattery {PinName::BATTERY_VOLTAGE};

auto battery_thread = rtos::Thread {};
auto battery_lambda = [&battery] {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ leka_register_unit_tests_for_driver(LKCoreSTM32Hal)
leka_register_unit_tests_for_driver(LKCoreVideo)
leka_register_unit_tests_for_driver(LKCoreLightSensor)
leka_register_unit_tests_for_driver(LKCoreMicrophone)
leka_register_unit_tests_for_driver(LKCoreBattery)
leka_register_unit_tests_for_driver(CoreBattery)

leka_register_unit_tests_for_driver(CoreHTS)
leka_register_unit_tests_for_driver(CoreI2C)
Expand Down

0 comments on commit e392e10

Please sign in to comment.