summaryrefslogtreecommitdiff
path: root/macros/Scilab-Arduino/GenerateSetupFunction.sci
diff options
context:
space:
mode:
Diffstat (limited to 'macros/Scilab-Arduino/GenerateSetupFunction.sci')
-rw-r--r--macros/Scilab-Arduino/GenerateSetupFunction.sci34
1 files changed, 34 insertions, 0 deletions
diff --git a/macros/Scilab-Arduino/GenerateSetupFunction.sci b/macros/Scilab-Arduino/GenerateSetupFunction.sci
new file mode 100644
index 0000000..db96e19
--- /dev/null
+++ b/macros/Scilab-Arduino/GenerateSetupFunction.sci
@@ -0,0 +1,34 @@
+function GenerateSetupFunction(FileInfo)
+
+SetupListFile = FileInfo.SetupListFile;
+
+load(SetupListFile,'SetupList');
+
+SetupArduinoFile = fullfile(FileInfo.CStyleOutCCCodeDir,'setup_arduino.c');
+C_SCI2CHeader(SetupArduinoFile);
+
+PrintStringInfo('#include ""setup_arduino.h""',SetupArduinoFile,'file','y');
+PrintStringInfo(' ',SetupArduinoFile,'file','y');
+PrintStringInfo('int setup_arduino()',SetupArduinoFile,'file','y');
+PrintStringInfo('{',SetupArduinoFile,'file','y');
+
+nelements=size(SetupList);
+
+for i=1:nelements
+ funcall = ' ';
+ funcall = funcall + SetupList(i)(1);
+ funcall = funcall + '(';
+ NInArg = size(SetupList(i))-1;
+ for j=1:NInArg-1
+ funcall = funcall + SetupList(i)(j+1);
+ funcall = funcall + ', ';
+ end
+ funcall = funcall + SetupList(i)(NInArg+1);
+ funcall = funcall + ');';
+ PrintStringInfo(funcall,SetupArduinoFile,'file','y');
+end
+PrintStringInfo(' ',SetupArduinoFile,'file','y');
+PrintStringInfo(' return (0); ',SetupArduinoFile,'file','y');
+PrintStringInfo('}',SetupArduinoFile,'file','y');
+
+endfunction