Orbs screen saver - Matrix rain style #239

Closed
nconner-06 wants to merge 5 commits from Orbs-ScreenSaver into dev
nconner-06 commented 2025-02-21 20:15:33 +00:00 (Migrated from github.com)

A small widget to provide a 'Matrix' style rain effect..

I think I've included everything..

Enjoy.

A small widget to provide a 'Matrix' style rain effect.. I think I've included everything.. Enjoy.
nconner-06 commented 2025-02-22 12:06:24 +00:00 (Migrated from github.com)

I've corrected the small error - lower case "w" :-(

I've corrected the small error - lower case "w" :-(
flattermann commented 2025-02-26 11:07:24 +00:00 (Migrated from github.com)

Thank you for your contribution!

I'll to review the code soon, but here are some general thoughts that came to mind:

I think the Widget should be called MatrixWidget or similar, not ScreenSaverWidget, because it's just a normal Widget and not really a screensaver.

Also, if we were to implement a screensaver mechanic, I think it would be best, if the user could configure a Widget of his choice that will be displayed after a timeout.

Thank you for your contribution! I'll to review the code soon, but here are some general thoughts that came to mind: I think the Widget should be called MatrixWidget or similar, not ScreenSaverWidget, because it's just a normal Widget and not really a screensaver. Also, if we were to implement a screensaver mechanic, I think it would be best, if the user could configure a Widget of his choice that will be displayed after a timeout.
flattermann (Migrated from github.com) requested changes 2025-02-26 11:28:29 +00:00
flattermann (Migrated from github.com) left a comment

Please also make sure to use the same naming/formatting schema like the rest of the code base:

  • directory names should be lower case (e.g. widgets/screensaverwidget or widgets/matrixwidget)
  • classes and their files should be upper/camel case, Widget should be written with a capital W, e.g. ScreenSaverWidget or MatrixWidget)
  • please format the files using the file .clang-format in the repo (this will be done automatically if you open the info-orbs.code-workspace in VSCode)
Please also make sure to use the same naming/formatting schema like the rest of the code base: - **directory** names should be lower case (e.g. `widgets/screensaverwidget` or `widgets/matrixwidget`) - **classes** and **their files** should be upper/camel case, Widget should be written with a capital W, e.g. `ScreenSaverWidget` or `MatrixWidget`) - please format the files using the file `.clang-format` in the repo (this will be done automatically if you open the `info-orbs.code-workspace` in VSCode)
@ -15,6 +15,7 @@
#define INCLUDE_PARQET // include ParqetWidget
//#define INCLUDE_WEBDATA // include WebDataWidget
//#define INCLUDE_MQTT // include MQTTWidget
#define INCLUDE_SCREENSAVER
flattermann (Migrated from github.com) commented 2025-02-26 11:08:29 +00:00

If you rename the Widget, please also rename the config name and add a comment with the actual widget name

If you rename the Widget, please also rename the config name and add a comment with the actual widget name
@ -18,6 +18,13 @@ ScreenManager::ScreenManager(TFT_eSPI &tft) : m_tft(tft) {
m_tft.fillScreen(TFT_WHITE);
m_tft.setTextDatum(MC_DATUM);
reset();
#ifdef INCLUDE_SCREENSAVER
flattermann (Migrated from github.com) commented 2025-02-26 11:09:58 +00:00

I don't think that it's a good idea to use widget specific code in ScreenManager.

The manager classes (ScreenManager, ConfigManager...) should not have knowledge of the widgets.

I don't think that it's a good idea to use widget specific code in ScreenManager. The manager classes (ScreenManager, ConfigManager...) should not have knowledge of the widgets.
@ -8,6 +8,7 @@
#include <SPI.h>
#include <TFT_eSPI.h>
#include <TJpg_Decoder.h>
#include "ScreenSaverwidget/DigitalRainAnimation.hpp"
flattermann (Migrated from github.com) commented 2025-02-26 11:10:47 +00:00

ScreenManager should not include widget headers

ScreenManager should not include widget headers
@ -10,3 +11,4 @@
#include <ArduinoLog.h>
TFT_eSPI tft = TFT_eSPI();
DigitalRainAnimation<TFT_eSPI> matrix_effect = DigitalRainAnimation<TFT_eSPI>();
flattermann (Migrated from github.com) commented 2025-02-26 11:13:31 +00:00

Why do you need to define the matrix_effect here?

main.cpp should only include widget code that's absolutely necessary, i.e. widgetSet -> add(new XXX)

Why do you need to define the `matrix_effect` here? main.cpp should only include widget code that's absolutely necessary, i.e. `widgetSet -> add(new XXX)`
@ -0,0 +1,52 @@
#include "ScreenSaverwidget.h"
ScreenSaverwidget::ScreenSaverwidget(ScreenManager &manager, ConfigManager &config) : Widget(manager, config){
m_enabled = true;
flattermann (Migrated from github.com) commented 2025-02-26 11:14:57 +00:00

Widgets should have an enable option in the WebUI, and they should be disabled by default.

Widgets should have an enable option in the WebUI, and they should be disabled by default.
@ -0,0 +12,4 @@
m_config.addConfigInt("ScreenSaverWidget", "updateInterval", &m_updateInterval, "Screen Update Interval", true);
}
void ScreenSaverwidget::addConfigToManager(){
flattermann (Migrated from github.com) commented 2025-02-26 11:16:30 +00:00

What's this function used for?

Did you want to move the m_config.addConfig*() from the constructor here?

What's this function used for? Did you want to move the `m_config.addConfig*()` from the constructor here?
@ -0,0 +20,4 @@
void addConfigToManager();
bool m_smallFont = false;
int m_textColor; // = 0x001F;
int m_headtextColor; // = 0x07FF;
flattermann (Migrated from github.com) commented 2025-02-26 11:20:45 +00:00

I would set some default values here

I would set some default values here
flattermann (Migrated from github.com) reviewed 2025-02-26 11:52:08 +00:00
@ -0,0 +2,4 @@
ScreenSaverwidget::ScreenSaverwidget(ScreenManager &manager, ConfigManager &config) : Widget(manager, config){
m_enabled = true;
m_config.addConfigBool("ScreenSaverWidget", "SmallFont", &m_smallFont, "Small font (unchecked)", false);
flattermann (Migrated from github.com) commented 2025-02-26 11:52:07 +00:00

Please add a short widget specific prefix to all config keys, e.g. "SmallFont" -> "mtxSmallFont" or similar.

FYI: The key length is limited to 15 characters if I remember correctly.

Please add a short widget specific prefix to all config keys, e.g. "SmallFont" -> "mtxSmallFont" or similar. FYI: The key length is limited to 15 characters if I remember correctly.
flattermann (Migrated from github.com) reviewed 2025-02-26 15:05:39 +00:00
@ -15,6 +15,7 @@
#define INCLUDE_PARQET // include ParqetWidget
//#define INCLUDE_WEBDATA // include WebDataWidget
//#define INCLUDE_MQTT // include MQTTWidget
#define INCLUDE_SCREENSAVER
flattermann (Migrated from github.com) commented 2025-02-26 15:05:07 +00:00

And please do not include it in default build (i.e. comment out the line)

And please do not include it in default build (i.e. comment out the line)
@ -0,0 +2,4 @@
ScreenSaverwidget::ScreenSaverwidget(ScreenManager &manager, ConfigManager &config) : Widget(manager, config){
m_enabled = true;
m_config.addConfigBool("ScreenSaverWidget", "SmallFont", &m_smallFont, "Small font (unchecked)", false);
flattermann (Migrated from github.com) commented 2025-02-26 12:08:03 +00:00

And this should probably be renamed to "Big font".

And this should probably be renamed to "Big font".
nconner-06 (Migrated from github.com) reviewed 2025-02-27 19:20:54 +00:00
@ -15,6 +15,7 @@
#define INCLUDE_PARQET // include ParqetWidget
//#define INCLUDE_WEBDATA // include WebDataWidget
//#define INCLUDE_MQTT // include MQTTWidget
#define INCLUDE_SCREENSAVER
nconner-06 (Migrated from github.com) commented 2025-02-27 19:20:54 +00:00

Hi Christian
Many thanks for all your comments and recommendations.
I'll work on updating my little widget and upload revised code as soon as I can.
I'm not an expert on OO coding so might have a few questions for you, if that's ok?
Regards
Neil

Hi Christian Many thanks for all your comments and recommendations. I'll work on updating my little widget and upload revised code as soon as I can. I'm not an expert on OO coding so might have a few questions for you, if that's ok? Regards Neil
flattermann (Migrated from github.com) reviewed 2025-02-28 18:20:17 +00:00
@ -15,6 +15,7 @@
#define INCLUDE_PARQET // include ParqetWidget
//#define INCLUDE_WEBDATA // include WebDataWidget
//#define INCLUDE_MQTT // include MQTTWidget
#define INCLUDE_SCREENSAVER
flattermann (Migrated from github.com) commented 2025-02-28 18:20:17 +00:00

Hi Neil,
Sure, I'll try my best to answer if I can!

Hi Neil, Sure, I'll try my best to answer if I can!
nconner-06 (Migrated from github.com) reviewed 2025-03-04 12:58:55 +00:00
@ -18,6 +18,13 @@ ScreenManager::ScreenManager(TFT_eSPI &tft) : m_tft(tft) {
m_tft.fillScreen(TFT_WHITE);
m_tft.setTextDatum(MC_DATUM);
reset();
#ifdef INCLUDE_SCREENSAVER
nconner-06 (Migrated from github.com) commented 2025-03-04 12:58:55 +00:00

Hi Christian

I modified the ScreenManager class because I needed access to functions in the base TFT_eSPI class which are not passed by the ScreenManager class, what is the process here?

Can I propose a change to the ScreenManager class in this PR? to make them available using the standard m_manager object.

May be someone else might need them as some point in the future...
Thanks for the clarification
Neil

Hi Christian I modified the ScreenManager class because I needed access to functions in the base TFT_eSPI class which are not passed by the ScreenManager class, what is the process here? Can I propose a change to the ScreenManager class in this PR? to make them available using the standard m_manager object. May be someone else might need them as some point in the future... Thanks for the clarification Neil
flattermann (Migrated from github.com) reviewed 2025-03-04 14:13:24 +00:00
@ -18,6 +18,13 @@ ScreenManager::ScreenManager(TFT_eSPI &tft) : m_tft(tft) {
m_tft.fillScreen(TFT_WHITE);
m_tft.setTextDatum(MC_DATUM);
reset();
#ifdef INCLUDE_SCREENSAVER
flattermann (Migrated from github.com) commented 2025-03-04 14:13:24 +00:00

I see, you need access to m_tft to pass it to DigitalRainAnimation.hpp.

Well, .getDisplay() was public before, but we changed it because a widget should not use it directly.

The best way would probably to use a wrapper call (i.e. a class that implements the TFT_eSPI functions used by DigitalRainAnimation.hpp and forward them to ScreenManager.

I'll do some test as soon as I can.

I see, you need access to `m_tft` to pass it to `DigitalRainAnimation.hpp`. Well, `.getDisplay()` was public before, but we changed it because a widget should not use it directly. The best way would probably to use a wrapper call (i.e. a class that implements the `TFT_eSPI` functions used by `DigitalRainAnimation.hpp` and forward them to `ScreenManager`. I'll do some test as soon as I can.
nconner-06 (Migrated from github.com) reviewed 2025-03-04 14:28:09 +00:00
@ -18,6 +18,13 @@ ScreenManager::ScreenManager(TFT_eSPI &tft) : m_tft(tft) {
m_tft.fillScreen(TFT_WHITE);
m_tft.setTextDatum(MC_DATUM);
reset();
#ifdef INCLUDE_SCREENSAVER
nconner-06 (Migrated from github.com) commented 2025-03-04 14:28:09 +00:00

Ok, thanks
A class within a class and I want to access the internal class...
So, far I have identified I need to access these attributes of TFT_eSPI:
int16_t width();
int16_t height();
void setTextColor(uint16_t c);
void setTextColor(uint16_t c, uint16_t b);
void setTextColor(uint16_t c, uint16_t b, bool bgfill);
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
void setCursor(int16_t x, int16_t y);
void setTextSize(uint8_t s);
void print(String s);
void print(char c);

And .getDisplay...

Ok, thanks A class within a class and I want to access the internal class... So, far I have identified I need to access these attributes of TFT_eSPI: int16_t width(); int16_t height(); void setTextColor(uint16_t c); void setTextColor(uint16_t c, uint16_t b); void setTextColor(uint16_t c, uint16_t b, bool bgfill); uint16_t color565(uint8_t r, uint8_t g, uint8_t b); void setCursor(int16_t x, int16_t y); void setTextSize(uint8_t s); void print(String s); void print(char c); And .getDisplay...
nconner-06 (Migrated from github.com) reviewed 2025-03-04 14:33:45 +00:00
@ -18,6 +18,13 @@ ScreenManager::ScreenManager(TFT_eSPI &tft) : m_tft(tft) {
m_tft.fillScreen(TFT_WHITE);
m_tft.setTextDatum(MC_DATUM);
reset();
#ifdef INCLUDE_SCREENSAVER
nconner-06 (Migrated from github.com) commented 2025-03-04 14:33:45 +00:00

I'm happy to modify the "DigitalRainAnimation.hpp" file if needed.

As you can see the initialization takes a pointer to a TFT_eSPI class object (if I understand the code correctly)

// initialization
void DigitalRainAnimation::init(TFT_eSPI gfx,* bool biggerText, bool alphabetOnly)
{
_gfx = gfx;
setBigText(biggerText);
line_len_min = 3;
line_len_max = 10;
isAlphabetOnly = alphabetOnly;
prepareAnim();
}

I'm happy to modify the "DigitalRainAnimation.hpp" file if needed. As you can see the initialization takes a pointer to a TFT_eSPI class object (if I understand the code correctly) // initialization void DigitalRainAnimation::init(TFT_eSPI *gfx,** bool biggerText, bool alphabetOnly) { _gfx = gfx; setBigText(biggerText); line_len_min = 3; line_len_max = 10; isAlphabetOnly = alphabetOnly; prepareAnim(); }
nconner-06 (Migrated from github.com) reviewed 2025-03-06 08:41:07 +00:00
@ -18,6 +18,13 @@ ScreenManager::ScreenManager(TFT_eSPI &tft) : m_tft(tft) {
m_tft.fillScreen(TFT_WHITE);
m_tft.setTextDatum(MC_DATUM);
reset();
#ifdef INCLUDE_SCREENSAVER
nconner-06 (Migrated from github.com) commented 2025-03-06 08:41:07 +00:00

@flattermann
FYI, I'm managed to get the function working without needing the protected function.. i.e. I'm using ScreenManager without needing to have any Widget specific code in the core function.
I still do need to add functionality to the SM, but that is just to pass some additional TFT_eSPI functions which are not already presented...
I'll update this PR during the day

@flattermann FYI, I'm managed to get the function working without needing the protected function.. i.e. I'm using ScreenManager without needing to have any Widget specific code in the core function. I still do need to add functionality to the SM, but that is just to pass some additional TFT_eSPI functions which are not already presented... I'll update this PR during the day
nconner-06 (Migrated from github.com) reviewed 2025-03-06 08:42:36 +00:00
@ -8,6 +8,7 @@
#include <SPI.h>
#include <TFT_eSPI.h>
#include <TJpg_Decoder.h>
#include "ScreenSaverwidget/DigitalRainAnimation.hpp"
nconner-06 (Migrated from github.com) commented 2025-03-06 08:42:36 +00:00

ok, removed

ok, removed
nconner-06 (Migrated from github.com) reviewed 2025-03-06 08:42:49 +00:00
@ -10,3 +11,4 @@
#include <ArduinoLog.h>
TFT_eSPI tft = TFT_eSPI();
DigitalRainAnimation<TFT_eSPI> matrix_effect = DigitalRainAnimation<TFT_eSPI>();
nconner-06 (Migrated from github.com) commented 2025-03-06 08:42:49 +00:00

ok, removed

ok, removed
nconner-06 (Migrated from github.com) reviewed 2025-03-06 08:43:03 +00:00
@ -0,0 +1,52 @@
#include "ScreenSaverwidget.h"
ScreenSaverwidget::ScreenSaverwidget(ScreenManager &manager, ConfigManager &config) : Widget(manager, config){
m_enabled = true;
nconner-06 (Migrated from github.com) commented 2025-03-06 08:43:03 +00:00

ok, changed

ok, changed
nconner-06 (Migrated from github.com) reviewed 2025-03-06 08:43:15 +00:00
@ -0,0 +12,4 @@
m_config.addConfigInt("ScreenSaverWidget", "updateInterval", &m_updateInterval, "Screen Update Interval", true);
}
void ScreenSaverwidget::addConfigToManager(){
nconner-06 (Migrated from github.com) commented 2025-03-06 08:43:15 +00:00

ok, removed

ok, removed
nconner-06 (Migrated from github.com) reviewed 2025-03-06 08:43:46 +00:00
@ -0,0 +20,4 @@
void addConfigToManager();
bool m_smallFont = false;
int m_textColor; // = 0x001F;
int m_headtextColor; // = 0x07FF;
nconner-06 (Migrated from github.com) commented 2025-03-06 08:43:46 +00:00

Defaults are set in the class, but added them here for safety..

Defaults are set in the class, but added them here for safety..
nconner-06 (Migrated from github.com) reviewed 2025-03-06 08:43:57 +00:00
@ -0,0 +2,4 @@
ScreenSaverwidget::ScreenSaverwidget(ScreenManager &manager, ConfigManager &config) : Widget(manager, config){
m_enabled = true;
m_config.addConfigBool("ScreenSaverWidget", "SmallFont", &m_smallFont, "Small font (unchecked)", false);
nconner-06 (Migrated from github.com) commented 2025-03-06 08:43:57 +00:00

good idea, changed.

good idea, changed.
nconner-06 (Migrated from github.com) reviewed 2025-03-06 08:45:40 +00:00
@ -15,6 +15,7 @@
#define INCLUDE_PARQET // include ParqetWidget
//#define INCLUDE_WEBDATA // include WebDataWidget
//#define INCLUDE_MQTT // include MQTTWidget
#define INCLUDE_SCREENSAVER
nconner-06 (Migrated from github.com) commented 2025-03-06 08:45:40 +00:00

widget renamed to MatrixWidget
formatting update to follow project standards
Will be disabled as standard and include better comments.

widget renamed to MatrixWidget formatting update to follow project standards Will be disabled as standard and include better comments.
nconner-06 (Migrated from github.com) reviewed 2025-03-06 08:46:43 +00:00
@ -18,6 +18,13 @@ ScreenManager::ScreenManager(TFT_eSPI &tft) : m_tft(tft) {
m_tft.fillScreen(TFT_WHITE);
m_tft.setTextDatum(MC_DATUM);
reset();
#ifdef INCLUDE_SCREENSAVER
nconner-06 (Migrated from github.com) commented 2025-03-06 08:46:42 +00:00

removed Widget specific reference from the cord code

removed Widget specific reference from the cord code
nconner-06 commented 2025-03-06 08:53:07 +00:00 (Migrated from github.com)

I just noticed that it would be good if I add the support for "I18n improvements #241" PR...

I just noticed that it would be good if I add the support for "I18n improvements #241" PR...

Pull request closed

Sign in to join this conversation.
No description provided.