-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[P043] [JSON] Add feature to output times in JSON #5524
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
base: mega
Are you sure you want to change the base?
Changes from 3 commits
cd2e4b5
e5d85ac
f1bb011
e72c8b7
fc1ad04
1dc105e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd expect this new feature to deserve a mention in the Changelog at the top of |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -366,6 +366,39 @@ boolean Plugin_043(uint8_t function, struct EventStruct *event, String& string) | |
| # undef P043_GETVALUE_LENGTH | ||
| break; | ||
| } | ||
|
|
||
| #if FEATURE_P043_CLK_TIMES_JSON | ||
| case PLUGIN_TASK_JSON: | ||
| { | ||
| addLog(LOG_LEVEL_INFO, F("P043 JSON CALLED")); | ||
| auto taskWriter = reinterpret_cast<KeyValueWriter *>(event->Par1); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto, please use the already present |
||
| if (!taskWriter) break; | ||
| taskWriter->write({ F("OnOff"), PCONFIG(6) }); | ||
|
|
||
| auto timesWriter = taskWriter->createChildArray(F("Times")); | ||
| if (!timesWriter) break; | ||
|
|
||
| LoadTaskSettings(event->TaskIndex); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not 100% sure this is needed as the |
||
|
|
||
| const int offset = | ||
| (validGpio(CONFIG_PIN1) || (PCONFIG(7) == 1)) ? 1 : 0; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto for |
||
|
|
||
| for (int x = 0; x < PCONFIG(7); x++) { | ||
|
|
||
| auto timeWriter = timesWriter->createChild(); | ||
| if (!timeWriter) continue; | ||
|
|
||
| long value = Cache.getTaskDevicePluginConfigLong(event->TaskIndex, x); | ||
| int val = ExtraTaskSettings.TaskDevicePluginConfig[x] - offset; | ||
|
|
||
| timeWriter->write({ F("Time"), timeLong2String(value) }); | ||
| timeWriter->write({ F("Value"), val }); | ||
| } | ||
|
|
||
| success = true; | ||
| break; | ||
| } | ||
| #endif // FEATURE_P043_CLK_TIMES_JSON | ||
| } | ||
| return success; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -575,6 +575,15 @@ void handle_json() | |
| } | ||
| } | ||
|
|
||
| # if FEATURE_ADDITIONAL_JSON_FROM_PLUGIN | ||
|
|
||
| EventStruct TempEvent(TaskIndex); | ||
| TempEvent.Par1 = reinterpret_cast<intptr_t>(taskWriter.get()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't do nasty things like this. There is a proper pointer in the KeyValueWriter* kvWriter = nullptr; |
||
|
|
||
| String dummy; | ||
| PluginCall(PLUGIN_TASK_JSON, &TempEvent, dummy); | ||
| # endif // FEATURE_ADDITIONAL_JSON_FROM_PLUGIN | ||
|
|
||
| #if FEATURE_PLUGIN_STATS && FEATURE_CHART_JS | ||
|
|
||
| if (showPluginStats && Device[DeviceIndex].PluginStats) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.