diff options
author | Brijeshcr | 2017-07-20 19:39:55 +0530 |
---|---|---|
committer | Brijeshcr | 2017-07-20 19:39:55 +0530 |
commit | 215a24b64f6d0ec3fcef06c2634926f730b3dcc5 (patch) | |
tree | 48072b76fe009ec8423ba9e179fef964db666a3a /2.3-1/macros/Hardware/RasberryPi/gertBoard | |
parent | 9a2e3e3174a9ff35ba9b739cec4a0b8c052a8dbe (diff) | |
parent | dbf6486fa17d277729e0d6f77c2a6b93cbdd9424 (diff) | |
download | Scilab2C-215a24b64f6d0ec3fcef06c2634926f730b3dcc5.tar.gz Scilab2C-215a24b64f6d0ec3fcef06c2634926f730b3dcc5.tar.bz2 Scilab2C-215a24b64f6d0ec3fcef06c2634926f730b3dcc5.zip |
Added RPI demo and lcd128x64 fixed
Diffstat (limited to '2.3-1/macros/Hardware/RasberryPi/gertBoard')
8 files changed, 265 insertions, 0 deletions
diff --git a/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_analogRead.sci b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_analogRead.sci new file mode 100755 index 00000000..41bf877a --- /dev/null +++ b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_analogRead.sci @@ -0,0 +1,40 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function out=RPI_analogRead(pin) +// Function to read the analog voltage at the given pin +// +// Calling Sequence +// v=RPI_analogRead(pin) +// +// Parameters +// pin: The pin number to read the voltage from. Numbering sequence to be followed as initiated using RPI_pinNumbering function. +// +// Description +// This function returns the value read on the supplied analog input pin. Additional analog modules need to be registered to enable this function for devices such as the Gertboard, quick2Wire analog board, etc. +// +// Examples +// v=RPI_analogRead(0) +// See also +// RPI_analogWrite, RPI_digitalRead, RPI_digitalWrite, RPI_pinNumbering, RPI_pinMode +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="anR#1#"+string(pin)+"#"; + if getos()=="Linux" then + out=unix_g("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos()=="Windows" then + [out,RPI_winR]=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction diff --git a/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_analogWrite.sci b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_analogWrite.sci new file mode 100755 index 00000000..f7089f53 --- /dev/null +++ b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_analogWrite.sci @@ -0,0 +1,41 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function RPI_analogWrite(pin,Volt) +// Function to set analog voltage at given analog pin. +// +// Calling Sequence +// RPI_analogWrite(pin,Volt) +// +// Parameters +// pin : The pin number to set the voltage at. Numbering sequence to be followed as initiated using RPI_pinNumbering function. +// Volt: The analog voltage value to set at the pin. +// +// Description +// This writes the given value to the supplied analog pin. Additional analog modules need to be registered to enable this function for devices such as the Gertboard. +// +// Examples +// RPI_analogWrite(0,100) +// See also +// RPI_analogRead, RPI_digitalRead, RPI_digitalWrite, RPI_pinNumbering, RPI_pinMode +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="anW#2#"+string(pin)+"#"+string(Volt)+"#"; + if getos=="Linux" then + unix_w("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos=="Windows" then + RPI_winR=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction diff --git a/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogRead.sci b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogRead.sci new file mode 100755 index 00000000..ce7e870e --- /dev/null +++ b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogRead.sci @@ -0,0 +1,42 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function out=RPI_gertboardAnalogRead(pin) +// Function to read voltage from gertboard +// +// Calling Sequence +// RPI_gertboardAnalogRead(pin) +// +// Parameters +// pin:the pin to read the voltage from. Numbering follows the pinBase from RPI_gertboardSetup function. +// +// Description +// After initialinzing the pinBase using the RPI_gertboeardSetup function, reading channel pinBase + 0 reads the first analog input channel (pin DA0 on the Gertboard). Returns a value from 0 to 1023 representing the value on the supplied pin. +// +// Examples +// RPI_gertboardAnalogRead(101) +// See also +// RPI_gertboardAnalogSetup, RPI_gertboardAnalogWrite, RPI_gertboardSPISetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ +// http://pi4j.com/apidocs/com/pi4j/wiringpi/Gertboard.html + + commande="gAR#1#"+string(pin)+"#"; + if getos()=="Linux" then + out=unix_g("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos()=="Windows" then + [out,RPI_winR]=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction + diff --git a/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogSetup.sci b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogSetup.sci new file mode 100755 index 00000000..a8348110 --- /dev/null +++ b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogSetup.sci @@ -0,0 +1,41 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function out=RPI_gertboardAnalogSetup(pinBase) +// Function to setup the gertboard +// +// Calling Sequence +// RPI_getboardAnalogSetup(pinBase) +// +// Parameters +// pinBase:the base pin that the analog ports will appear as +// +// Description +// This function calls a setup routine that allocates 2 pins and overlays the analog to digital input pins with the digital to analog output pins. pinBase is the base pin that you want the analog ports to appear as. So reading channel pinBase + 0 reads the first analog input channel (pin DA0 on the Gertboard), and writing pinBase + 0 outputs to the first analog output channel. (Pin AD0) +// +// Examples +// RPI_getboardAnalogSetup(100) +// See also +// RPI_gertboardAnalogRead, RPI_gertboardAnalogWrite, RPI_gertboardSPISetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ +// http://pi4j.com/apidocs/com/pi4j/wiringpi/Gertboard.html + + commande="gAS#1#"+string(pinBase)+"#"; + if getos()=="Linux" then + out=unix_g("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos()=="Windows" then + [out,RPI_winR]=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction diff --git a/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogWrite.sci b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogWrite.sci new file mode 100755 index 00000000..3f8f9dd6 --- /dev/null +++ b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogWrite.sci @@ -0,0 +1,42 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function RPI_gertboardAnalogWrite(pin,value) +// Function to write voltage value to pins on gertboard +// +// Calling Sequence +// RPI_gertboardAnalogWrite(pin,value) +// +// Parameters +// pin : the pin to read the voltage from. Numbering follows the pinBase from RPI_gertboardSetup function. +// value: voltage value to write +// +// Description +// After initialinzing the pinBase using the RPI_gertboeardSetup function, writing pinBase + 0 outputs to the first analog output channel. (Pin AD0). +// +// Examples +// RPI_gertboardAnalogWrite(100,100) +// See also +// RPI_gertboardAnalogSetup, RPI_gertboardAnalogRead, RPI_gertboardSPISetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ +// http://pi4j.com/apidocs/com/pi4j/wiringpi/Gertboard.html + + commande="gAW#2#"+string(pin)+"#"+string(value)+"#"; + if getos=="Linux" then + unix_w("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos=="Windows" then + RPI_winR=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction diff --git a/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardSPISetup.sci b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardSPISetup.sci new file mode 100755 index 00000000..d4117b00 --- /dev/null +++ b/2.3-1/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardSPISetup.sci @@ -0,0 +1,39 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function RPI_gertboardSPISetup() +// Function to initialize SPI bus communication with gertboard +// +// Calling Sequence +// RPI_gertboardSPIsetup() +// +// Description +// This function must be called to initialize the SPI bus to communicate with the Gertboards ADC and DAC chips. +// +// Examples +// RPI_gertboardSPISetup() +// See also +// RPI_gertboardAnalogSetup, RPI_gertboardAnalogRead, RPI_gertboardAnalogWrite +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ +// http://pi4j.com/apidocs/com/pi4j/wiringpi/Gertboard.html + + commande="gSS#0#"; + if getos=="Linux" then + unix_w("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos=="Windows" then + RPI_winR=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction + diff --git a/2.3-1/macros/Hardware/RasberryPi/gertBoard/buildmacros.sce b/2.3-1/macros/Hardware/RasberryPi/gertBoard/buildmacros.sce new file mode 100755 index 00000000..7d533f7b --- /dev/null +++ b/2.3-1/macros/Hardware/RasberryPi/gertBoard/buildmacros.sce @@ -0,0 +1,14 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Author: Jorawar Singh +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +tbx_build_macros(TOOLBOX_NAME, get_absolute_file_path('buildmacros.sce')); + +clear tbx_build_macros; diff --git a/2.3-1/macros/Hardware/RasberryPi/gertBoard/names b/2.3-1/macros/Hardware/RasberryPi/gertBoard/names new file mode 100755 index 00000000..27a469a1 --- /dev/null +++ b/2.3-1/macros/Hardware/RasberryPi/gertBoard/names @@ -0,0 +1,6 @@ +RPI_analogRead +RPI_analogWrite +RPI_gertboardAnalogRead +RPI_gertboardAnalogSetup +RPI_gertboardAnalogWrite +RPI_gertboardSPISetup |