Skip to content

Commit

Permalink
avoid the need for additional includes for task interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas committed Oct 28, 2023
1 parent ff1bc50 commit a98693a
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 43 deletions.
6 changes: 1 addition & 5 deletions extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
CFG_INCLUDE_IMPL='GwConfigDefImpl.h'
XDR_INCLUDE='GwXdrTypeMappings.h'
TASK_INCLUDE='GwUserTasks.h'
TASK_INCLUDE_IF='GwUserTasksIf.h'
EMBEDDED_INCLUDE="GwEmbeddedFiles.h"

def getEmbeddedFiles(env):
Expand Down Expand Up @@ -267,14 +266,12 @@ def checkAndAdd(file,names,ilist):
if not match:
return
ilist.append(file)
def genereateUserTasks(outfile,forIf=False):
def genereateUserTasks(outfile):
includes=[]
for task in userTaskDirs:
#print("##taskdir=%s"%task)
base=os.path.basename(task)
includeNames=[base.lower()+".h",'gw'+base.lower()+'.h']
if forIf:
includeNames=["i"+base.lower()+".h",'gwi'+base.lower()+'.h']
for f in os.listdir(task):
checkAndAdd(f,includeNames,includes)
includeData=""
Expand Down Expand Up @@ -403,7 +400,6 @@ def prebuild(env):
print("#WARNING: infile %s for %s not found"%(inFile,ef))
generateEmbedded(filedefs,os.path.join(outPath(),EMBEDDED_INCLUDE))
genereateUserTasks(os.path.join(outPath(), TASK_INCLUDE))
genereateUserTasks(os.path.join(outPath(), TASK_INCLUDE_IF),forIf=True)
generateFile(os.path.join(basePath(),XDR_FILE),os.path.join(outPath(),XDR_INCLUDE),generateXdrMappings)
version="dev"+datetime.now().strftime("%Y%m%d")
env.Append(CPPDEFINES=[('GWDEVVERSION',version)])
Expand Down
1 change: 0 additions & 1 deletion lib/buttontask/GwButtonTask.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "GwButtonTask.h"
#include "GwIButtonTask.h"
#include "GwHardware.h"
#include "GwApi.h"
#include "GwLedTask.h"
Expand Down
15 changes: 15 additions & 0 deletions lib/buttontask/GwButtonTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,19 @@
//task function
void initButtons(GwApi *param);
DECLARE_INITFUNCTION(initButtons);

class IButtonTask : public GwApi::TaskInterfaces::Base
{
public:
typedef enum
{
OFF,
PRESSED,
PRESSED_5, // 5...10s
PRESSED_10 //>10s
} ButtonState;
ButtonState state=OFF;
long pressCount=0;
};
DECLARE_TASKIF(IButtonTask);
#endif
19 changes: 0 additions & 19 deletions lib/buttontask/GwIButtonTask.h

This file was deleted.

1 change: 0 additions & 1 deletion lib/exampletask/GwExampleTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//we only compile for some boards
#ifdef BOARD_TEST
#include "GwExampleTask.h"
#include "GwIExampleTask.h"
#include "GwApi.h"
#include "GWConfig.h"
#include <vector>
Expand Down
14 changes: 13 additions & 1 deletion lib/exampletask/GwExampleTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,20 @@ void exampleInit(GwApi *param);

//let the core call an init function before the
//N2K Stuff and the communication is set up
//normally you should not need this at all
//especially this init function will register the real task at the core
//this gives you some flexibility to decide based on config or defines whether you
//really want to start the task or not
//this function must return when done - otherwise the core will not start up
DECLARE_INITFUNCTION(exampleInit);

/**
* an interface for the example task
*/
class ExampleTaskIf : public GwApi::TaskInterfaces::Base{
public:
long count=0;
String someValue;
};
DECLARE_TASKIF(ExampleTaskIf);

#endif
14 changes: 0 additions & 14 deletions lib/exampletask/GwIExampleTask.h

This file was deleted.

1 change: 0 additions & 1 deletion lib/ledtask/GwLedTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "GwHardware.h"
#include "GwApi.h"
#include "FastLED.h"
#include "GwIButtonTask.h"
typedef enum {
LED_OFF,
LED_GREEN,
Expand Down
1 change: 0 additions & 1 deletion lib/usercode/GwUserCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class GwUserCapability{
}
};
#include "GwUserTasks.h"
#include "GwUserTasksIf.h"

class TaskDataEntry{
public:
Expand Down

0 comments on commit a98693a

Please sign in to comment.