Skip to content

Commit e958132

Browse files
Micro refactoring
1 parent fec3fc1 commit e958132

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

src/drivers/input/gpio_input_driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace xbot::driver::input {
1111

1212
bool GpioInputDriver::OnInputConfigValue(lwjson_stream_parser_t* jsp, const char* key, lwjson_stream_type_t type,
1313
Input& input) {
14-
auto& gpio_input = reinterpret_cast<GpioInput&>(input);
14+
auto& gpio_input = static_cast<GpioInput&>(input);
1515
if (strcmp(key, "line") == 0) {
1616
JsonExpectType(STRING);
1717
gpio_input.line = GetIoLineByName(jsp->data.str.buff);

src/drivers/input/input_driver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct Input {
2424
bool Update(bool new_active);
2525

2626
uint32_t ActiveDuration() const {
27-
return service::system::getTimeMicros() - active_since;
27+
return xbot::service::system::getTimeMicros() - active_since;
2828
}
2929

3030
private:

src/drivers/input/worx_input_driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static const etl::flat_map<etl::string<13>, uint8_t, 8> INPUT_BITS = {
2727

2828
bool WorxInputDriver::OnInputConfigValue(lwjson_stream_parser_t* jsp, const char* key, lwjson_stream_type_t type,
2929
Input& input) {
30-
auto& worx_input = reinterpret_cast<WorxInput&>(input);
30+
auto& worx_input = static_cast<WorxInput&>(input);
3131
if (strcmp(key, "id") == 0) {
3232
JsonExpectType(STRING);
3333
decltype(INPUT_BITS)::key_type input_id{jsp->data.str.buff};

src/services/input_service/input_service.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ void InputService::OnInputChanged(Input& input) {
190190

191191
void InputService::OnSimulatedInputsChanged([[maybe_unused]] const uint64_t& new_value) {
192192
#ifdef DEBUG_BUILD
193-
if (auto* simulated_driver = dynamic_cast<SimulatedInputDriver*>(drivers_.find("simulated")->second)) {
194-
simulated_driver->SetActiveInputs(new_value);
195-
}
193+
auto* simulated_driver = static_cast<SimulatedInputDriver*>(drivers_.find("simulated")->second);
194+
simulated_driver->SetActiveInputs(new_value);
196195
#endif
197196
}

src/services/input_service/input_service.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class InputService : public InputServiceBase {
2424
drivers_.emplace(id, driver);
2525
}
2626

27-
[[nodiscard]] const etl::ivector<Input*>& GetAllInputs() const {
27+
const etl::ivector<Input*>& GetAllInputs() const {
2828
return all_inputs_;
2929
}
3030

0 commit comments

Comments
 (0)