Skip to content

Commit

Permalink
Show infos at startup like project name, version and compile date, co…
Browse files Browse the repository at this point in the history
…nnecting to wifi and waiting for time sync
  • Loading branch information
MG-5 committed Jan 13, 2023
1 parent e81c070 commit fb4c313
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 6 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions main/Application.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
73 changes: 70 additions & 3 deletions main/led/RenderTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "helpers/freertos.hpp"

#include "esp_log.h"
#include "esp_ota_ops.h"

void RenderTask::taskMain(void *)
{
Expand All @@ -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;
Expand Down Expand Up @@ -87,4 +115,43 @@ void RenderTask::renderVehicles(bool showCurrentVehicle)

pageCounter++;
}
}
}

//--------------------------------------------------------------------------------------------------
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());
}
23 changes: 20 additions & 3 deletions main/led/RenderTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

0 comments on commit fb4c313

Please sign in to comment.