Skip to content

Commit c3945ba

Browse files
committed
Cleaned up some code
1 parent 68e4a2f commit c3945ba

4 files changed

Lines changed: 67 additions & 40 deletions

File tree

SmartHandController.ino

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -115,33 +115,32 @@ void setup(void) {
115115
#if DEBUG == PROFILER
116116
tasks.add(142, 0, true, 7, profiler, "Profilr");
117117
#endif
118-
119-
// start any plugins
120-
#if PLUGIN1 != OFF
121-
PLUGIN1.init();
122-
#endif
123-
#if PLUGIN2 != OFF
124-
PLUGIN2.init();
125-
#endif
126-
#if PLUGIN3 != OFF
127-
PLUGIN3.init();
128-
#endif
129-
#if PLUGIN4 != OFF
130-
PLUGIN4.init();
131-
#endif
132-
#if PLUGIN5 != OFF
133-
PLUGIN5.init();
134-
#endif
135-
#if PLUGIN6 != OFF
136-
PLUGIN6.init();
137-
#endif
138-
#if PLUGIN7 != OFF
139-
PLUGIN7.init();
140-
#endif
141-
#if PLUGIN8 != OFF
142-
PLUGIN8.init();
143-
#endif
144118

119+
// start any plugins
120+
#if PLUGIN1 != OFF
121+
PLUGIN1.init();
122+
#endif
123+
#if PLUGIN2 != OFF
124+
PLUGIN2.init();
125+
#endif
126+
#if PLUGIN3 != OFF
127+
PLUGIN3.init();
128+
#endif
129+
#if PLUGIN4 != OFF
130+
PLUGIN4.init();
131+
#endif
132+
#if PLUGIN5 != OFF
133+
PLUGIN5.init();
134+
#endif
135+
#if PLUGIN6 != OFF
136+
PLUGIN6.init();
137+
#endif
138+
#if PLUGIN7 != OFF
139+
PLUGIN7.init();
140+
#endif
141+
#if PLUGIN8 != OFF
142+
PLUGIN8.init();
143+
#endif
145144

146145
VLF("MSG: Starting UI loop");
147146
}

src/plugins/Plugins.config.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,41 @@
11
/* ---------------------------------------------------------------------------------------------------------------------------------
2-
* User plugins for OnStepX
2+
* User plugins for the SmartHandController (OnStep) project.
33
*
44
* For each entery below one must specify the class instance name and #include the class header file.
55
*
66
* Each plugin should have a directory that contains all of its files, which gets dropped into to the /src/plugins directory.
77
* The plugin main class instance name should match the directory name.
8-
* The plugin main class must have a "void init();" method for OnStepX to call when it starts up.
8+
* The plugin main class must have a "void init();" method for the SmartHandController to call when it starts up.
99
*
1010
* ---------------------------------------------------------------------------------------------------------------------------------
1111
*/
1212

1313
// =================================================================================================================================
1414

15+
#define PLUGIN1 OFF // OFF, Specify the class instance (same as plugin directory name) to enable. Option
16+
//#include "plugin1/Name.h" // Specify the header file to include the class.
17+
1518
// *** Comment out PLUGIN1 above AND uncomment the following two lines to enable the sample plugin ***
1619
//#define PLUGIN1 sample // OFF, Specify the class instance (same as plugin directory name) to enable. Option
1720
//#include "sample/Sample.h" // Specify the header file to include the class.
1821

19-
#define PLUGIN1 OFF // OFF, Specify the class instance (same as plugin directory name) to enable. Option
20-
//#include "website/Website.h" // Specify the header file to include the class.
21-
#define PLUGIN1_COMMAND_PROCESSING OFF // OFF, Set to ON for plugins that allow command processing
22-
2322
#define PLUGIN2 OFF // OFF, Specify the class instance (same as plugin directory name) to enable. Option
24-
//#include "power/Power.h" // Specify the header file to include the class.
25-
#define PLUGIN2_COMMAND_PROCESSING OFF // OFF, Set to ON for plugins that allow command processing
23+
//#include "plugin2/Name.h" // Specify the header file to include the class.
2624

2725
#define PLUGIN3 OFF // OFF, Specify the class instance (same as plugin directory name) to enable. Option
2826
//#include "plugin3/Name.h" // Specify the header file to include the class.
29-
#define PLUGIN3_COMMAND_PROCESSING OFF // OFF, Set to ON for plugins that allow command processing
3027

3128
#define PLUGIN4 OFF // OFF, Specify the class instance (same as plugin directory name) to enable. Option
3229
//#include "plugin4/Name.h" // Specify the header file to include the class.
33-
#define PLUGIN4_COMMAND_PROCESSING OFF // OFF, Set to ON for plugins that allow command processing
3430

3531
#define PLUGIN5 OFF // OFF, Specify the class instance (same as plugin directory name) to enable. Option
3632
//#include "plugin5/Name.h" // Specify the header file to include the class.
37-
#define PLUGIN5_COMMAND_PROCESSING OFF // OFF, Set to ON for plugins that allow command processing
3833

3934
#define PLUGIN6 OFF // OFF, Specify the class instance (same as plugin directory name) to enable. Option
4035
//#include "plugin6/Name.h" // Specify the header file to include the class.
41-
#define PLUGIN6_COMMAND_PROCESSING OFF // OFF, Set to ON for plugins that allow command processing
4236

4337
#define PLUGIN7 OFF // OFF, Specify the class instance (same as plugin directory name) to enable. Option
4438
//#include "plugin7/Name.h" // Specify the header file to include the class.
45-
#define PLUGIN7_COMMAND_PROCESSING OFF // OFF, Set to ON for plugins that allow command processing
4639

4740
#define PLUGIN8 OFF // OFF, Specify the class instance (same as plugin directory name) to enable. Option
4841
//#include "plugin8/Name.h" // Specify the header file to include the class.
49-
#define PLUGIN8_COMMAND_PROCESSING OFF // OFF, Set to ON for plugins that allow command processing

src/plugins/Sample/Sample.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Sample plugin
2+
3+
#include "Sample.h"
4+
#include "../../Common.h"
5+
#include "../../lib/tasks/OnTask.h"
6+
7+
void sampleWrapper() { sample.loop(); }
8+
9+
void Sample::init() {
10+
VLF("MSG: Plugins, starting: sample");
11+
12+
// start a task that runs twice a second, run at priority level 7 so we can block
13+
// using tasks.yield(); fairly aggressively without significant impact on operation
14+
tasks.add(2000, 0, true, 7, sampleWrapper);
15+
}
16+
17+
void Sample::loop() {
18+
Serial.println("Hello from the sample plugin!");
19+
}
20+
21+
Sample sample;

src/plugins/Sample/Sample.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Sample plugin
2+
#pragma once
3+
4+
class Sample {
5+
public:
6+
// the initialization method must be present and named: void init();
7+
void init();
8+
9+
void loop();
10+
11+
private:
12+
13+
};
14+
15+
extern Sample sample;

0 commit comments

Comments
 (0)