Skip to content

Commit

Permalink
Add stubs for new controllers up-to C025
Browse files Browse the repository at this point in the history
  • Loading branch information
TD-er committed Sep 27, 2020
1 parent d9b8ea0 commit 05fef85
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/_CPlugin_Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#define CPLUGIN_HELPER_H CPLUGIN_HELPER_H

#include <Arduino.h>

#include "ESPEasy_common.h"

#include "src/Globals/CPlugins.h"
#include "src/Globals/ESPEasy_Scheduler.h"
#include "src/Helpers/Numerical.h"
Expand Down
9 changes: 6 additions & 3 deletions src/__CPlugin.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "ESPEasy_common.h"

#include "src/Globals/CPlugins.h"
#include "src/Globals/Protocol.h"
#include "src/Globals/Settings.h"
Expand All @@ -6,9 +8,6 @@
#include "src/DataStructs/ESPEasy_plugin_functions.h"
#include "src/DataStructs/TimingStats.h"

#include "ESPEasy_common.h"



// ********************************************************************************
// Initialize all Controller CPlugins that where defined earlier
Expand Down Expand Up @@ -148,6 +147,10 @@ void CPluginInit(void)
ADDCPLUGIN(025)
#endif

// When extending this, search for EXTEND_CONTROLLER_IDS
// in the code to find all places that need to be updated too.


CPluginCall(CPlugin::Function::CPLUGIN_PROTOCOL_ADD, 0);

// Set all not supported cplugins to disabled.
Expand Down
5 changes: 4 additions & 1 deletion src/src/ControllerQueue/ControllerDelayHandlerStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
#include "../Helpers/Scheduler.h"
#include "../Helpers/StringConverter.h"

#include <Arduino.h>
#include <list>
#include <memory> // For std::shared_ptr
#include <new> // std::nothrow


/*********************************************************************************************\
* ControllerDelayHandlerStruct
Expand Down Expand Up @@ -234,7 +237,7 @@ struct ControllerDelayHandlerStruct {
} \
bool init_c##NNN####M##_delay_queue(controllerIndex_t ControllerIndex) { \
if (C##NNN####M##_DelayHandler == nullptr) { \
C##NNN####M##_DelayHandler = new (std::nothrow) C##NNN####M##_DelayHandler_t; \
C##NNN####M##_DelayHandler = new (std::nothrow) (C##NNN####M##_DelayHandler_t); \
} \
if (C##NNN####M##_DelayHandler == nullptr) { return false; } \
MakeControllerSettings(ControllerSettings); \
Expand Down
40 changes: 37 additions & 3 deletions src/src/ControllerQueue/DelayQueueElements.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "DelayQueueElements.h"

#include "../DataStructs/ControllerSettingsStruct.h"
#include "../DataStructs/TimingStats.h"
#include "../Globals/ESPEasy_Scheduler.h"

#ifdef USES_MQTT
ControllerDelayHandlerStruct<MQTT_queue_element> *MQTTDelayHandler = nullptr;
Expand All @@ -11,7 +14,7 @@ bool init_mqtt_delay_queue(controllerIndex_t ControllerIndex, String& pubname, b
}
LoadControllerSettings(ControllerIndex, ControllerSettings);
if (MQTTDelayHandler == nullptr) {
MQTTDelayHandler = new (std::nothrow) ControllerDelayHandlerStruct<MQTT_queue_element>;
MQTTDelayHandler = new (std::nothrow) ControllerDelayHandlerStruct<MQTT_queue_element>;
}
if (MQTTDelayHandler == nullptr) {
return false;
Expand Down Expand Up @@ -145,6 +148,37 @@ DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 18)
#endif
*/

/*
#ifdef USES_C021
DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 21)
#endif
*/

/*
#ifdef USES_C022
DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 22)
#endif
*/

/*
#ifdef USES_C023
DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 23)
#endif
*/

/*
#ifdef USES_C024
DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 24)
#endif
*/

/*
#ifdef USES_C025
DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 25)
#endif
*/



// When extending this, also extend in Scheduler.cpp:
// void process_interval_timer(unsigned long id, unsigned long lasttimer)
// When extending this, search for EXTEND_CONTROLLER_IDS
// in the code to find all places that need to be updated too.
38 changes: 35 additions & 3 deletions src/src/ControllerQueue/DelayQueueElements.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#ifndef DELAY_QUEUE_ELEMENTS_H
#define DELAY_QUEUE_ELEMENTS_H


#include "../../ESPEasy_common.h"
#include "../DataStructs/ControllerSettingsStruct.h"
#include "../../ESPEasy_fdwdecl.h"

#include "../ControllerQueue/ControllerDelayHandlerStruct.h"
#include "../ControllerQueue/SimpleQueueElement_string_only.h"
#include "../ControllerQueue/queue_element_single_value_base.h"

#include "../DataStructs/ControllerSettingsStruct.h"


// The most logical place to have these queue element handlers defined would be in their
// respective _Cxxx.ino file.
Expand Down Expand Up @@ -156,9 +158,39 @@ DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 18)
#endif
*/

/*
#ifdef USES_C021
DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 21)
#endif
*/

/*
#ifdef USES_C022
DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 22)
#endif
*/

/*
#ifdef USES_C023
DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 23)
#endif
*/

/*
#ifdef USES_C024
DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 24)
#endif
*/

/*
#ifdef USES_C025
DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 25)
#endif
*/


// When extending this, also extend in Scheduler.cpp:
// void process_interval_timer(unsigned long id, unsigned long lasttimer)
// When extending this, search for EXTEND_CONTROLLER_IDS
// in the code to find all places that need to be updated too.


#endif // ifndef DELAY_QUEUE_ELEMENTS_H
51 changes: 49 additions & 2 deletions src/src/Helpers/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ void ESPEasy_Scheduler::setIntervalTimer(IntervalTimer_e id, unsigned long lastt
case IntervalTimer_e::TIMER_C018_DELAY_QUEUE:
case IntervalTimer_e::TIMER_C019_DELAY_QUEUE:
case IntervalTimer_e::TIMER_C020_DELAY_QUEUE:
case IntervalTimer_e::TIMER_C021_DELAY_QUEUE:
case IntervalTimer_e::TIMER_C022_DELAY_QUEUE:
case IntervalTimer_e::TIMER_C023_DELAY_QUEUE:
case IntervalTimer_e::TIMER_C024_DELAY_QUEUE:
case IntervalTimer_e::TIMER_C025_DELAY_QUEUE:
// When extending this, search for EXTEND_CONTROLLER_IDS
// in the code to find all places that need to be updated too.
interval = 1000; break;
}
unsigned long timer = lasttimer;
Expand Down Expand Up @@ -368,8 +375,48 @@ void ESPEasy_Scheduler::process_interval_timer(IntervalTimer_e id, unsigned long
*/
break;

// When extending this, also extend in DelayQueueElements.h
// Also make sure to extend the "TIMER_C020_DELAY_QUEUE" list of defines.
case IntervalTimer_e::TIMER_C021_DELAY_QUEUE:
/*
#ifdef USES_C021
process_c021_delay_queue();
#endif
*/
break;

case IntervalTimer_e::TIMER_C022_DELAY_QUEUE:
/*
#ifdef USES_C022
process_c022_delay_queue();
#endif
*/
break;

case IntervalTimer_e::TIMER_C023_DELAY_QUEUE:
/*
#ifdef USES_C023
process_c023_delay_queue();
#endif
*/
break;

case IntervalTimer_e::TIMER_C024_DELAY_QUEUE:
/*
#ifdef USES_C024
process_c024_delay_queue();
#endif
*/
break;

case IntervalTimer_e::TIMER_C025_DELAY_QUEUE:
/*
#ifdef USES_C025
process_c025_delay_queue();
#endif
*/
break;

// When extending this, search for EXTEND_CONTROLLER_IDS
// in the code to find all places that need to be updated too.
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/src/Helpers/Scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ class ESPEasy_Scheduler {
TIMER_C018_DELAY_QUEUE,
TIMER_C019_DELAY_QUEUE,
TIMER_C020_DELAY_QUEUE,
TIMER_C021_DELAY_QUEUE,
TIMER_C022_DELAY_QUEUE,
TIMER_C023_DELAY_QUEUE,
TIMER_C024_DELAY_QUEUE,
TIMER_C025_DELAY_QUEUE,
// When extending this, search for EXTEND_CONTROLLER_IDS
// in the code to find all places that need to be updated too.

};

enum class PluginPtrType {
Expand Down

0 comments on commit 05fef85

Please sign in to comment.