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

Plugins: Allow view specific config #201

Draft
wants to merge 1 commit into
base: Development
Choose a base branch
from

Conversation

nhjschulz
Copy link
Collaborator

Add a method for view specfic configuration
keys via json. The goal is to allow additional
settings (i.e. 64x64 layouts) without increasing
the footprint for others.

A new interface called IJsonConfig defines the API to use. Both plugins and views can implement it. The plugins then forward config calls to the views to have view specific settings covered (if needed).

Add a method for view specfic configuration
keys via json. The goal is to allow additional
settings (i.e. 64x64 layouts) without increasing
the  footprint for others.

A new interface called IJsonConfig defines the API
to use. Both plugins and views can implement it. The
plugins then forward config calls to the views to have
view specific settings covered (if needed).
@nhjschulz
Copy link
Collaborator Author

The change doen't fullfill its goal to save flash right now 👎

Default config:

feature/view_config:
RAM: [== ] 18.3% (used 59844 bytes from 327680 bytes)
Flash: [==========] 96.1% (used 1384965 bytes from 1441792 bytes)

Development:
RAM: [== ] 18.3% (used 59876 bytes from 327680 bytes)
Flash: [==========] 96.0% (used 1384121 bytes from 1441792 bytes)

@@ -333,6 +318,13 @@ class PluginWithConfig : public Plugin
bool m_storeConfigReq; /**< Is requested to store the configuration in persistent memory? */
bool m_reloadConfigReq; /**< Is requested to reload the configuration from persistent memory? */

/*TODO REMOVE if all plugins have it. Right now only in DateTimePlugin. */
bool mergeConfiguration(JsonObject& jsonMerged, const JsonObjectConst& jsonSource)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the idea later with mergeConfiguration() method in this class? Isn't it only used between the plugin main class and its views only?

@@ -47,6 +47,8 @@
#include <WString.h>
#include <cerrno>

#include <YAColor.h>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

library.json dependency update is missing. Now Utilities are depended on YAGfx.

* updates. It is used to provide and apply configuration settings to and from
* a REST API.
*/
class IJsonConfig
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether the interface class is necessary, see my comment in PluginWithConfig.hpp
mergeConfiguration() is only required between plugin main class and its view. The other two methods are in general required for configuration file handling in PluginWithConfig.

Additional it increases the dependency from plugin library to common library. But could live in plugin library.


if (false == jsonAnalogClock.isNull())
{
jsonMerged["analogClock"] = jsonAnalogClock;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check the REST API if you change a color value?


bool DateTimeView64x64::setConfiguration(const JsonObjectConst& jsonCfg)
{
bool result = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result will be true even if "analogClock" would be a string instead an object.

if (false == jsonAnalogClock.isNull())
{
jsonMerged["analogClock"] = jsonAnalogClock;
result = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be aware, mergeConfiguration() will receive all JSON parameters as String! A conversion might be necessary here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants