diff --git a/.clang-tidy b/.clang-tidy index 72475fb..105f7bd 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -4,6 +4,7 @@ Checks: abseil-*, bugprone-*, -bugprone-bool-pointer-implicit-conversion, + -bugprone-branch-clone -bugprone-exception-escape, -bugprone-infinite-loop, -bugprone-signed-char-misuse, diff --git a/main/Application.cxx b/main/Application.cxx index e35a4d6..e33173e 100644 --- a/main/Application.cxx +++ b/main/Application.cxx @@ -34,10 +34,12 @@ void Application::run() Task::applicationIsReadyStartAllTasks(); sync::waitForAll(sync::ConnectedToWifi); + renderTask.setState(RenderTask::State::WaitForTimesyncronization); Timebase::initTimeSychronization(); resetTimer(); sync::waitForAll(sync::TimeIsSynchronized); + renderTask.setState(RenderTask::State::ShowVehicles); stopTimer(); while (true) diff --git a/main/led/RenderTask.cxx b/main/led/RenderTask.cxx index be330c3..7980264 100644 --- a/main/led/RenderTask.cxx +++ b/main/led/RenderTask.cxx @@ -3,6 +3,7 @@ #include "helpers/freertos.hpp" #include "esp_log.h" +#include "esp_ota_ops.h" void RenderTask::taskMain(void *) { @@ -14,8 +15,35 @@ void RenderTask::taskMain(void *) while (true) { clearDisplayRam(); - renderTitleBar(blinkState); - renderVehicles(blinkState); + + switch (state) + { + case State::InitializingWifi: + renderProjectInfos(); + renderConnectingToWifi(); + break; + + case State::WaitForTimesyncronization: + renderProjectInfos(); + renderTimesyncronization(); + break; + + case State::ShowVehicles: + case State::ShowVehiclesWithRunningText: + renderTitleBar(blinkState); + renderVehicles(blinkState); + break; + + case State::ShowFreeText: + // Todo: + renderer.print({0, 0}, "free text mode 1"); + renderer.print({0, 1}, "free text mode 2"); + renderer.print({0, 2}, "free text mode 3"); + renderer.print({0, 3}, "free text mode 4"); + renderer.print({0, 4}, "free text mode 5"); + break; + } + renderer.render(); blinkState = !blinkState; @@ -87,4 +115,43 @@ void RenderTask::renderVehicles(bool showCurrentVehicle) pageCounter++; } -} \ No newline at end of file +} + +//-------------------------------------------------------------------------------------------------- +void RenderTask::renderProjectInfos() +{ + const esp_app_desc_t *appDesc = esp_ota_get_app_description(); + + snprintf(printBuffer, PrintBufferSize, "%s (%s)", appDesc->project_name, appDesc->version); + renderer.print({0, 0}, printBuffer); + renderer.print({0, 1}, appDesc->date); + renderer.print({0, 2}, "by M. Grau und T. Wiesner"); +} + +//-------------------------------------------------------------------------------------------------- +void RenderTask::renderConnectingToWifi() +{ + std::string textToPrint = " Mit WLAN verbinden "; + + if (dotCounter++ >= NumberOfDots) + dotCounter = 1; + + for (size_t i = 0; i < dotCounter; i++) + textToPrint += "."; + + renderer.print({0, LedControl::Strips - 1}, textToPrint.data()); +} + +//-------------------------------------------------------------------------------------------------- +void RenderTask::renderTimesyncronization() +{ + std::string textToPrint = " Zeitsyncronisation "; + + if (dotCounter++ >= NumberOfDots) + dotCounter = 1; + + for (size_t i = 0; i < dotCounter; i++) + textToPrint += "."; + + renderer.print({0, LedControl::Strips - 1}, textToPrint.data()); +} diff --git a/main/led/RenderTask.hpp b/main/led/RenderTask.hpp index d460177..3fdc12c 100644 --- a/main/led/RenderTask.hpp +++ b/main/led/RenderTask.hpp @@ -18,26 +18,43 @@ class RenderTask : public util::wrappers::TaskWithMemberFunctionBase enum class State { InitializingWifi, - WaitForTimesycronization, - NoWifiConnection + WaitForTimesyncronization, + ShowVehicles, + ShowVehiclesWithRunningText, + ShowFreeText }; + void setState(State newState) + { + state = newState; + } + + State getState() const + { + return state; + } + protected: void taskMain(void *) override; private: static constexpr auto PrintTag = "[RenderTask]"; + static constexpr auto NumberOfDots = 5; Dfi &dfi; LedControl &ledControl; Renderer renderer{LedControl::Columns, LedControl::Strips, ledControl}; State state = State::InitializingWifi; + uint8_t dotCounter = 1; - static constexpr auto PrintBufferSize = 32; + static constexpr auto PrintBufferSize = 72; char printBuffer[PrintBufferSize]{}; void clearDisplayRam(); void renderTitleBar(bool showDoublePoint); void renderVehicles(bool showCurrentVehicle); + void renderProjectInfos(); + void renderConnectingToWifi(); + void renderTimesyncronization(); };