diff options
author | siddhu8990 | 2015-12-17 14:48:36 +0530 |
---|---|---|
committer | siddhu8990 | 2015-12-23 11:26:29 +0530 |
commit | 66ae4f251032aca6b7063353beee6c387a58418e (patch) | |
tree | a474f509f6413acb4593a43c371a4406d9400957 /2.3-1/macros/Scilab-Arduino | |
parent | eac39cdc77ad5fdaf7b245cbce5c92f105ac75bf (diff) | |
download | Scilab2C-66ae4f251032aca6b7063353beee6c387a58418e.tar.gz Scilab2C-66ae4f251032aca6b7063353beee6c387a58418e.tar.bz2 Scilab2C-66ae4f251032aca6b7063353beee6c387a58418e.zip |
Code generation for Arduino changed. DC motor added to Arduino.
Diffstat (limited to '2.3-1/macros/Scilab-Arduino')
15 files changed, 210 insertions, 0 deletions
diff --git a/2.3-1/macros/Scilab-Arduino/GenerateSetupFunction.bin b/2.3-1/macros/Scilab-Arduino/GenerateSetupFunction.bin Binary files differnew file mode 100644 index 00000000..7a5052dc --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/GenerateSetupFunction.bin diff --git a/2.3-1/macros/Scilab-Arduino/GenerateSetupFunction.sci b/2.3-1/macros/Scilab-Arduino/GenerateSetupFunction.sci new file mode 100644 index 00000000..db96e190 --- /dev/null +++ b/2.3-1/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 diff --git a/2.3-1/macros/Scilab-Arduino/GetArduinoFunctions.bin b/2.3-1/macros/Scilab-Arduino/GetArduinoFunctions.bin Binary files differnew file mode 100644 index 00000000..82b0d456 --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/GetArduinoFunctions.bin diff --git a/2.3-1/macros/Scilab-Arduino/GetArduinoFunctions.sci b/2.3-1/macros/Scilab-Arduino/GetArduinoFunctions.sci new file mode 100644 index 00000000..19d59ca4 --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/GetArduinoFunctions.sci @@ -0,0 +1,22 @@ +function ArduinoFunctions = GetArduinoFunctions() +// ----------------------------------------------------------------- +// Get list of Arduino functions supported +// +// Input data: +// None +// +// Output data: +// List of Arduino functions supported +// +// Author: Siddhesh Wani +// ----------------------------------------------------------------- + +ArduinoFunctions = [ + "cmd_digital_out" + "cmd_digital_in" + "cmd_analog_out" + "cmd_analog_in" + "cmd_dcmotor_setup" + "cmd_dcmotor_run"]; + +endfunction diff --git a/2.3-1/macros/Scilab-Arduino/GetArduinoSetupFunctions.bin b/2.3-1/macros/Scilab-Arduino/GetArduinoSetupFunctions.bin Binary files differnew file mode 100644 index 00000000..048da7d7 --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/GetArduinoSetupFunctions.bin diff --git a/2.3-1/macros/Scilab-Arduino/GetArduinoSetupFunctions.sci b/2.3-1/macros/Scilab-Arduino/GetArduinoSetupFunctions.sci new file mode 100644 index 00000000..f377d385 --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/GetArduinoSetupFunctions.sci @@ -0,0 +1,17 @@ +function ArduinoSetupFunctions = GetArduinoSetupFunctions() +// ----------------------------------------------------------------- +// Get list of Arduino setup functions supported +// +// Input data: +// None +// +// Output data: +// List of Arduino setup functions supported +// +// Author: Siddhesh Wani +// ----------------------------------------------------------------- + +ArduinoSetupFunctions = [ + "cmd_dcmotor_setup"]; + +endfunction diff --git a/2.3-1/macros/Scilab-Arduino/InsertSetupInList.bin b/2.3-1/macros/Scilab-Arduino/InsertSetupInList.bin Binary files differnew file mode 100644 index 00000000..41c1a3fe --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/InsertSetupInList.bin diff --git a/2.3-1/macros/Scilab-Arduino/InsertSetupInList.sci b/2.3-1/macros/Scilab-Arduino/InsertSetupInList.sci new file mode 100644 index 00000000..5c6be8bb --- /dev/null +++ b/2.3-1/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 diff --git a/2.3-1/macros/Scilab-Arduino/IsArduinoFunction.bin b/2.3-1/macros/Scilab-Arduino/IsArduinoFunction.bin Binary files differnew file mode 100644 index 00000000..5dbfacad --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/IsArduinoFunction.bin diff --git a/2.3-1/macros/Scilab-Arduino/IsArduinoFunction.sci b/2.3-1/macros/Scilab-Arduino/IsArduinoFunction.sci new file mode 100644 index 00000000..de1c770b --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/IsArduinoFunction.sci @@ -0,0 +1,22 @@ +function Output = IsArduinoFunction(FunName) +// ----------------------------------------------------------------- +// Check whether input function name is an Arduino function or not. +// +// Input data: +// FunName: Name of the function to be checked +// +// Output data: +// Output: True or False depending whether given function is an +// Arduino function or not +// +// Author: Siddhesh Wani +// ----------------------------------------------------------------- + +//Get list of supported functions for Arduino +ArduinoFunctions = GetArduinoFunctions(); + +//Check whether input function is present in above list or not +FunNameInArduino = members(FunName,ArduinoFunctions); +Output = bool2s(FunNameInArduino~=0); + +endfunction diff --git a/2.3-1/macros/Scilab-Arduino/IsArduinoSetupFunction.bin b/2.3-1/macros/Scilab-Arduino/IsArduinoSetupFunction.bin Binary files differnew file mode 100644 index 00000000..8948d1a3 --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/IsArduinoSetupFunction.bin diff --git a/2.3-1/macros/Scilab-Arduino/IsArduinoSetupFunction.sci b/2.3-1/macros/Scilab-Arduino/IsArduinoSetupFunction.sci new file mode 100644 index 00000000..fae7f625 --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/IsArduinoSetupFunction.sci @@ -0,0 +1,22 @@ +function Output = IsArduinoSetupFunction(FunName) +// ----------------------------------------------------------------- +// Check whether input function name is an Arduino setup function or not. +// +// Input data: +// FunName: Name of the function to be checked +// +// Output data: +// Output: True or False depending whether given function is an +// Arduino setup function or not +// +// Author: Siddhesh Wani +// ----------------------------------------------------------------- + +//Get list of supported functions for Arduino +ArduinoSetupFunctions = GetArduinoSetupFunctions(); + +//Check whether input function is present in above list or not +FunNameInArduinoSetup = members(FunName,ArduinoSetupFunctions); +Output = bool2s(FunNameInArduinoSetup~=0); + +endfunction diff --git a/2.3-1/macros/Scilab-Arduino/buildmacros.sce b/2.3-1/macros/Scilab-Arduino/buildmacros.sce new file mode 100644 index 00000000..dfeb4755 --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/buildmacros.sce @@ -0,0 +1,29 @@ +// This file is released into the public domain + +Directories = [ "ASTManagement", ... + "CCodeGeneration", ... + "ErrorMessages", ... + "findDeps", ... + "FunctionAnnotation", ... + "FunctionList", ... + "GeneralFunctions", ... + "SymbolTable", ... + "ToolInitialization"... + "Hardware/AVR"... + "Scilab-Arduino" ]; + + +current_path_buildmacros = get_absolute_file_path("buildmacros.sce"); + +for K=1:size(Directories,"*") + myfile = current_path_buildmacros + filesep() + Directories(K) + filesep() + "buildmacros.sce"; + if isfile(myfile) then + exec(myfile); + end +end + +clear current_path_buildmacros; + +tbx_build_macros(TOOLBOX_NAME, get_absolute_file_path('buildmacros.sce')); + +clear tbx_build_macros; diff --git a/2.3-1/macros/Scilab-Arduino/lib b/2.3-1/macros/Scilab-Arduino/lib Binary files differnew file mode 100644 index 00000000..bd0cb707 --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/lib diff --git a/2.3-1/macros/Scilab-Arduino/names b/2.3-1/macros/Scilab-Arduino/names new file mode 100644 index 00000000..55eb6fef --- /dev/null +++ b/2.3-1/macros/Scilab-Arduino/names @@ -0,0 +1,6 @@ +GenerateSetupFunction +GetArduinoFunctions +GetArduinoSetupFunctions +InsertSetupInList +IsArduinoFunction +IsArduinoSetupFunction |