Skip to content

Commit

Permalink
Merge pull request #36 from fablab-bergamo/lib-update
Browse files Browse the repository at this point in the history
Dependencies update, small c++ improvements
  • Loading branch information
PBrunot authored Jul 21, 2024
2 parents dcb8eac + 5586f17 commit e6034b5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
22 changes: 15 additions & 7 deletions include/PinsConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,28 @@ namespace fabomatic
pins.led.blue_pin,
pins.buttons.factory_defaults_pin};

// No constexpr std::sort available
for (auto i = 0; i < pin_nums.size(); ++i)
// C++20 provides constexpr sorting
std::sort(pin_nums.begin(), pin_nums.end());

uint8_t previous = NO_PIN;
for (const auto pin : pin_nums)
{
if (pin_nums[i] == NO_PIN)
if (pin == NO_PIN)
{
continue;
}

for (auto j = i + 1; j < pin_nums.size(); ++j)
if (pin == previous)
{
if (pin_nums[i] == pin_nums[j])
return false;
return false;
}

previous = pin;

// Check pins numbers are convertible to gpio_num_t
static_cast<gpio_num_t>(pin_nums[i]);
[[maybe_unused]] auto test = static_cast<gpio_num_t>(pin);
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion include/SavedConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace fabomatic
[[nodiscard]] static auto DefaultConfig() -> SavedConfig;

/// @brief Increments the boot count and saves it to EEPROM
static auto IncrementBootCount() -> size_t;
[[maybe_unused]] static auto IncrementBootCount() -> size_t;
};

} // namespace fabomatic
Expand Down
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ monitor_filters = esp32_exception_decoder
colorize
lib_ldf_mode = deep
lib_deps = https://github.com/PBrunot/LiquidCrystal.git#use_const
https://github.com/bblanchon/ArduinoJson.git#v7.0.4
https://github.com/bblanchon/ArduinoJson.git#v7.1.0
256dpi/MQTT
https://github.com/OSSLibraries/Arduino_MFRC522v2.git#2.0.4
Wire
adafruit/Adafruit NeoPixel@^1.12.2
adafruit/Adafruit NeoPixel@^1.12.3
https://github.com/tzapu/WiFiManager.git@2.0.17
https://github.com/terrorsl/sMQTTBroker.git
ArduinoOTA
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void setup()
auto hw_init = logic.configure(rfid, lcd);
hw_init &= logic.initBoard();

const auto count = fabomatic::SavedConfig::IncrementBootCount();
[[maybe_unused]] const auto count = fabomatic::SavedConfig::IncrementBootCount();
ESP_LOGI(TAG, "Boot count: %d, reset reason: %d", count, esp_reset_reason());

logic.changeStatus(Status::Booting);
Expand Down
8 changes: 4 additions & 4 deletions src/mock/MockMQTTBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace fabomatic
case NewClient_sMQTTEventType:
{
// Handle new client connection event
auto *e = static_cast<sMQTTNewClientEvent *>(event);
[[maybe_unused]] auto *e = static_cast<sMQTTNewClientEvent *>(event);
ESP_LOGD(TAG2, "MQTT BROKER: client connected, id:%s", e->Client()->getClientId().c_str());
}
break;
Expand All @@ -69,7 +69,7 @@ namespace fabomatic
case RemoveClient_sMQTTEventType:
{
// Handle client removal event
auto *e = static_cast<sMQTTRemoveClientEvent *>(event);
[[maybe_unused]] auto *e = static_cast<sMQTTRemoveClientEvent *>(event);
ESP_LOGD(TAG2, "MQTT BROKER: removed client id: %s", e->Client()->getClientId().c_str());
}
break;
Expand All @@ -83,14 +83,14 @@ namespace fabomatic
case Subscribe_sMQTTEventType:
{
// Handle subscription event
auto *e = static_cast<sMQTTSubUnSubClientEvent *>(event);
[[maybe_unused]] auto *e = static_cast<sMQTTSubUnSubClientEvent *>(event);
ESP_LOGD(TAG2, "MQTT BROKER: client %s subscribed to %s", e->Client()->getClientId().c_str(), e->Topic().c_str());
}
break;
case UnSubscribe_sMQTTEventType:
{
// Handle unsubscription event
auto *e = static_cast<sMQTTSubUnSubClientEvent *>(event);
[[maybe_unused]] auto *e = static_cast<sMQTTSubUnSubClientEvent *>(event);
ESP_LOGD(TAG2, "MQTT BROKER: got unsubscribe from %s", e->Topic().c_str());
}
break;
Expand Down

0 comments on commit e6034b5

Please sign in to comment.