Skip to content

Commit

Permalink
UI abstraction cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NachtRaveVL authored and NachtRaveVL committed Mar 5, 2023
1 parent dc83475 commit 350835f
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 59 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ Included below is the default system setup defines of the Dual-Axis Tracking exa
#define SETUP_SD_CARD_SPI_CS -1 // SD card CS pin, else -1
#define SETUP_SD_CARD_SPI_SPEED F_SPD // SD card SPI speed, in Hz (ignored on Teensy)
#define SETUP_LCD_I2C_ADDR 0b000 // LCD i2c address
#define SETUP_CTRL_INPUT_PINS {(pintype_t)-1} // Control input pin ribbon, else {-1}
#define SETUP_CTRL_INPUT_PINS {(pintype_t)-1} // Control input pins, else {-1}
#define SETUP_I2C_WIRE Wire // I2C wire class instance
#define SETUP_I2C_SPEED 400000U // I2C speed, in Hz
#define SETUP_ESP_I2C_SDA SDA // I2C SDA pin, if on ESP
Expand Down Expand Up @@ -382,9 +382,9 @@ Included below is the default system setup defines of the Dual-Axis Tracking exa
#define SETUP_SYS_NAME "Helioduino" // System name
#define SETUP_SYS_TIMEZONE +0 // System timezone offset
#define SETUP_SYS_LOGLEVEL All // System log level filter (All, Warnings, Errors, None)
#define SETUP_SYS_STATIC_LAT DBL_UNDEF // System static latitude (if not using GPS, else DBL_UNDEF), in degrees
#define SETUP_SYS_STATIC_LONG DBL_UNDEF // System static longitude (if not using GPS, else DBL_UNDEF), in minutes
#define SETUP_SYS_STATIC_ALT DBL_UNDEF // System static altitude (if not using GPS, else DBL_UNDEF), in meters above sea level (msl)
#define SETUP_SYS_STATIC_LAT DBL_UNDEF // System static latitude (if not using GPS/UI, else DBL_UNDEF), in degrees
#define SETUP_SYS_STATIC_LONG DBL_UNDEF // System static longitude (if not using GPS/UI, else DBL_UNDEF), in minutes
#define SETUP_SYS_STATIC_ALT DBL_UNDEF // System static altitude (if not using GPS/UI, else DBL_UNDEF), in meters above sea level (msl)
// System Saves Settings (note: only one primary and one fallback mechanism may be enabled at a time)
#define SETUP_SAVES_CONFIG_FILE "helioduino.cfg" // System config file name for system saves
Expand Down
10 changes: 4 additions & 6 deletions examples/DATracking/DATracking.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SoftwareSerial SWSerial(RX, TX); // Replace with Rx/Tx pi
#define SETUP_SD_CARD_SPI_CS -1 // SD card CS pin, else -1
#define SETUP_SD_CARD_SPI_SPEED F_SPD // SD card SPI speed, in Hz (ignored on Teensy)
#define SETUP_LCD_I2C_ADDR 0b000 // LCD i2c address
#define SETUP_CTRL_INPUT_PINS {(pintype_t)-1} // Control input pin ribbon, else {-1}
#define SETUP_CTRL_INPUT_PINS {(pintype_t)-1} // Control input pins, else {-1}
#define SETUP_I2C_WIRE Wire // I2C wire class instance
#define SETUP_I2C_SPEED 400000U // I2C speed, in Hz
#define SETUP_ESP_I2C_SDA SDA // I2C SDA pin, if on ESP
Expand Down Expand Up @@ -56,9 +56,9 @@ SoftwareSerial SWSerial(RX, TX); // Replace with Rx/Tx pi
#define SETUP_SYS_NAME "Helioduino" // System name
#define SETUP_SYS_TIMEZONE +0 // System timezone offset
#define SETUP_SYS_LOGLEVEL All // System log level filter (All, Warnings, Errors, None)
#define SETUP_SYS_STATIC_LAT DBL_UNDEF // System static latitude (if not using GPS, else DBL_UNDEF), in degrees
#define SETUP_SYS_STATIC_LONG DBL_UNDEF // System static longitude (if not using GPS, else DBL_UNDEF), in minutes
#define SETUP_SYS_STATIC_ALT DBL_UNDEF // System static altitude (if not using GPS, else DBL_UNDEF), in meters above sea level (msl)
#define SETUP_SYS_STATIC_LAT DBL_UNDEF // System static latitude (if not using GPS/UI, else DBL_UNDEF), in degrees
#define SETUP_SYS_STATIC_LONG DBL_UNDEF // System static longitude (if not using GPS/UI, else DBL_UNDEF), in minutes
#define SETUP_SYS_STATIC_ALT DBL_UNDEF // System static altitude (if not using GPS/UI, else DBL_UNDEF), in meters above sea level (msl)

// System Saves Settings (note: only one primary and one fallback mechanism may be enabled at a time)
#define SETUP_SAVES_CONFIG_FILE "helioduino.cfg" // System config file name for system saves
Expand Down Expand Up @@ -171,10 +171,8 @@ MQTTClient mqttClient;
#if defined(HELIO_USE_GUI) && SETUP_DISPLAY_OUT_MODE != Disabled
#if SETUP_SYS_UI_MODE == Minimal
#include "min/HelioduinoUI.h"
typedef HelioduinoMinUI HelioduinoUI;
#elif SETUP_SYS_UI_MODE == Full
#include "full/HelioduinoUI.h"
typedef HelioduinoFullUI HelioduinoUI;
#endif
#endif

Expand Down
8 changes: 4 additions & 4 deletions examples/FullSystem/FullSystem.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SoftwareSerial SWSerial(RX, TX); // Replace with Rx/Tx pi
#define SETUP_SD_CARD_SPI_CS -1 // SD card CS pin, else -1
#define SETUP_SD_CARD_SPI_SPEED F_SPD // SD card SPI speed, in Hz (ignored on Teensy)
#define SETUP_LCD_I2C_ADDR 0b000 // LCD i2c address
#define SETUP_CTRL_INPUT_PINS {(pintype_t)-1} // Control input pin ribbon, else {-1}
#define SETUP_CTRL_INPUT_PINS {(pintype_t)-1} // Control input pins, else {-1}
#define SETUP_I2C_WIRE Wire // I2C wire class instance
#define SETUP_I2C_SPEED 400000U // I2C speed, in Hz
#define SETUP_ESP_I2C_SDA SDA // I2C SDA pin, if on ESP
Expand Down Expand Up @@ -63,9 +63,9 @@ SoftwareSerial SWSerial(RX, TX); // Replace with Rx/Tx pi
#define SETUP_SYS_NAME "Helioduino" // System name
#define SETUP_SYS_TIMEZONE +0 // System timezone offset
#define SETUP_SYS_LOGLEVEL All // System log level filter (All, Warnings, Errors, None)
#define SETUP_SYS_STATIC_LAT DBL_UNDEF // System static latitude (if not using GPS, else DBL_UNDEF), in degrees
#define SETUP_SYS_STATIC_LONG DBL_UNDEF // System static longitude (if not using GPS, else DBL_UNDEF), in minutes
#define SETUP_SYS_STATIC_ALT DBL_UNDEF // System static altitude (if not using GPS, else DBL_UNDEF), in meters above sea level (msl)
#define SETUP_SYS_STATIC_LAT DBL_UNDEF // System static latitude (if not using GPS/UI, else DBL_UNDEF), in degrees
#define SETUP_SYS_STATIC_LONG DBL_UNDEF // System static longitude (if not using GPS/UI, else DBL_UNDEF), in minutes
#define SETUP_SYS_STATIC_ALT DBL_UNDEF // System static altitude (if not using GPS/UI, else DBL_UNDEF), in meters above sea level (msl)

// System Saves Settings (note: only one primary and one fallback mechanism may be enabled at a time)
#define SETUP_SAVES_CONFIG_FILE "helioduino.cfg" // System config file name for system saves
Expand Down
4 changes: 2 additions & 2 deletions src/HelioInterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
struct HelioJSONSerializableInterface;

class HelioObjInterface;
class HelioduinoUIInterface;
class HelioUIInterface;
class HelioRTCInterface;

struct HelioDigitalInputPinInterface;
Expand Down Expand Up @@ -83,7 +83,7 @@ class HelioObjInterface {
};

// UI Interface
class HelioduinoUIInterface {
class HelioUIInterface {
public:
virtual bool begin() = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/HelioUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ inline HelioLogger *getLogger();
inline HelioPublisher *getPublisher();
#ifdef HELIO_USE_GUI
// Returns the active UI instance. Not guaranteed to be non-null.
inline HelioduinoUIInterface *getUI();
inline HelioUIInterface *getUI();
#endif

// Publishes latest data from sensor to Publisher output.
Expand Down
2 changes: 1 addition & 1 deletion src/HelioUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ inline HelioPublisher *getPublisher()

#ifdef HELIO_USE_GUI

inline HelioduinoUIInterface *getUI()
inline HelioUIInterface *getUI()
{
return Helioduino::_activeInstance ? Helioduino::_activeInstance->_activeUIInstance : nullptr;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Helioduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ class Helioduino : public HelioFactory, public HelioCalibrations, public HelioOb

#ifdef HELIO_USE_GUI
// Enables UI to run with passed instance.
// Minimal UI only allows the user to edit existing objects, not create nor delete them.
// Full UI allows the user to add/remove system objects, customize features, change settings, etc.
// Minimal/RO UI only allows the user to edit existing objects, not create nor delete them.
// Full/RW UI allows the user to add/remove system objects, customize features, change settings, etc.
// Note: Be sure to manually include the appropriate UI system header file (e.g. #include "min/HelioduinoUI.h") in Arduino sketch.
inline bool enableUI(HelioduinoUIInterface *ui) { _activeUIInstance = ui; return ui->begin(); }
inline bool enableUI(HelioUIInterface *ui) { _activeUIInstance = ui; return ui->begin(); }
#endif

// Mutators.
Expand Down Expand Up @@ -482,7 +482,7 @@ class Helioduino : public HelioFactory, public HelioCalibrations, public HelioOb
protected:
static Helioduino *_activeInstance; // Current active instance (set after init, weak)
#ifdef HELIO_USE_GUI
HelioduinoUIInterface *_activeUIInstance; // Current active UI instance (owned)
HelioUIInterface *_activeUIInstance; // Current active UI instance (owned)
#endif
HelioSystemData *_systemData; // System data (owned, saved to storage)

Expand Down Expand Up @@ -565,7 +565,7 @@ class Helioduino : public HelioFactory, public HelioCalibrations, public HelioOb
friend HelioLogger *::getLogger();
friend HelioPublisher *::getPublisher();
#ifdef HELIO_USE_GUI
friend HelioduinoUIInterface *::getUI();
friend HelioUIInterface *::getUI();
#endif
friend class HelioCalibrations;
friend class HelioScheduler;
Expand Down
10 changes: 1 addition & 9 deletions src/full/HelioduinoUI.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
/* Helioduino: Simple automation controller for solar tracking systems.
Copyright (C) 2023 NachtRaveVL <[email protected]>
Helioduino Full UI
Helioduino Full/RW UI
*/

#include "Helioduino.h"
#include "HelioduinoUI.h"

bool HelioFullUI::begin()
{
return false;
}

void HelioFullUI::setNeedsLayout()
{ }
22 changes: 13 additions & 9 deletions src/full/HelioduinoUI.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
/* Helioduino: Simple automation controller for solar tracking systems.
Copyright (C) 2023 NachtRaveVL <[email protected]>
Helioduino Full UI
Helioduino Full/RW UI
*/

class HelioFullUI;
#include <Helioduino.h>
#ifdef HELIO_USE_GUI
#ifndef HelioUI_H
#define HelioUI_H

#include "Helioduino.h"
class HelioduinoFullUI;
typedef HelioduinoFullUI HydruinoUI;

class HelioFullUI : HelioduinoUIInterface {
public:
virtual bool begin() override;

virtual void setNeedsLayout() override;
#include "..\shared\HelioduinoUI.h"

protected:
class HelioduinoFullUI : public HelioduinoBaseUI {
public:
};

#endif // /ifndef HelioUI_H
#endif
10 changes: 1 addition & 9 deletions src/min/HelioduinoUI.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
/* Helioduino: Simple automation controller for solar tracking systems.
Copyright (C) 2023 NachtRaveVL <[email protected]>
Helioduino Minimal UI
Helioduino Minimal/RO UI
*/

#include "Helioduino.h"
#include "HelioduinoUI.h"

bool HelioMinUI::begin()
{
return false;
}

void HelioMinUI::setNeedsLayout()
{ }
22 changes: 13 additions & 9 deletions src/min/HelioduinoUI.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
/* Helioduino: Simple automation controller for solar tracking systems.
Copyright (C) 2023 NachtRaveVL <[email protected]>
Helioduino Minimal UI
Helioduino Minimal/RO UI
*/

class HelioMinUI;
#include <Helioduino.h>
#ifdef HELIO_USE_GUI
#ifndef HelioUI_H
#define HelioUI_H

#include "Helioduino.h"
class HelioduinoMinUI;
typedef HelioduinoMinUI HydruinoUI;

class HelioMinUI : HelioduinoUIInterface {
public:
virtual bool begin() override;

virtual void setNeedsLayout() override;
#include "..\shared\HelioduinoUI.h"

protected:
class HelioduinoMinUI : public HelioduinoBaseUI {
public:
};

#endif // /ifndef HelioUI_H
#endif
15 changes: 15 additions & 0 deletions src/shared/HelioduinoUI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Helioduino: Simple automation controller for solar tracking systems.
Copyright (C) 2023 NachtRaveVL <[email protected]>
Helioduino Base UI
*/

#include "Helioduino.h"
#include "HelioduinoUI.h"

bool HelioduinoBaseUI::begin()
{
return false;
}

void HelioduinoBaseUI::setNeedsLayout()
{ }
21 changes: 21 additions & 0 deletions src/shared/HelioduinoUI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* Helioduino: Simple automation controller for solar tracking systems.
Copyright (C) 2023 NachtRaveVL <[email protected]>
Helioduino Base UI
*/

#include <Helioduino.h>
#ifdef HELIO_USE_GUI
#ifndef HelioBaseUI_H
#define HelioBaseUI_H

class HelioduinoBaseUI : public HelioUIInterface {
public:
virtual bool begin() override;

virtual void setNeedsLayout() override;

protected:
};

#endif // /ifndef HelioBaseUI_H
#endif

0 comments on commit 350835f

Please sign in to comment.