summaryrefslogtreecommitdiff
path: root/macros/Scilab-Arduino/InsertSetupInList.sci
diff options
context:
space:
mode:
authorsiddhu89902015-12-17 14:48:36 +0530
committersiddhu89902015-12-23 11:26:29 +0530
commit329613eb48542f24bb9014a0a617b05199726e99 (patch)
treebf571563bb735fc2ccd9a300a952f8557667fd77 /macros/Scilab-Arduino/InsertSetupInList.sci
parent96b51a5ded447676d493be9721e4480065a5ae7e (diff)
downloadscilab2c-329613eb48542f24bb9014a0a617b05199726e99.tar.gz
scilab2c-329613eb48542f24bb9014a0a617b05199726e99.tar.bz2
scilab2c-329613eb48542f24bb9014a0a617b05199726e99.zip
Code generation for Arduino changed. DC motor added to Arduino.
Diffstat (limited to 'macros/Scilab-Arduino/InsertSetupInList.sci')
-rw-r--r--macros/Scilab-Arduino/InsertSetupInList.sci58
1 files changed, 58 insertions, 0 deletions
diff --git a/macros/Scilab-Arduino/InsertSetupInList.sci b/macros/Scilab-Arduino/InsertSetupInList.sci
new file mode 100644
index 00000000..5c6be8bb
--- /dev/null
+++ b/macros/Scilab-Arduino/InsertSetupInList.sci
@@ -0,0 +1,58 @@
+function InsertSetupInList(FunName,InArg,NInArg,SetupListFile,FunType)
+
+load(SetupListFile,'SetupList');
+
+//Check first if current input function already exists in the list
+nelements = size(SetupList);
+found=%F;
+
+if(FunType=='Setup')
+ for i=1:nelements
+ if(SetupList(i)(1) == FunName)
+ for j=1:NInArg
+ if(SetupList(i)(j+1) ~= InArg(j).Name)
+ found = %F
+ break;
+ else
+ found = %T;
+ end
+ end
+ end
+ if (found == %T)
+ break; //One match found. No need to check further.
+ end
+ end
+
+ if(found == %F)
+ temp = list(FunName);
+ for i=1:NInArg
+ temp($+1) = InArg(i).Name;
+ end
+ end
+ SetupList($+1) = temp;
+elseif((FunType=='Init')&((FunName=='cmd_digital_out')|(FunName=='cmd_analog_out')|(FunName=='cmd_digital_in')))
+ for i=1:nelements
+ if(SetupList(i)(1) == FunName)
+ if(SetupList(i)(2) == InArg(2).Name)
+ found = %T
+ break;
+ else
+ found = %F;
+ end
+ end
+ end
+
+ if(found == %F)
+ temp = list('pinMode');
+ temp($+1) = InArg(2).Name;
+ if ((FunName=='cmd_digital_out')|(FunName=='cmd_analog_out'))
+ temp($+1) = 'OUTPUT';
+ elseif (FunName == 'cmd_digital_in')
+ temp($+1) = 'INPUT';
+ end
+ end
+ SetupList($+1) = temp;
+end
+
+save(SetupListFile,'SetupList');
+endfunction