Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change compile settings #35

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/Machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "FabUser.hpp"
#include "MachineConfig.hpp"
#include "Tasks.hpp"

#include <array>
#include <chrono>
#include <cstdint>
Expand Down Expand Up @@ -107,8 +109,8 @@ namespace fabomatic
bool active{false};
FabUser current_user{};

std::optional<std::chrono::steady_clock::time_point> usage_start_timestamp{std::nullopt}; // When did the machine start?
std::optional<std::chrono::steady_clock::time_point> logoff_timestamp{std::nullopt}; // When did the last user log off?
std::optional<Tasks::time_point> usage_start_timestamp{std::nullopt}; // When did the machine start?
std::optional<Tasks::time_point> logoff_timestamp{std::nullopt}; // When did the last user log off?
PowerState power_state{PowerState::PoweredOff};

/// @brief If true, machine needs maintenance
Expand Down
10 changes: 6 additions & 4 deletions include/Tasks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace fabomatic::Tasks
using milliseconds = std::chrono::milliseconds;
using namespace std::chrono_literals;

[[nodiscard]] inline auto arduinoNow() -> const std::chrono::steady_clock::time_point
typedef std::chrono::steady_clock::time_point time_point;

[[nodiscard]] inline auto arduinoNow() -> const time_point
{
return std::chrono::steady_clock::now();
}
Expand Down Expand Up @@ -93,7 +95,7 @@ namespace fabomatic::Tasks

/// @brief When shall the task be run again
/// @return time_point of the next run or time_point::max() if the task will not run.
[[nodiscard]] auto getNextRun() const -> const std::chrono::steady_clock::time_point;
[[nodiscard]] auto getNextRun() const -> const Tasks::time_point &;

[[nodiscard]] auto toString() const -> const std::string;

Expand All @@ -102,8 +104,8 @@ namespace fabomatic::Tasks
const std::string id;
milliseconds period;
milliseconds delay;
std::chrono::steady_clock::time_point last_run;
std::chrono::steady_clock::time_point next_run;
Tasks::time_point last_run;
Tasks::time_point next_run;
milliseconds average_tardiness;
milliseconds total_runtime;
std::function<void()> callback;
Expand Down
3 changes: 2 additions & 1 deletion include/mock/MockMrfc522.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "MFRC522DriverPinSimple.h"
#include "MFRC522DriverSPI.h"
#include "MFRC522v2.h"
#include "Tasks.hpp"

namespace fabomatic
{
Expand All @@ -19,7 +20,7 @@ namespace fabomatic
{
private:
std::optional<card::uid_t> uid{std::nullopt};
std::optional<std::chrono::steady_clock::time_point> stop_uid_simulate_time{std::nullopt};
std::optional<Tasks::time_point> stop_uid_simulate_time{std::nullopt};
std::optional<card::uid_t> getSimulatedUid() const;

public:
Expand Down
5 changes: 1 addition & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ lib_deps = https://github.com/PBrunot/LiquidCrystal.git#use_const
ArduinoOTA
build_unflags = -std=gnu++11 -fexceptions
build_flags = -std=gnu++2b
-ffunction-sections
-fdata-sections
-g3
-fno-exceptions
-Os
-I conf
-Wno-deprecated-declarations
Expand All @@ -49,7 +46,7 @@ build_src_flags = -Wformat=2
-Wformat-truncation
-Wall
-Wextra
-Wl,-Map,firmware.map,--cref,--no-warn-rwx-segments
-Wl,-Map,firmware.map,--cref
-Wstack-usage=2048
-D LOG_LOCAL_LEVEL=ESP_LOG_VERBOSE
-D FABOMATIC_BUILD="\"$PIOENV\""
Expand Down
11 changes: 5 additions & 6 deletions src/Tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,12 @@ namespace fabomatic::Tasks
{
std::stringstream ss;
ss << "Task " << getId() << ", active=" << active
<< ",Period=" << period << ", Delay=" << delay
<< ",Period(ms)=" << period << ", Delay(ms)=" << delay
<< ",Last run=" << last_run.time_since_epoch()
<< ",Next_run=" << next_run.time_since_epoch()
<< ",Avg tardiness=" << average_tardiness
<< ",total_runtime " << total_runtime
<< ",run_counter=" << run_counter
<< ",clock=" << millis();
<< ",Avg tardiness (ms)=" << average_tardiness
<< ",total_runtime (ms)= " << total_runtime
<< ",run_counter=" << run_counter;
return ss.str();
}

Expand Down Expand Up @@ -256,7 +255,7 @@ namespace fabomatic::Tasks
return total_runtime;
}

auto Task::getNextRun() const -> const std::chrono::steady_clock::time_point
auto Task::getNextRun() const -> const Tasks::time_point &
{
return next_run;
}
Expand Down