2024-01-25 14:29:08 +01:00

85 lines
2.2 KiB
C++

#ifndef T_IOT_901_CONVOYOR_M5LCD_H
#define T_IOT_901_CONVOYOR_M5LCD_H
#include <vector>
#include <ctime>
#include "M5Stack.h"
#define LCD_PAGES 3
#define DASHBOARD_SCREEN 0
#define DEBUG_SCREEN 1
#define CONFIG_SCREEN 2
enum AvailableComponentsStatus {
COMPONENT_OK,
COMPONENT_KO,
COMPONENT_MISSING,
UNKNOWN_ERROR,
};
typedef struct ComponentsStatus {
AvailableComponentsStatus nfc;
AvailableComponentsStatus wifi;
AvailableComponentsStatus dolibarr;
AvailableComponentsStatus servo;
AvailableComponentsStatus grbl;
} ComponentsStatus;
typedef struct MessageToShow {
const char* message;
int color;
} MessageToShow;
class LogMessage {
public:
LogMessage(std::string log);
std::string get_message() const;
const char* get_datetime_format() const;
private:
time_t datetime;
std::string log;
};
class M5LCD {
public:
M5LCD();
void display_message(const char* str) const;
void display_error(const char* str) const;
void display_warning(const char* str) const;
void add_log(const char *str);
void update();
ComponentsStatus get_components();
void set_wifi_status(AvailableComponentsStatus status);
void set_nfc_status(AvailableComponentsStatus status);
void set_grbl_status(AvailableComponentsStatus status);
void set_servo(AvailableComponentsStatus status);
void set_dolibarr_status(AvailableComponentsStatus status);
void set_nfc_message(std::string str);
void set_dolibarr_message(std::string str);
void set_product_label(std::string str);
void set_product_id(std::string str);
void set_servo_message(std::string str);
private:
void update_page() const;
void show_debug() const;
void show_dashboard() const;
void show_config() const;
void update_pagination() const;
void update_dashboard() const;
int _current_page;
int _debug_loc_y;
std::vector<LogMessage> _logs;
ComponentsStatus _components_status;
std::string _last_nfc;
std::string _product_label;
std::string _product_id;
std::string _dolibarr_msg;
std::string _servo_current_position;
};
inline M5LCD *lcdScreen;
#endif //T_IOT_901_CONVOYOR_M5LCD_H