diff options
author | Jorawar Singh | 2017-07-16 22:17:43 +0530 |
---|---|---|
committer | Jorawar Singh | 2017-07-16 22:17:43 +0530 |
commit | 550bca9f6e005872e654bc96b0b477cf502d814f (patch) | |
tree | fbc38869310f062b7237096760d1f516cec77211 /macros | |
parent | d13b41b79200c533efad1f5dcc8803ca510ae1be (diff) | |
download | Scilab2C_fossee_old-550bca9f6e005872e654bc96b0b477cf502d814f.tar.gz Scilab2C_fossee_old-550bca9f6e005872e654bc96b0b477cf502d814f.tar.bz2 Scilab2C_fossee_old-550bca9f6e005872e654bc96b0b477cf502d814f.zip |
Toolbox merge, RPI demos and structured demos
Diffstat (limited to 'macros')
177 files changed, 4700 insertions, 46 deletions
diff --git a/macros/ASTManagement/lib b/macros/ASTManagement/lib Binary files differdeleted file mode 100644 index e9d351a..0000000 --- a/macros/ASTManagement/lib +++ /dev/null diff --git a/macros/CCodeGeneration/lib b/macros/CCodeGeneration/lib Binary files differdeleted file mode 100644 index f2696fe..0000000 --- a/macros/CCodeGeneration/lib +++ /dev/null diff --git a/macros/ErrorMessages/lib b/macros/ErrorMessages/lib Binary files differdeleted file mode 100644 index 1500b1f..0000000 --- a/macros/ErrorMessages/lib +++ /dev/null diff --git a/macros/FunctionAnnotation/lib b/macros/FunctionAnnotation/lib Binary files differdeleted file mode 100644 index 5eb9bc2..0000000 --- a/macros/FunctionAnnotation/lib +++ /dev/null diff --git a/macros/FunctionList/lib b/macros/FunctionList/lib Binary files differdeleted file mode 100644 index e101853..0000000 --- a/macros/FunctionList/lib +++ /dev/null diff --git a/macros/GeneralFunctions/lib b/macros/GeneralFunctions/lib Binary files differdeleted file mode 100644 index 846ca1b..0000000 --- a/macros/GeneralFunctions/lib +++ /dev/null diff --git a/macros/Hardware/AVR/lib b/macros/Hardware/AVR/lib Binary files differdeleted file mode 100644 index 53e5659..0000000 --- a/macros/Hardware/AVR/lib +++ /dev/null diff --git a/macros/Hardware/RasberryPi/Digital/RPI_digitalRead.sci b/macros/Hardware/RasberryPi/Digital/RPI_digitalRead.sci new file mode 100755 index 0000000..f3f229f --- /dev/null +++ b/macros/Hardware/RasberryPi/Digital/RPI_digitalRead.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_digitalRead(pin) +// Function to read the digital voltage at the given pin +// +// Calling Sequence +// v=RPI_digitalRead(pin) +// +// Parameters +// pin: The pin number to read the voltage from. Numbering sequence to be followed as initiated using RPI_pinNumbering function. +// +// Description +// This funtion reads the digital voltage at the given pin. Returns a 0 (for low) and 1 (for high). +// Note: pin should be set for input mode using RPI_pinMode. The function will also return 0/1 corresponding to what the voltage is set for an output pin. +// +// Examples +// v=RPI_digitalRead(0) +// See also +// RPI_analogWrite, RPI_analogRead, RPI_digitalWrite, RPI_pinNumbering, RPI_pinMode +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="diR#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/macros/Hardware/RasberryPi/Digital/RPI_digitalReadByte.sci b/macros/Hardware/RasberryPi/Digital/RPI_digitalReadByte.sci new file mode 100755 index 0000000..5cbccc2 --- /dev/null +++ b/macros/Hardware/RasberryPi/Digital/RPI_digitalReadByte.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 +// Author: Jorawar Singh +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function out=RPI_digitalReadByte() +// Function to read first 8 GPIO pins +// +// Calling Sequence +// b=RPI_digitalReadByte() +// +// Description +// This function read the state of the first eight GPIO pins at once. The state is read from pin0 to pin7. +// +// Note: The MSB-LSB sequence here is opposite of that of the RPI_digitalWriteByte. +// +// Examples +// b=RPI_digitalReadByte() +// See also +// RPI_digitalWriteByte, RPI_digitalRead +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="BtR#0#"; + 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/macros/Hardware/RasberryPi/Digital/RPI_digitalWrite.sci b/macros/Hardware/RasberryPi/Digital/RPI_digitalWrite.sci new file mode 100755 index 0000000..d4ac660 --- /dev/null +++ b/macros/Hardware/RasberryPi/Digital/RPI_digitalWrite.sci @@ -0,0 +1,46 @@ +// 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_digitalWrite(pin,Volt) +// Function to set digital voltage at the given pin +// +// Calling Sequence +// RPI_digitalWrite(pin,Volt) +// +// Parameters +// pin : The pin number to set the voltage at. Numbering sequence to be followed as initiated using RPI_pinNumbering function. +// Volt: Digital voltage to set. 0 (for logic-LOW) or 1 (for logic-HIGH) +// +// Description +// This funtion sets the voltage at the given pin. 0v for logic 0 and 3.3v for logic 1. +// Note: pin should be set for output mode using RPI_pinMode. +// +// Examples +// RPI_digitalWrite(0,1) +// See also +// RPI_analogWrite, RPI_digitalRead, RPI_digitalRead, RPI_pinNumbering, RPI_pinMode +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + if (Volt==0 | Volt==1) then + commande="diW#2#"+string(pin)+"#"+string(Volt)+"#"; + else + error("Voltage logic should be 0 or 1."); + end + 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/macros/Hardware/RasberryPi/Digital/RPI_digitalWriteByte.sci b/macros/Hardware/RasberryPi/Digital/RPI_digitalWriteByte.sci new file mode 100755 index 0000000..f7f9191 --- /dev/null +++ b/macros/Hardware/RasberryPi/Digital/RPI_digitalWriteByte.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_digitalWriteByte(Byte) +// Function to set first eight GPIO pins to a particular value +// +// Calling Sequence +// RPI_digitalWriteByte(Byte) +// +// Parameters +// Byte: An 8-bit byte to write on the first 8 GPIO pins. Inter from 0 to 255. +// +// Description +// This writes the 8-bit byte supplied to the first 8 GPIO pins. It’s the fastest way to set all 8 bits at once to a particular value, although it still takes two write operations to the Pi’s GPIO hardware. The state is written from pin7 to pin0. +// +// Note: The MSB-LSB sequence here is opposite to that from RPI_digitalReadByte. +// +// Examples +// RPI_digitalWriteByte(128) +// See also +// RPI_digitalReadByte, RPI_digitalWrite +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="BtW#1#"+string(Byte)+"#"; + 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/macros/Hardware/RasberryPi/Digital/buildmacros.sce b/macros/Hardware/RasberryPi/Digital/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/Digital/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/macros/Hardware/RasberryPi/Digital/names b/macros/Hardware/RasberryPi/Digital/names new file mode 100755 index 0000000..27fe63b --- /dev/null +++ b/macros/Hardware/RasberryPi/Digital/names @@ -0,0 +1,4 @@ +RPI_digitalRead +RPI_digitalReadByte +RPI_digitalWrite +RPI_digitalWriteByte diff --git a/macros/Hardware/RasberryPi/I2C/RPI_I2CRead.sci b/macros/Hardware/RasberryPi/I2C/RPI_I2CRead.sci new file mode 100755 index 0000000..afd9850 --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/RPI_I2CRead.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_I2CRead(fd) +// Function to read device +// +// Calling Sequence +// RPI_I2CRead(fd) +// +// Parameters +// fd: file descriptor obtained from RPI_I2CSetup +// +// Description +// Function for a simple device read. Some devices present data when you read them without having to do any register transactions. +// +// Examples +// RPI_I2CRead(13) +// See also +// RPI_i2cdetect, RPI_I2CReadReg8, RPI_I2CReadReg16, RPI_I2CWrite, RPI_I2CWriteReg8, RPI_I2CWriteReg16, RPI_I2CSetupInterface, RPI_I2CSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="CR1#1#"+string(fd)+"#"; + 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/macros/Hardware/RasberryPi/I2C/RPI_I2CReadReg16.sci b/macros/Hardware/RasberryPi/I2C/RPI_I2CReadReg16.sci new file mode 100755 index 0000000..f0ad989 --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/RPI_I2CReadReg16.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_I2CReadReg16(fd,reg) +// Function to read 16-bit valu from the register +// +// Calling Sequence +// RPI_I2CReadReg16(fd,reg) +// +// Parameters +// fd : file descriptor obtained from RPI_I2CSetup +// reg: integer register to read data from +// +// Description +// This function reads a 16-bit value from the device register indicated. +// +// Examples +// RPI_I2CReadReg16(13,0x40) +// See also +// RPI_i2cdetect, RPI_I2CRead, RPI_I2CReadReg8, RPI_I2CWrite, RPI_I2CWriteReg8, RPI_I2CWriteReg16, RPI_I2CSetupInterface, RPI_I2CSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="CR3#2#"+string(fd)+"#"+string(reg)+"#"; + 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/macros/Hardware/RasberryPi/I2C/RPI_I2CReadReg8.sci b/macros/Hardware/RasberryPi/I2C/RPI_I2CReadReg8.sci new file mode 100755 index 0000000..d2ab59f --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/RPI_I2CReadReg8.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_I2CReadReg8(fd,reg) +// Function to read 8-bit valu from the register +// +// Calling Sequence +// RPI_I2CReadReg8(fd,reg) +// +// Parameters +// fd : file descriptor obtained from RPI_I2CSetup +// reg: integer register to read data from +// +// Description +// This function reads an 8-bit value from the device register indicated. +// +// Examples +// RPI_I2CReadReg8(13,0x40) +// See also +// RPI_i2cdetect, RPI_I2CRead, RPI_I2CReadReg16, RPI_I2CWrite, RPI_I2CWriteReg8, RPI_I2CWriteReg16, RPI_I2CSetupInterface, RPI_I2CSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="CR2#2#"+string(fd)+"#"+string(reg)+"#"; + 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/macros/Hardware/RasberryPi/I2C/RPI_I2CSetup.sci b/macros/Hardware/RasberryPi/I2C/RPI_I2CSetup.sci new file mode 100755 index 0000000..801c2e6 --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/RPI_I2CSetup.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_I2CSetup(addr) +// Function to initialize the I2C system +// +// Calling Sequence +// fd=RPI_I2CSetup(addr) +// +// Parameters +// addr: integer, the I2C number of the device obtained using RPI_i2cdetect +// +// Description +// This initialises the I2C system with your given device identifier. The addr is the I2C number of the device and obtained using RPI_i2cdetect program. The function works out the Raspberry Pi revision and opens the appropriate device in /dev. +// +//The return value is the standard Linux filehandle, or -1 if any error – in which case, errno can be consulted as usual. +// +// Examples +// fd=RPI_I2CSetup(64) +// See also +// RPI_i2cdetect, RPI_I2CRead, RPI_I2CReadReg8, RPI_I2CReadReg16, RPI_I2CWrite, RPI_I2CWriteReg8, RPI_I2CWriteReg16, RPI_I2CSetupInterface +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="CSe#1#"+string(addr)+"#"; + 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/macros/Hardware/RasberryPi/I2C/RPI_I2CSetupInterface.sci b/macros/Hardware/RasberryPi/I2C/RPI_I2CSetupInterface.sci new file mode 100755 index 0000000..fed4f05 --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/RPI_I2CSetupInterface.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_I2CSetupInterface(device,addr) +// Function to select different I2C interfaces +// +// Calling Sequence +// I2CSetupInterface(device,addr) +// +// Parameters +// device: device +// addr : the I2C number of the device obtained using RPI_i2cdetect +// +// Description +// This feature is not implemented currently, and will be used to select different I2C interfaces if the RPi ever receives them. +// +// Examples +// I2CSetupInterface(1,0x48) +// See also +// RPI_i2cdetect, RPI_I2CRead, RPI_I2CReadReg8, RPI_I2CReadReg16, RPI_I2CWrite, RPI_I2CWriteReg8, RPI_I2CWriteReg16, RPI_I2CSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="CSI#2#"+string(device)+"#"+string(addr)+"#"; + 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/macros/Hardware/RasberryPi/I2C/RPI_I2CWrite.sci b/macros/Hardware/RasberryPi/I2C/RPI_I2CWrite.sci new file mode 100755 index 0000000..854b3b2 --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/RPI_I2CWrite.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_I2CWrite(fd,data) +// Function to write to device +// +// Calling Sequence +// RPI_I2CWrite(fd,data) +// +// Parameters +// fd : file descriptor obtained from RPI_I2CSetup +// data: integer data to write to device +// +// Description +// Function for simple device write. Some devices accept data this way without needing to access any internal registers. +// +// Examples +// RPI_I2CWrite(13,100) +// See also +// RPI_i2cdetect, RPI_I2CRead, RPI_I2CReadReg8, RPI_I2CReadReg16, RPI_I2CWriteReg8, RPI_I2CWriteReg16, RPI_I2CSetupInterface, RPI_I2CSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="CW1#2#"+string(fd)+"#"+string(data)+"#"; + 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/macros/Hardware/RasberryPi/I2C/RPI_I2CWriteReg16.sci b/macros/Hardware/RasberryPi/I2C/RPI_I2CWriteReg16.sci new file mode 100755 index 0000000..b2e8fb6 --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/RPI_I2CWriteReg16.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_I2CWriteReg16(fd,reg,data) +// Function to write 16-bit data to register +// +// Calling Sequence +// RPI_I2CWriteReg16(fd,reg,data) +// +// Parameters +// fd : file descriptor obtained from RPI_I2CSetup +// reg : integer register to write data at +// data: integer data to write to device +// +// Description +// This function writes a 16-bit data value into the device register indicated. +// +// Examples +// RPI_I2CWriteReg16(13,0x40,100) +// See also +// RPI_i2cdetect, RPI_I2CRead, RPI_I2CReadReg8, RPI_I2CReadReg16, RPI_I2CWrite, RPI_I2CWriteReg8, RPI_I2CSetupInterface, RPI_I2CSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="CW3#3#"+string(fd)+"#"+string(reg)+"#"+string(data)+"#"; + 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/macros/Hardware/RasberryPi/I2C/RPI_I2CWriteReg8.sci b/macros/Hardware/RasberryPi/I2C/RPI_I2CWriteReg8.sci new file mode 100755 index 0000000..19c8157 --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/RPI_I2CWriteReg8.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_I2CWriteReg8(fd,reg,data) +// Function to write 8-bit data to register +// +// Calling Sequence +// RPI_I2CWriteReg8(fd,reg,data) +// +// Parameters +// fd : file descriptor obtained from RPI_I2CSetup +// reg : integer register to write data at +// data: integer data to write to device +// +// Description +// This function writes an 8-bit data value into the device register indicated. +// +// Examples +// RPI_I2CWriteReg8(13,0x40,100) +// See also +// RPI_i2cdetect, RPI_I2CRead, RPI_I2CReadReg8, RPI_I2CReadReg16, RPI_I2CWrite, RPI_I2CWriteReg16, RPI_I2CSetupInterface, RPI_I2CSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="CW2#3#"+string(fd)+"#"+string(reg)+"#"+string(data)+"#"; + 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/macros/Hardware/RasberryPi/I2C/RPI_i2cdetect.sci b/macros/Hardware/RasberryPi/I2C/RPI_i2cdetect.sci new file mode 100755 index 0000000..a37bc4c --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/RPI_i2cdetect.sci @@ -0,0 +1,38 @@ +// 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_i2cdetect() +// Function to get the address of attached i2c device +// +// Calling Sequence +// RPI_i2cdetect() +// +// Description +// This function returns the address of the i2c device connected to the Raspberry pi. +// +// Examples +// addr=RPI_i2cdetect() +// See also +// RPI_I2CRead, RPI_I2CSetup, RPI_I2CReadReg8, RPI_I2CReadReg16, RPI_I2CSetupInterface, RPI_I2CWrite, RPI_I2CWriteReg8, RPI_I2CWriteReg16 +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + rev=RPI_boardRev(); + commande="i2c#1#i2cdetect -y "+string(strtod(rev)-1)+"#"; + 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/macros/Hardware/RasberryPi/I2C/buildmacros.sce b/macros/Hardware/RasberryPi/I2C/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/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/macros/Hardware/RasberryPi/I2C/names b/macros/Hardware/RasberryPi/I2C/names new file mode 100755 index 0000000..5a31886 --- /dev/null +++ b/macros/Hardware/RasberryPi/I2C/names @@ -0,0 +1,9 @@ +RPI_I2CRead +RPI_I2CReadReg16 +RPI_I2CReadReg8 +RPI_I2CSetup +RPI_I2CSetupInterface +RPI_I2CWrite +RPI_I2CWriteReg16 +RPI_I2CWriteReg8 +RPI_i2cdetect diff --git a/macros/Hardware/RasberryPi/Interrupt/RPI_waitForInterrupt.sci b/macros/Hardware/RasberryPi/Interrupt/RPI_waitForInterrupt.sci new file mode 100755 index 0000000..bb18042 --- /dev/null +++ b/macros/Hardware/RasberryPi/Interrupt/RPI_waitForInterrupt.sci @@ -0,0 +1,45 @@ +// 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_waitForInterrupt(pin,timeOut) +// Function to set a pin to wait for interrupt. +// +// Calling Sequence +// i=RPI_waitForInterrupt(pin,timeOut) +// +// Parameters +// pin : The pin to check for interrupt. Numbering sequence to be followed as initiated using RPI_pinNumbering function. +// timeOut: The time (in milliseconds) for which to wait for interrupt. -1 to wait forever. +// +// Description +// When called, it will wait for an interrupt event to happen on that pin and the program will be stalled. The return value is -1 if an error occurred (and errno will be set appropriately), 0 if it timed out, or 1 on a successful interrupt event. +// +// Before using RPI_waitForInterrupt, first initialise the GPIO pin and at present the only way to do this is to use the gpio program, either in a script, or using the system() call from inside the program. +// Eg: To wait for a falling-edge interrupt on GPIO pin 0, setup the hardware using (before running the program): +// gpio edge 0 falling +// +// Examples +// i=RPI_waitForInterrupt(0,5000) +// See also +// +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="Int#2#"+string(pin)+"#"+string(timeOut)+"#"; + 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/macros/Hardware/RasberryPi/Interrupt/buildmacros.sce b/macros/Hardware/RasberryPi/Interrupt/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/Interrupt/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/macros/Hardware/RasberryPi/Interrupt/names b/macros/Hardware/RasberryPi/Interrupt/names new file mode 100755 index 0000000..248c3e2 --- /dev/null +++ b/macros/Hardware/RasberryPi/Interrupt/names @@ -0,0 +1 @@ +RPI_waitForInterrupt diff --git a/macros/Hardware/RasberryPi/Misc/RPI_boardRev.sci b/macros/Hardware/RasberryPi/Misc/RPI_boardRev.sci new file mode 100755 index 0000000..91ddb33 --- /dev/null +++ b/macros/Hardware/RasberryPi/Misc/RPI_boardRev.sci @@ -0,0 +1,34 @@ +// 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_boardRev() +// Function to print the board revision. +// +// Calling Sequence +// rev=RPI_boardRev() +// +// Description +// This function returns the board revision of the Raspberry Pi. Returns either 1 or 2. +// +// Examples +// rev=RPI_boardRev() +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="bRv#0#"; + 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/macros/Hardware/RasberryPi/Misc/RPI_padDrive.sci b/macros/Hardware/RasberryPi/Misc/RPI_padDrive.sci new file mode 100755 index 0000000..f2d0b17 --- /dev/null +++ b/macros/Hardware/RasberryPi/Misc/RPI_padDrive.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 RPI_padDrive(Group,value) +// Function to set the 'strength' of the pad drivers for a particular group of pins +// +// Calling Sequence +// RPI_padDrive(Group,value) +// +// Parameters +// Group: the group to act on, a number from 0 to 2 +// Value: the strength, from 0 to 7, to set for the group +// +// Description +// This sets the “strength” of the pad drivers for a particular group of pins. There are 3 groups of pins and the drive strength is from 0 to 7. Do not use this unless you know what you are doing +// +// Examples +// RPI_padDrive(0,5) +// See also +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pDr#2#"+string(Group)+"#"+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/macros/Hardware/RasberryPi/Misc/RPI_sn3218Setup.sci b/macros/Hardware/RasberryPi/Misc/RPI_sn3218Setup.sci new file mode 100755 index 0000000..0791c50 --- /dev/null +++ b/macros/Hardware/RasberryPi/Misc/RPI_sn3218Setup.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 RPI_sn3218Setup(pinBase) +// Function for setting up SN3218 I2C based LED controller. +// +// Calling Sequence +// RPI_sn3218Setup(pinBase) +// +// Parameters +// pinBase: any number above 64. The consecutive 18 pins will be allocated alongwith. +// +// Description +// This function sets up the extension module for the SN3218 I2C based LED controller.There is no I2C device address passed into the setup function – the SN3218 has a fixed I2C address of 0x54, so there’s no need to refer to it other than internally inside the driver. This also means that only one device can be connected to a Raspberry Pi. +// +// Examples +// RPI_sn3218Setup(67) +// See also +// RPI_sr595Setup, RPI_pcf8574Setup, RPI_pcf8591Setup, RPI_mcp23008Setup, RPI_mcp23016Setup, RPI_mcp23017Setup, RPI_mcp23s08Setup, RPI_mcp23s17Setup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sn3#1#"+string(pinBase)+"#"; + 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/macros/Hardware/RasberryPi/Misc/buildmacros.sce b/macros/Hardware/RasberryPi/Misc/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/Misc/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/macros/Hardware/RasberryPi/Misc/names b/macros/Hardware/RasberryPi/Misc/names new file mode 100755 index 0000000..35a4a42 --- /dev/null +++ b/macros/Hardware/RasberryPi/Misc/names @@ -0,0 +1,3 @@ +RPI_boardRev +RPI_padDrive +RPI_sn3218Setup diff --git a/macros/Hardware/RasberryPi/RPI_adress.sci b/macros/Hardware/RasberryPi/RPI_adress.sci new file mode 100755 index 0000000..4c9aa7f --- /dev/null +++ b/macros/Hardware/RasberryPi/RPI_adress.sci @@ -0,0 +1,34 @@ +// 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 + +global RPI_piAdress; +function RPI_adress(adress) + // Function for non-ssh connection to raspberry pi + // + // Calling Sequence + // RPI_adress(adress) + // + // Parameters + // address : Network address of the raspberry pi. Eg:192.168.137.214 + // + // Description + // This program is required for the functioning of the remaining toolbox if the server is manually run by the user. + // + // Examples + // RPI_adress('10.42.0.82') + // See also + // raspi,raspi_close + // + // Authors + // Jorawar Singh + + global RPI_piAdress; + RPI_piAdress=adress; +endfunction diff --git a/macros/Hardware/RasberryPi/SPI/RPI_SPIDataRW.sci b/macros/Hardware/RasberryPi/SPI/RPI_SPIDataRW.sci new file mode 100755 index 0000000..186e68f --- /dev/null +++ b/macros/Hardware/RasberryPi/SPI/RPI_SPIDataRW.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_SPIDataRW(channel,data,len) +// Function to perform simultaneous read-write on SPI +// +// Calling Sequence +// RPI_SPIDataRW(channel,data,len) +// +// Parameters +// channel: channel number, 0 or 1 +// data : data to write as list of integers +// len : length of the data +// +// Description +// This performs a simultaneous write/read transaction over the selected SPI bus. Data that was in your buffer is overwritten by data returned from the SPI bus. +// +// Examples +// RPI_SPIDataRW(0,[13,58],2) +// See also +// RPI_SPISetup, RPI_SPISetupMode, RPI_SPIGetFd +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="SPD#3#"+string(channel)+"#"+string(data)+"#"+string(len)+"#"; + 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/macros/Hardware/RasberryPi/SPI/RPI_SPIGetFd.sci b/macros/Hardware/RasberryPi/SPI/RPI_SPIGetFd.sci new file mode 100755 index 0000000..43cfc09 --- /dev/null +++ b/macros/Hardware/RasberryPi/SPI/RPI_SPIGetFd.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 out=RPI_SPIGetFd(channel) +// +// Calling Sequence +// RPI_SPIGetFd(channel) +// +// Parameters +// channel: channel number, 0 or 1 +// +// Description +// +// +// Examples +// RPI_SPIGetFd(1) +// See also +// RPI_SPIDataRW, RPI_SPISetup, RPI_SPISetupMode +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="SPG#1#"+string(channel)+"#"; + 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/macros/Hardware/RasberryPi/SPI/RPI_SPISetup.sci b/macros/Hardware/RasberryPi/SPI/RPI_SPISetup.sci new file mode 100755 index 0000000..5654cf9 --- /dev/null +++ b/macros/Hardware/RasberryPi/SPI/RPI_SPISetup.sci @@ -0,0 +1,43 @@ +// 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_SPISetup(channel,speed) +// Function to initialize SPI +// +// Calling Sequence +// RPI_SPISetup(channel,spped) +// +// Parameters +// channel: channel number, 0 or 1 +// speed : SPI clock speed in Hz +// +// Description +// This function initialises a channel (The Pi has 2 channels; 0 and 1). The speed parameter is an integer in the range 500,000 through 32,000,000 and represents the SPI clock speed in Hz. +// +//The returned value is the Linux file-descriptor for the device, or -1 on error. +// +// Examples +// RPI_SPISetup(1,500000) +// See also +// RPI_SPIDataRW, RPI_SPISetupMode, RPI_SPIGetFd +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="SPS#2#"+string(channel)+"#"+string(speed)+"#"; + 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/macros/Hardware/RasberryPi/SPI/RPI_SPISetupMode.sci b/macros/Hardware/RasberryPi/SPI/RPI_SPISetupMode.sci new file mode 100755 index 0000000..fec785a --- /dev/null +++ b/macros/Hardware/RasberryPi/SPI/RPI_SPISetupMode.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_SPISetupMode(channel,speed,Mode) +// Function to initialize SPI +// +// Calling Sequence +// RPI_SPISetupMode(channel,spped,Mode) +// +// Parameters +// channel: channel number, 0 or 1 +// speed : SPI clock speed in Hz +// Mode : integer, mode to set +// +// Description +// +// Examples +// RPI_SPISetupMode(1,500000,2) +// See also +// RPI_SPIDataRW, RPI_SPISetup, RPI_SPIGetFd +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="SPM#23#"+string(channel)+"#"+string(speed)+"#"+string(Mode)+"#"; + 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/macros/Hardware/RasberryPi/SPI/buildmacros.sce b/macros/Hardware/RasberryPi/SPI/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/SPI/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/macros/Hardware/RasberryPi/SPI/names b/macros/Hardware/RasberryPi/SPI/names new file mode 100755 index 0000000..6f458a7 --- /dev/null +++ b/macros/Hardware/RasberryPi/SPI/names @@ -0,0 +1,4 @@ +RPI_SPIDataRW +RPI_SPIGetFd +RPI_SPISetup +RPI_SPISetupMode diff --git a/macros/Hardware/RasberryPi/Serial/RPI_serialClose.sci b/macros/Hardware/RasberryPi/Serial/RPI_serialClose.sci new file mode 100755 index 0000000..6f54b65 --- /dev/null +++ b/macros/Hardware/RasberryPi/Serial/RPI_serialClose.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_serialClose(fd) +// Function to close and open serial device +// +// Calling Sequence +// RPI_serialClose(fd) +// +// Parameters +// fd: file-descriptor obtained from RPI_serialOpen function +// +// Description +// This function closes the device identified by the file descriptor given. +// +// Examples +// RPI_serialClose(13) +// See also +// RPI_serialOpen, RPI_serialFlush, RPI_serialPutchar, RPI_serialPuts, RPI_serialPrintf, RPI_serialDataAvail, RPI_serialGetchar +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sCl#1#"+string(fd)+"#"; + 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/macros/Hardware/RasberryPi/Serial/RPI_serialDataAvail.sci b/macros/Hardware/RasberryPi/Serial/RPI_serialDataAvail.sci new file mode 100755 index 0000000..9421e5b --- /dev/null +++ b/macros/Hardware/RasberryPi/Serial/RPI_serialDataAvail.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_serialDataAvail(fd) +// Function to get number of readable character from the serial device +// +// Calling Sequence +// RPI_serialDataAvail(fd) +// +// Parameters +// fd: file-descriptor obtained from RPI_serialOpen function +// +// Description +// Returns the number of characters available for reading, or -1 for any error condition, in which case error number will be set appropriately. +// +// Examples +// RPI_serialDataAvail(13) +// See also +// RPI_serialOpen, RPI_serialClose, RPI_serialFlush, RPI_serialPutchar, RPI_serialPuts, RPI_serialPrintf, RPI_serialGetchar +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sDA#1#"+string(fd)+"#"; + 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/macros/Hardware/RasberryPi/Serial/RPI_serialFlush.sci b/macros/Hardware/RasberryPi/Serial/RPI_serialFlush.sci new file mode 100755 index 0000000..845f70b --- /dev/null +++ b/macros/Hardware/RasberryPi/Serial/RPI_serialFlush.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_serialFlush(fd) +// Function to discard all data to/from the serial device +// +// Calling Sequence +// RPI_serialFlush(fd) +// +// Parameters +// fd: file-descriptor obtained from RPI_serialOpen function +// +// Description +// This function discards all data received, or waiting to be send down the given device. +// +// Examples +// RPI_serialFlush(13) +// See also +// RPI_serialOpen, RPI_serialClose, RPI_serialPutchar, RPI_serialPuts, RPI_serialPrintf, RPI_serialDataAvail, RPI_serialGetchar +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sFl#1#"+string(fd)+"#"; + 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/macros/Hardware/RasberryPi/Serial/RPI_serialGetchar.sci b/macros/Hardware/RasberryPi/Serial/RPI_serialGetchar.sci new file mode 100755 index 0000000..327fe35 --- /dev/null +++ b/macros/Hardware/RasberryPi/Serial/RPI_serialGetchar.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_serialGetchar(fd) +// Function to get next character from serial device +// +// Calling Sequence +// RPI_serialGetchar(fd) +// +// Parameters +// fd: file-descriptor obtained from RPI_serialOpen function +// +// Description +// This function returns the next character available on the serial device. This call will block for up to 10 seconds if no data is available (when it will return -1). +// +// Examples +// RPI_serialGetchar(13) +// See also +// RPI_serialOpen, RPI_serialClose, RPI_serialFlush, RPI_serialPutchar, RPI_serialPuts, RPI_serialPrintf, RPI_serialDataAvail +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sGc#1#"+string(fd)+"#"; + 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/macros/Hardware/RasberryPi/Serial/RPI_serialOpen.sci b/macros/Hardware/RasberryPi/Serial/RPI_serialOpen.sci new file mode 100755 index 0000000..684a6f2 --- /dev/null +++ b/macros/Hardware/RasberryPi/Serial/RPI_serialOpen.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_serialOpen(device,baud) +// Function to initialize a serial device +// +// Calling Sequence +// RPI_serialOpen(device,baud) +// +// Parameters +// device: device to connect to +// baud : the baud rate for communication +// +// Description +// This function opens and initialises the serial device and sets the baud rate. It sets the port into “raw” mode (character at a time and no translations), and sets the read timeout to 10 seconds. The return value is the file descriptor or -1 for any error, in which case errno will be set as appropriate. +// +// Examples +// RPI_serialOpen("/dev/ttyAMA0", 9600) +// See also +// RPI_serialClose, RPI_serialFlush, RPI_serialPutchar, RPI_serialPuts, RPI_serialPrintf, RPI_serialDataAvail, RPI_serialGetchar +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sOp#2#"+string(device)+"#"+string(baud)+"#"; + 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/macros/Hardware/RasberryPi/Serial/RPI_serialPrintf.sci b/macros/Hardware/RasberryPi/Serial/RPI_serialPrintf.sci new file mode 100755 index 0000000..668a9ff --- /dev/null +++ b/macros/Hardware/RasberryPi/Serial/RPI_serialPrintf.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_serialPrintf(fd,msg) +// Function to print to serial device +// +// Calling Sequence +// RPI_serialPrintf(fd,msg) +// +// Parameters +// fd : file-descriptor obtained from RPI_serialOpen function +// msg: message to print +// +// Description +// This function emulates the system printf function to the serial device. +// +// Examples +// RPI_serialPrintf(13,'White Collar rocks') +// See also +// RPI_serialOpen, RPI_serialClose, RPI_serialFlush, RPI_serialPutchar, RPI_serialPuts, RPI_serialDataAvail, RPI_serialGetchar +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sPf#2#"+string(fd)+"#"+string(msg)+"#"; + 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/macros/Hardware/RasberryPi/Serial/RPI_serialPutchar.sci b/macros/Hardware/RasberryPi/Serial/RPI_serialPutchar.sci new file mode 100755 index 0000000..ceea556 --- /dev/null +++ b/macros/Hardware/RasberryPi/Serial/RPI_serialPutchar.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_serialPutchar(fd,character) +// Function to send a single byte to the serial device +// +// Calling Sequence +// RPI_serialPutchar(fd,character) +// +// Parameters +// fd : file-descriptor obtained from RPI_serialOpen function +// character: character to send to the serial device +// +// Description +// This function sends the single byte to the serial device identified by the given file descriptor. +// +// Examples +// RPI_serialPutchar(113,'s') +// See also +// RPI_serialOpen, RPI_serialClose, RPI_serialFlush, RPI_serialPuts, RPI_serialPrintf, RPI_serialDataAvail, RPI_serialGetchar +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sPc#2#"+string(fd)+"#"+string(character)+"#"; + 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/macros/Hardware/RasberryPi/Serial/RPI_serialPuts.sci b/macros/Hardware/RasberryPi/Serial/RPI_serialPuts.sci new file mode 100755 index 0000000..ecbbe05 --- /dev/null +++ b/macros/Hardware/RasberryPi/Serial/RPI_serialPuts.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_serialPuts(fd,s) +// Function to send a null-terminalted string +// +// Calling Sequence +// RPI_serialPuts(fd,s) +// +// Parameters +// fd: file-descriptor obtained from RPI_serialOpen function +// s : string to send +// +// Description +// Sends the nul-terminated string to the serial device identified by the given file descriptor. +// +// Examples +// RPI_serialPuts(13,'Believe it, Dattebayo!\0') +// See also +// RPI_serialOpen, RPI_serialClose, RPI_serialFlush, RPI_serialPutchar, RPI_serialPrintf, RPI_serialDataAvail, RPI_serialGetchar +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sPs#2#"+string(fd)+"#"+string(s)+"#"; + 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/macros/Hardware/RasberryPi/Serial/buildmacros.sce b/macros/Hardware/RasberryPi/Serial/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/Serial/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/macros/Hardware/RasberryPi/Serial/names b/macros/Hardware/RasberryPi/Serial/names new file mode 100755 index 0000000..a652727 --- /dev/null +++ b/macros/Hardware/RasberryPi/Serial/names @@ -0,0 +1,8 @@ +RPI_serialClose +RPI_serialDataAvail +RPI_serialFlush +RPI_serialGetchar +RPI_serialOpen +RPI_serialPrintf +RPI_serialPutchar +RPI_serialPuts diff --git a/macros/Hardware/RasberryPi/Setup/RPI_getAlt.sci b/macros/Hardware/RasberryPi/Setup/RPI_getAlt.sci new file mode 100755 index 0000000..ba3d204 --- /dev/null +++ b/macros/Hardware/RasberryPi/Setup/RPI_getAlt.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_getAlt(pin) +// Function to get the current mode of pin +// +// Calling Sequence +// s=RPI_getAlt(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 current mode of the pin. Output will be 0 for INPUT, 1 for OUTPUT, 2 for PWM_OUT and 3 for CLOCK. +// +// Examples +// s=RPI_getAlt(0) +// See also +// RPI_pinNumbering, RPI_pinModeAlt +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="gAt#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/macros/Hardware/RasberryPi/Setup/RPI_pinMode.sci b/macros/Hardware/RasberryPi/Setup/RPI_pinMode.sci new file mode 100755 index 0000000..b6f52e6 --- /dev/null +++ b/macros/Hardware/RasberryPi/Setup/RPI_pinMode.sci @@ -0,0 +1,60 @@ +// 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_pinMode(pin,Mode) +// Function to set the mode of the given pin. +// +// Calling Sequence +// RPI_pinMode(pin,Mode) +// +// Parameters +// pin : The pin number to act on. Numbering sequence to be followed as initiated using RPI_pinNumbering function. +// Mode: The mode in which to set the pin. +// +// Description +// This function configures the Raspberry Pi's given pin to work as the given mode (input/output/pwm/clock). Not all functions are available to all the pins. +// +// Mode can take the following values- +// <itemizedlist> +// <listitem><para>'in' -> sets the pin as input</para></listitem> +// <listitem><para>'out' -> sets the pin as output</para></listitem> +// <listitem><para>'pwm' -> sets the pin to PWM output. Only wiringPi pin 1 (BCM_GPIO pin 18) supports this function.</para></listitem> +// <listitem><para>'clock' -> sets the pin to CLOCK output. Only wiringPi pin 7 (BCM_GPIO pin 4) supports this function.</para></listitem> +// </itemizedlist> +// +// Examples +// RPI_pinMode(0,'out') +// See also +// RPI_pinNumbering +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + if Mode=='in' then + commande="pnM#2#"+string(pin)+"#0#"; + elseif Mode=='out' then + commande="pnM#2#"+string(pin)+"#1#"; + elseif Mode=='pwm' then + commande="pnM#2#"+string(pin)+"#2#"; + elseif Mode=='clock' then + commande="pnM#2#"+string(pin)+"#3#"; + else + error("Mode should be one of ""in/out/pwm/clock/soft_pwm/soft_tone/pwm_tone""."); + end + 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/macros/Hardware/RasberryPi/Setup/RPI_pinModeAlt.sci b/macros/Hardware/RasberryPi/Setup/RPI_pinModeAlt.sci new file mode 100755 index 0000000..dd0fa10 --- /dev/null +++ b/macros/Hardware/RasberryPi/Setup/RPI_pinModeAlt.sci @@ -0,0 +1,55 @@ +// 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_pinModeAlt(pin,ALTMode) +// Function to set the current mode of pin +// +// Calling Sequence +// RPI_pinModeAlt(pin,ALTMode) +// +// Parameters +// pin : The pin number to read the voltage from. Numbering sequence to be followed as initiated using RPI_pinNumbering function. +// ALTMode: integer, from 0 to 7 +// +// Description +// This function sets the mode of the pin to either of the general GPIO (also set through RPI_pinMode function) or the alternatives available (not accessible through RPI_pinMode function). +// +// ALTMode can take the following values: +// <itemizedlist> +// <listitem>0 : Input</listitem> +// <listitem>1 : Output</listitem> +// <listitem>2 : ALT5</listitem> +// <listitem>3 : ALT4</listitem> +// <listitem>4 : ALT0</listitem> +// <listitem>5 : ALT1</listitem> +// <listitem>6 : ALT2</listitem> +// <listitem>7 : ALT3</listitem> +// </itemizedlist> +// +//The list of Alternate functions of all the pins can be found on page 102 of the official documentation: https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf +// +// Examples +// RPI_pinModeAlt(1,2) +// See also +// RPI_pinMode, RPI_pinNumbering, RPI_getAlt +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pMA#2#"+string(pin)+"#"+string(ALTMode)+"#"; + 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/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci b/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci new file mode 100755 index 0000000..4716de8 --- /dev/null +++ b/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci @@ -0,0 +1,54 @@ +// 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_pinNumbering(pinSetup) +// Function to initialize wiringpi with the number sequence to be followed. +// +// Calling Sequence +// RPI_pinNumbering(pinSetup) +// +// Parameters +// pinSetup: The pin number sequence to follow +// +// Description +// This function must be called at the start of the program or the program will fail to work correctly. It tells the wiringpi which number sequence will be used to work on Raspberry Pi. Returns 0 if no errors encountered. Pin maps for the different pinSetups can be found at the link in bibliography. +// +// pinSetup can take the following values: +// <itemizedlist> +// <listitem>'wiringpi' -> This initialises wiringPi and assumes that the calling program is going to be using the wiringPi pin numbering scheme. This is a simplified numbering scheme which provides a mapping from virtual pin numbers to the real underlying Broadcom GPIO pin numbers.</listitem> +// <listitem>'GPIO' -> Same as above, however it allows the calling programs to use the Broadcom GPIO pin numbers directly with no re-mapping.</listitem> +// <listitem>'phys' -> Identical to above, however it allows the calling programs to use the physical pin numbers on the P1 connector only.</listitem> +// </itemizedlist> +// +// Examples +// RPI_pinNumbering('wiringpi') +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + if (pinSetup=='wiringpi') then + commande="pN0#0#"; + elseif (pinSetup=='GPIO') then + commande="pN1#0#"; + elseif (pinSetup=='sys') then + commande="pN2#0#"; + elseif (pinSetup=='phys') then + commande="pN3#0#"; + else + error("pinSetup should be one of wiringpi/GPIO/sys/phys"); + end + 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/macros/Hardware/RasberryPi/Setup/RPI_pullControl.sci b/macros/Hardware/RasberryPi/Setup/RPI_pullControl.sci new file mode 100755 index 0000000..6354bf5 --- /dev/null +++ b/macros/Hardware/RasberryPi/Setup/RPI_pullControl.sci @@ -0,0 +1,60 @@ +// 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_pullControl(pin,RMode) +// Function to change the internal pull up/down resistor setting for a given pin. +// +// Calling Sequence +// RPI_pullControl(pin,RMode) +// +// Parameters +// pin : The pin number to act on. Numbering sequence to be followed as initiated using RPI_pinNumbering function. +// RMode: The mode for the internal resistance of the given pin. +// +// Description +// This sets the pull-up or pull-down resistor mode on the given pin, which should be set as an input using the PRI_pinMode function. The internal pull up/down +// resistors have a value of approximately 50KΩ on the Raspberry Pi. +// +// RMode can take values: +// <itemizedlist> +// <listitem>'up' -> pull to 3.3v</listitem> +// <listitem>'down'-> pull to ground</listitem> +// <listitem>'none'-> no pull up/down</listitem> +// </itemizedlist> +// +// This function has no effect on the Raspberry Pi’s GPIO pins when in sys mode, set using RPI_pinNumbering function. To activate a pull-up/pull-down, use the gpio +// program in a script before starting the program. +// +// Examples +// RPI_pullControl(0,'down') +// See also +// RPI_pinNumbering, RPI_pinMode +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + if RMode=='up' then + commande="plC#2#"+string(pin)+"#2#"; + elseif RMode=='down' then + commande="plC#2#"+string(pin)+"#1#"; + elseif RMode=='none' then + commande="plC#2#"+string(pin)+"#0#"; + else + error("mode should be one of up/down/none"); + end + 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/macros/Hardware/RasberryPi/Setup/buildmacros.sce b/macros/Hardware/RasberryPi/Setup/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/Setup/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/macros/Hardware/RasberryPi/Setup/names b/macros/Hardware/RasberryPi/Setup/names new file mode 100755 index 0000000..3895498 --- /dev/null +++ b/macros/Hardware/RasberryPi/Setup/names @@ -0,0 +1,5 @@ +RPI_getAlt +RPI_pinMode +RPI_pinModeAlt +RPI_pinNumbering +RPI_pullControl diff --git a/macros/Hardware/RasberryPi/Shift/RPI_shiftIn.sci b/macros/Hardware/RasberryPi/Shift/RPI_shiftIn.sci new file mode 100755 index 0000000..2bdb89b --- /dev/null +++ b/macros/Hardware/RasberryPi/Shift/RPI_shiftIn.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_shiftIn(dpin,cpin,order) +// Function to shift 8-bit value appearing on dpin +// +// Calling Sequence +// RPI_shiftIn(dpin,cpin,order) +// +// Parameters +// dpin : datapin +// cpin : clockpin +// order: integer, 0 (LSB first) or 1 (MSB first) +// +// Description +// This shifts an 8-bit data value in with the data appearing on the dPin and the clock being sent out on the cPin. Order is either LSBFIRST or MSBFIRST. The data is sampled after the cPin goes high. (So cPin high, sample data, cPin low, repeat for 8 bits) The 8-bit value is returned by the function. +// +// Examples +// RPI_shiftIn(0,2,0) +// See also +// RPI_shiftOut +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="shI#3#"+string(dpin)+"#"+string(cpin)+"#"+string(order)+"#"; + 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/macros/Hardware/RasberryPi/Shift/RPI_shiftOut.sci b/macros/Hardware/RasberryPi/Shift/RPI_shiftOut.sci new file mode 100755 index 0000000..c348560 --- /dev/null +++ b/macros/Hardware/RasberryPi/Shift/RPI_shiftOut.sci @@ -0,0 +1,43 @@ +// 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_shiftOut(dpin,cpin,order,val) +// Function to shift out 8-bit data with value=val +// +// Calling Sequence +// RPI_shiftOut(dpin,cpin,order,val) +// +// Parameters +// dpin : datapin +// cpin : clockpin +// order: integer, 0 (LSB first) or 1 (MSB first) +// val : integer, data to send +// +// Description +// The shifts an 8-bit data value val out with the data being sent out on dPin and the clock being sent out on the cPin. order is as above. Data is clocked out on the rising or falling edge – ie. dPin is set, then cPin is taken high then low – repeated for the 8 bits. +// +// Examples +// RPI_shiftOut(1,2,0,123) +// See also +// RPI_shiftIn +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="shO#4#"+string(dpin)+"#"+string(cpin)+"#"+string(order)+"#"+string(val)+"#"; + 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/macros/Hardware/RasberryPi/Shift/RPI_sr595Setup.sci b/macros/Hardware/RasberryPi/Shift/RPI_sr595Setup.sci new file mode 100755 index 0000000..fb77f98 --- /dev/null +++ b/macros/Hardware/RasberryPi/Shift/RPI_sr595Setup.sci @@ -0,0 +1,44 @@ +// 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_sr595Setup(pinBase,numPins,dataPin,clockPin,latchPin) +// Function to setup sr5595 shift register chips +// +// Calling Sequence +// RPI_sr595Setup(pinBase,numPins,dataPin,clockPin,latchPin) +// +// Parameters +// pinBase : any number above 64. Consecutive number of numPins will be allocated alongwith. +// numPins : number of pins, can be 0-32, 8 pins per 74x595 +// dataPin : The Raspberry pin corresponding to the 74x595's data pin. Numbering sequence to be followed as initiated by RPI_pinNumbering function. +// clockPin: The Raspberry pin corresponding to the 74x595's clock pin. Numbering sequence to be followed as initiated by RPI_pinNumbering function. +// latchPin: The Raspberry pin corresponding to the 74x595's latch pin. Numbering sequence to be followed as initiated by RPI_pinNumbering function. +// +// Description +// This function sets up the extension module for the 74×595 shift register chips which can be used as general purpose output ports. Each instance can support up to 4 74×595’s daisy-chained together, giving a 32-bit output port using just 3 GPIO wires from the Raspberry Pi (or from any other GPIO expansion port connected to the Pi) One can have as many instances of these enabled in the system, provided there are 3 spare GPIO pins per instance. +// +// Examples +// RPI_sr595Setup(100,10,0,1,2) +// See also +// RPI_sn3218Setup, RPI_pcf8574Setup, RPI_pcf8591Setup, RPI_mcp23008Setup, RPI_mcp23016Setup, RPI_mcp23017Setup, RPI_mcp23s08Setup, RPI_mcp23s17Setup, RPI_pinNumbering +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sr5#5#"+string(pinBase)+"#"+string(numPins)+"#"+string(dataPin)+"#"+string(clockPin)+"#"+string(latchPin)+"#"; + 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/macros/Hardware/RasberryPi/Shift/buildmacros.sce b/macros/Hardware/RasberryPi/Shift/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/Shift/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/macros/Hardware/RasberryPi/Shift/names b/macros/Hardware/RasberryPi/Shift/names new file mode 100755 index 0000000..3fc17b6 --- /dev/null +++ b/macros/Hardware/RasberryPi/Shift/names @@ -0,0 +1,3 @@ +RPI_shiftIn +RPI_shiftOut +RPI_sr595Setup diff --git a/macros/Hardware/RasberryPi/Soft/RPI_softPwmCreate.sci b/macros/Hardware/RasberryPi/Soft/RPI_softPwmCreate.sci new file mode 100755 index 0000000..b0161c2 --- /dev/null +++ b/macros/Hardware/RasberryPi/Soft/RPI_softPwmCreate.sci @@ -0,0 +1,44 @@ +// 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_softPwmCreate(pin,ival,pwmrange) +// Function to set up software pwm on a given pin +// +// Calling Sequence +// RPI_softPwmCreate(pin,ival,pwmrange) +// +// Parameters +// pin : pin to start software pwm on. Numbering sequence to follow as initiated using RPI_pinNumbering function +// ival : inital value +// pwmrange: range for the pwm +// +// Description +// This function creates a software controlled PWM pin. Any GPIO pin can be used. Using 100 for the range, the value can be anything from 0 (off) to 100 (fully on) for the given pin. +// +//The return value is 0 for success. Otherwise the global error number variable should be checked to see what went wrong. +// +// Examples +// RPI_softPwmCreate(1,25,250) +// See also +// RPI_softPwmStop, RPI_softPwmWrite, RPI_softToneCreate, RPI_softToneStop, RPI_softToneWrite, RPI_pinNumbering, RPI_softServoWrite, RIP_softServoSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sPC#3#"+string(pin)+"#"+string(ival)+"#"+string(pwmrange)+"#"; + 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/macros/Hardware/RasberryPi/Soft/RPI_softPwmStop.sci b/macros/Hardware/RasberryPi/Soft/RPI_softPwmStop.sci new file mode 100755 index 0000000..5a911c8 --- /dev/null +++ b/macros/Hardware/RasberryPi/Soft/RPI_softPwmStop.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 RPI_softPwmStop(pin) +// Function to stop the software pwm on the pin +// +// Calling Sequence +// RPI_softPwmStop(pin) +// +// Parameters +// pin: pin to stop. Numbering sequence to follow as initiated using RPI_pinNumbering +// +// Description +// This function stops the software pwm on the specified pin. +// +// Examples +// RPI_softPwmStop(1) +// See also +// RPI_softPwmWrite, RPI_softToneCreate, RPI_softToneStop, RPI_softToneWrite, RPI_softPwmCreate, RPI_pinNumbering, RPI_softServoWrite, RIP_softServoSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sPS#1#"+string(pin)+"#"; + 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/macros/Hardware/RasberryPi/Soft/RPI_softPwmWrite.sci b/macros/Hardware/RasberryPi/Soft/RPI_softPwmWrite.sci new file mode 100755 index 0000000..349923f --- /dev/null +++ b/macros/Hardware/RasberryPi/Soft/RPI_softPwmWrite.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_softPwmWrite(pin,value) +// Function to update the softpwm value on the pin +// +// Calling Sequence +// RPI_softPwmWrite(pin,value) +// +// Parameters +// pin : pin to act on, should be initialised using RPI_softPwmCreate. Numbering sequence follows from_RPI pinNumbering +// value: value to write +// +// Description +// This updates the PWM value on the given pin. The value is checked to be in-range and pins that haven’t previously been initialised via softPwmCreate will be silently ignored. +// +// Examples +// RPI_softPwmWrite(1,250) +// See also +// RPI_softPwmStop, RPI_softToneCreate, RPI_softToneStop, RPI_softToneWrite, RPI_softPwmCreate, RPI_pinNumbering, RPI_softServoWrite, RIP_softServoSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sPW#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/macros/Hardware/RasberryPi/Soft/RPI_softToneCreate.sci b/macros/Hardware/RasberryPi/Soft/RPI_softToneCreate.sci new file mode 100755 index 0000000..06adf83 --- /dev/null +++ b/macros/Hardware/RasberryPi/Soft/RPI_softToneCreate.sci @@ -0,0 +1,43 @@ +// 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_softToneCreate(pin) +// Function to create a software controlled tone pin +// +// Calling Sequence +// RPI_softToneCreate(pin) +// +// Parameters +// pin: pin to create software tone on. Numbering sequence to be followed as initiated using RPI_pinNumbering +// +// Description +// This function creates a software controlled tone pin. Any GPIO pin can be used. Using 100 for the range, the value can be anything from 0 (off) to 100 (fully on) for the given pin. +// +//The return value is 0 for success. Otherwise the global error number variable should be checked to see what went wrong. +// +// +// Examples +// RPI_softToneCreate(1) +// See also +// RPI_softPwmStop, RPI_softPwmWrite, RPI_softToneStop, RPI_softToneWrite, RPI_softPwmCreate, RPI_pinNumbering, RPI_softServoWrite, RIP_softServoSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sTC#1#"+string(pin)+"#"; + 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/macros/Hardware/RasberryPi/Soft/RPI_softToneStop.sci b/macros/Hardware/RasberryPi/Soft/RPI_softToneStop.sci new file mode 100755 index 0000000..4ecc420 --- /dev/null +++ b/macros/Hardware/RasberryPi/Soft/RPI_softToneStop.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 RPI_softToneStop(pin) +// Function to stop the software tone on the pin +// +// Calling Sequence +// RPI_softToneStop(pin) +// +// Parameters +// pin: soft tone pin to stop. Numbering sequence to follow as initiated using RPI_pinNumbering +// +// Description +// This function stops the software tone on the specified pin. +// +// Examples +// RPI_softToneStop(1) +// See also +// RPI_softPwmStop, RPI_softPwmWrite, RPI_softToneCreate, RPI_softToneWrite, RPI_softPwmCreate, RPI_pinNumbering, RPI_softServoWrite, RIP_softServoSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sTS#1#"+string(pin)+"#"; + 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/macros/Hardware/RasberryPi/Soft/RPI_softToneWrite.sci b/macros/Hardware/RasberryPi/Soft/RPI_softToneWrite.sci new file mode 100755 index 0000000..ba070a8 --- /dev/null +++ b/macros/Hardware/RasberryPi/Soft/RPI_softToneWrite.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_softToneWrite(pin,freq) +// Function to update tone frquency on the soft tone pin +// +// Calling Sequence +// RPI_softToneWrite(pin,freq) +// +// Parameters +// pin : soft tone pin +// freq: frequency value to write +// +// Description +// This function updates the tone frequency value on the given pin. The tone will be played until you set the frequency to 0. +// +// Examples +// RPI_softToneWrite(1,200) +// See also +// RPI_softPwmStop, RPI_softPwmWrite, RPI_softToneCreate, RPI_softToneStop, RPI_softPwmCreate, RPI_softServoWrite, RIP_softServoSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="sTW#2#"+string(pin)+"#"+string(freq)+"#"; + 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/macros/Hardware/RasberryPi/Soft/buildmacros.sce b/macros/Hardware/RasberryPi/Soft/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/Soft/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/macros/Hardware/RasberryPi/Soft/names b/macros/Hardware/RasberryPi/Soft/names new file mode 100755 index 0000000..da06cbb --- /dev/null +++ b/macros/Hardware/RasberryPi/Soft/names @@ -0,0 +1,6 @@ +RPI_softPwmCreate +RPI_softPwmStop +RPI_softPwmWrite +RPI_softToneCreate +RPI_softToneStop +RPI_softToneWrite diff --git a/macros/Hardware/RasberryPi/Timing/RPI_delay.sci b/macros/Hardware/RasberryPi/Timing/RPI_delay.sci new file mode 100755 index 0000000..bd868e8 --- /dev/null +++ b/macros/Hardware/RasberryPi/Timing/RPI_delay.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 RPI_delay(time) +// Function to introduce delay in milliseconds +// +// Calling Sequence +// RPI_delay(time) +// +// Parameters +// time: Time in milliseconds for which to pause the program execution. +// +// Description +// This causes program execution to pause for at least 'time' milliseconds. Due to the multi-tasking nature of Linux it could be longer. The maximum delay is an unsigned 32-bit integer or approximately 49 days. +// +// Examples +// RPI_delay(1000) +// See also +// RPI_delayMicro, RPI_micros, RPI_millis +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="deS#1#"+string(time)+"#"; + 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/macros/Hardware/RasberryPi/Timing/RPI_delayMicro.sci b/macros/Hardware/RasberryPi/Timing/RPI_delayMicro.sci new file mode 100755 index 0000000..a1b5d59 --- /dev/null +++ b/macros/Hardware/RasberryPi/Timing/RPI_delayMicro.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 RPI_delayMicro(time) +// Function to introduce delay in microseconds +// +// Calling Sequence +// RPI_delayMicros(time) +// +// Parameters +// time: Time in microseconds for which to pause the program execution. +// +// Description +// This causes program execution to pause for at least 'time' microseconds. Due to the multi-tasking nature of Linux it could be longer. The maximum delay is an unsigned 32-bit integer or approximately 71 minutes. +// +// Examples +// RPI_delayMicro(1000) +// See also +// RPI_delay, RPI_micros, RPI_millis +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="deU#1#"+string(time)+"#"; + 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/macros/Hardware/RasberryPi/Timing/RPI_micros.sci b/macros/Hardware/RasberryPi/Timing/RPI_micros.sci new file mode 100755 index 0000000..058a827 --- /dev/null +++ b/macros/Hardware/RasberryPi/Timing/RPI_micros.sci @@ -0,0 +1,37 @@ +// 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_micros() +// Function to display the number of microseconds since the call to RPI_pinNumbering function. +// +// Calling Sequence +// t=RPI_micros() +// +// Description +// This returns the time in milliseconds since the call to RPI_pinNumbering function. It returns an unsigned 32-bit integer which wraps after approximately 71 minutes. +// +// Examples +// t=RPI_micros() +// See also +// RPI_millis, RPI_delay, RPI_delayMicro +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="mic#0#"; + 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/macros/Hardware/RasberryPi/Timing/RPI_millis.sci b/macros/Hardware/RasberryPi/Timing/RPI_millis.sci new file mode 100755 index 0000000..baecddc --- /dev/null +++ b/macros/Hardware/RasberryPi/Timing/RPI_millis.sci @@ -0,0 +1,37 @@ +// 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_millis() +// Function to display the number of milliseconds since the call to RPI_pinNumbering function. +// +// Calling Sequence +// t=RPI_millis() +// +// Description +// This returns the time in microseconds since the call to RPI_pinNumbering function. It returns an unsigned 32-bit integer which wraps after 49 days. +// +// Examples +// t=RPI_millis() +// See also +// RPI_micros, RPI_delay, RPI_delayMicro +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="mil#0#"; + 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/macros/Hardware/RasberryPi/Timing/buildmacros.sce b/macros/Hardware/RasberryPi/Timing/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/Timing/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/macros/Hardware/RasberryPi/Timing/names b/macros/Hardware/RasberryPi/Timing/names new file mode 100755 index 0000000..0b47b34 --- /dev/null +++ b/macros/Hardware/RasberryPi/Timing/names @@ -0,0 +1,4 @@ +RPI_delay +RPI_delayMicro +RPI_micros +RPI_millis diff --git a/macros/Hardware/RasberryPi/buildmacros.sce b/macros/Hardware/RasberryPi/buildmacros.sce index 2954a42..07b564e 100644..100755 --- a/macros/Hardware/RasberryPi/buildmacros.sce +++ b/macros/Hardware/RasberryPi/buildmacros.sce @@ -1,4 +1,49 @@ +// 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')); +RPI_Directories = [ "Digital", ... + "gertBoard", ... + "I2C", ... + "Interrupt", ... + "lcd", ... + "lcd128x64", ... + "mcp", ... + "Misc", ... + "pcf", ... + "piGlow", ... + "pinMap", ... + "pwm", ... + "Serial", ... + "Setup", ... + "Shift", ... + "Soft", ... + "SPI", ... + "Timing"]; + +RPI_path_buildmacros = get_absolute_file_path("buildmacros.sce"); -clear tbx_build_macros; +for H=1:size(RPI_Directories,"*") + myfile = RPI_path_buildmacros + filesep() + RPI_Directories(H) + filesep() + "buildmacros.sce"; + if isfile(myfile) then + exec(myfile); + end +end + +clear RPI_path_buildmacros; + +function buildmacros() + macros_path = get_absolute_file_path("buildmacros.sce"); + tbx_build_macros(TOOLBOX_NAME, macros_path); + clear tbx_build_macros; +endfunction + +buildmacros(); +clear buildmacros; diff --git a/macros/Hardware/RasberryPi/cleanmacros.sce b/macros/Hardware/RasberryPi/cleanmacros.sce new file mode 100755 index 0000000..a6428b2 --- /dev/null +++ b/macros/Hardware/RasberryPi/cleanmacros.sce @@ -0,0 +1,20 @@ +// ==================================================================== +// This file is released under the 3-clause BSD license. See COPYING-BSD. +// ==================================================================== +function cleanmacros() + + libpath = get_absolute_file_path("cleanmacros.sce"); + + binfiles = ls(libpath+"/*.bin"); + for i = 1:size(binfiles,"*") + mdelete(binfiles(i)); + end + + mdelete(libpath+"/names"); + mdelete(libpath+"/lib"); +endfunction + +cleanmacros(); +clear cleanmacros; // remove cleanmacros on stack + +// ==================================================================== diff --git a/macros/Hardware/RasberryPi/gertBoard/RPI_analogRead.sci b/macros/Hardware/RasberryPi/gertBoard/RPI_analogRead.sci new file mode 100755 index 0000000..41bf877 --- /dev/null +++ b/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/macros/Hardware/RasberryPi/gertBoard/RPI_analogWrite.sci b/macros/Hardware/RasberryPi/gertBoard/RPI_analogWrite.sci new file mode 100755 index 0000000..f7089f5 --- /dev/null +++ b/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/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogRead.sci b/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogRead.sci new file mode 100755 index 0000000..ce7e870 --- /dev/null +++ b/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/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogSetup.sci b/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogSetup.sci new file mode 100755 index 0000000..a834811 --- /dev/null +++ b/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/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogWrite.sci b/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardAnalogWrite.sci new file mode 100755 index 0000000..3f8f9dd --- /dev/null +++ b/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/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardSPISetup.sci b/macros/Hardware/RasberryPi/gertBoard/RPI_gertboardSPISetup.sci new file mode 100755 index 0000000..d4117b0 --- /dev/null +++ b/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/macros/Hardware/RasberryPi/gertBoard/buildmacros.sce b/macros/Hardware/RasberryPi/gertBoard/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/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/macros/Hardware/RasberryPi/gertBoard/names b/macros/Hardware/RasberryPi/gertBoard/names new file mode 100755 index 0000000..27a469a --- /dev/null +++ b/macros/Hardware/RasberryPi/gertBoard/names @@ -0,0 +1,6 @@ +RPI_analogRead +RPI_analogWrite +RPI_gertboardAnalogRead +RPI_gertboardAnalogSetup +RPI_gertboardAnalogWrite +RPI_gertboardSPISetup diff --git a/macros/Hardware/RasberryPi/lcd/RPI_lcdCharDef.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdCharDef.sci new file mode 100755 index 0000000..905cca8 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdCharDef.sci @@ -0,0 +1,44 @@ +// 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_lcdCharDef(fd,index,d0,d1,d2,d3,d4,d5,d6,d7) +// Function to redefine a user-definable character +// +// Calling Sequence +// RPI_lcdCharDef(fd,index,data) +// +// Parameters +// fd : file-descriptor obtained using RPI_lcdInit function +// index: which character to redefine (0 to 7) +// d0-d7: integers from 0 to 255 erpresenting the elements of the array to form the character +// +// Description +// This function re-define one of the 8 user-definable characters in the display. +// +// The data array is 8 bytes which represent the character from the top-line to the bottom line. Note that the characters are actually 5×8, so only the lower 5 bits are used. +// +// Examples +// RPI_lcdCharDef(13,0,0,0,0,31,31,31,31,0) +// See also +// RPI_lcdCursorBlink, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdHome, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lCD#10#"+string(fd)+"#"+string(index)+"#"+string(d0)+"#"+string(d1)+"#"+string(d2)+"#"+string(d3)+"#"+string(d4)+"#"+string(d5)+"#"+string(d6)+"#"+string(d7)+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdClear.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdClear.sci new file mode 100755 index 0000000..6da7212 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdClear.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 RPI_lcdClear(fd) +// Function to clear the lcd screen +// +// Calling Sequence +// RPI_lcdClear(fd) +// +// Parameters +// fd: file-descriptor obtained using RPI_lcdInit function +// +// Description +// This function clears the lcd screen. +// +// Examples +// RPI_lcdClear(13) +// See also +// RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdHome, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lCl#1#"+string(fd)+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdCursor.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdCursor.sci new file mode 100755 index 0000000..98c5471 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdCursor.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_lcdCursor(fd,state) +// Function to turn cursor on/off +// +// Calling Sequence +// RPI_lcdCursor(fd,state) +// +// Parameters +// fd : file-descriptor obtained using RPI_lcdInit function +// state: 0 (for off) or 1 (for on) +// +// Description +// This function sets the visibility of cursor. +// +// Examples +// RPI_lcdCursor(13,1) +// See also +// RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdDisplay, RPI_lcdHome, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lCu#2#"+string(fd)+"#"+string(state)+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdCursorBlink.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdCursorBlink.sci new file mode 100755 index 0000000..b16ebc5 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdCursorBlink.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_lcdCursorBlink(fd,state) +// Function to turn cursor blinking on/off +// +// Calling Sequence +// RPI_lcdCursorBlink(fd,state) +// +// Parameters +// fd : file-descriptor obtained using RPI_lcdInit function +// state: 0 (for off) or 1 (for on) +// +// Description +// This function sets the blinking of cursor. +// +// Examples +// RPI_lcdCursorBlink(13,1) +// See also +// RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdHome, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lCB#2#"+string(fd)+"#"+string(state)+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdDisplay.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdDisplay.sci new file mode 100755 index 0000000..de50af6 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdDisplay.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_lcdDisplay(fd,state) +// Function to turn display on/off +// +// Calling Sequence +// RPI_lcdDisplay(fd,state) +// +// Parameters +// fd : file-descriptor obtained using RPI_lcdInit function +// state: 0 (for off) or 1 (for on) +// +// Description +// This function turns the display 'on' or 'off'. +// +// Examples +// RPI_lcdDisplay(13,1) +// See also +// RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdHome, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lDs#2#"+string(fd)+"#"+string(state)+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdHome.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdHome.sci new file mode 100755 index 0000000..0c4507f --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdHome.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 RPI_lcdHome(fd) +// Function to send cursor back to the starting point (home) +// +// Calling Sequence +// RPI_lcdHome(fd) +// +// Parameters +// fd: file-descriptor obtained using RPI_lcdInit function +// +// Description +// This function sends the cursor to the top left (row=0,col=0) position on the lcd screen. +// +// Examples +// RPI_lcdHome(13) +// See also +// RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lHo#1#"+string(fd)+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdInit.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdInit.sci new file mode 100755 index 0000000..c5ddb1e --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdInit.sci @@ -0,0 +1,54 @@ +// 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_lcdInit(rows,cols,bits,rs,strb,d0,d1,d2,d3,d4,d5,d6,d7) +// Function to initialize lcd +// +// Calling Sequence +// RPI_lcdInit(rows,cols,bits,rs,strb,d0,d1,d2,d3,d4,d5,d6,d7) +// +// Parameters +// rows: numer of rows in lcd +// cols: numer of colums in lcd +// bits: number of bits wide on the interface (4 or 8) +// rs : pin number of display RS +// strb: pin number of strobe (E) +// d0 : pin number of data pin 1 +// d1 : pin number of data pin 2 +// d2 : pin number of data pin 3 +// d3 : pin number of data pin 4 +// d4 : pin number of data pin 5 +// d5 : pin number of data pin 6 +// d6 : pin number of data pin 7 +// d7 : pin number of data pin 8 +// +// Description +// This function initalizes an lcd display attaced to the Raspberry pi. The return value is the file-descriptor to be used for all subsequent calls to the lcd library when dealing with that LCD, or -1 to indicate a fault. (Usually incorrect parameters) +// +// The numberin sequence to be followed as initiated using RPI_pinNumbering +// +// Examples +// fd=RPI_lcdInit (2,16,8,11,10,0,1,2,3,4,5,6,7) ; +// See also +// RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdHome, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand, RPI_pinNumbering +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lIn#13#"+string(rows)+"#"+string(cols)+"#"+string(bits)+"#"+string(rs)+"#"+string(strb)+"#"+string(d0)+"#"+string(d1)+"#"+string(d2)+"#"+string(d3)+"#"+string(d4)+"#"+string(d5)+"#"+string(d6)+"#"+string(d7)+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdPosition.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdPosition.sci new file mode 100755 index 0000000..0f97832 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdPosition.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_lcdPosition(fd,col,row) +// Function to move the cursor +// +// Calling Sequence +// RPI_lcdPosition(fd,col,row) +// +// Parameters +// fd : file-descriptor obtained using RPI_lcdInit function +// col: column number to go to +// row: row number to go to +// +// Description +// This function set the position of the cursor for subsequent text entry. col=0 is the left-most edge any row=0 is the top line. +// +// Examples +// RPI_lcdPosition(13,0,1) +// See also +// RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdHome, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lPo#3#"+string(fd)+"#"+string(col)+"#"+string(row)+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdPrintf.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdPrintf.sci new file mode 100755 index 0000000..833bf44 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdPrintf.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_lcdPrintf(fd,String) +// Function to print on the lcd screen +// +// Calling Sequence +// RPI_lcdPrintf(fd,String) +// +// Parameters +// fd : file-descriptor obtained using RPI_lcdInit function +// String: string to print on the screen +// +// Description +// This function outputs a single ASCII character, a string or a formatted string using the usual printf formatting commands. +// +// Examples +// RPI_lcdPrintf(13,'We live in the shadows to serve the light.') +// See also +// RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdHome, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lPf#2#"+string(fd)+"#"+String+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdPutchar.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdPutchar.sci new file mode 100755 index 0000000..337691d --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdPutchar.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_lcdPutchar(fd,character) +// Function to print on the lcd screen +// +// Calling Sequence +// RPI_lcdPutchar(fd,charcter) +// +// Parameters +// fd : file-descriptor obtained using RPI_lcdInit function +// charcter: integer, 0 to 255, character to print +// +// Description +// This function outputs a single ASCII character, a string or a formatted string using the usual printf formatting commands. +// +// Examples +// RPI_lcdPutchar(13,200) +// See also +// RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdHome, RPI_lcdInit, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lPc#2#"+string(fd)+"#"+string(character)+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdPuts.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdPuts.sci new file mode 100755 index 0000000..8584309 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdPuts.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_lcdPuts(fd,character) +// Function to print on the lcd screen +// +// Calling Sequence +// RPI_lcdPuts(fd,character) +// +// Parameters +// fd : file-descriptor obtained using RPI_lcdInit function +// character: character to print +// +// Description +// This function outputs a single ASCII character, a string or a formatted string using the usual printf formatting commands. +// +// Examples +// RPI_lcdPuts(13,'K') +// See also +// RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdHome, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lPu#2#"+string(fd)+"#"+string(character)+"#"; + 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/macros/Hardware/RasberryPi/lcd/RPI_lcdSendCommand.sci b/macros/Hardware/RasberryPi/lcd/RPI_lcdSendCommand.sci new file mode 100755 index 0000000..db677be --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/RPI_lcdSendCommand.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_lcdSendCommand(fd,command) +// Function to send command to lcd +// +// Calling Sequence +// RPI_lcdSendCommand(fd,command) +// +// Parameters +// fd : file-descriptor obtained using RPI_lcdInit function +// command: A command, binary, to submit to the LCD. +// +// Description +// This function sends any arbitrary command to the LCD. +// +// Examples +// RPI_lcdSendCommand(13,00) +// See also +// RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdHome, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="lSC#2#"+string(fd)+"#"+string(command)+"#"; + 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/macros/Hardware/RasberryPi/lcd/buildmacros.sce b/macros/Hardware/RasberryPi/lcd/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/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/macros/Hardware/RasberryPi/lcd/names b/macros/Hardware/RasberryPi/lcd/names new file mode 100755 index 0000000..8f87ff8 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd/names @@ -0,0 +1,12 @@ +RPI_lcdCharDef +RPI_lcdClear +RPI_lcdCursor +RPI_lcdCursorBlink +RPI_lcdDisplay +RPI_lcdHome +RPI_lcdInit +RPI_lcdPosition +RPI_lcdPrintf +RPI_lcdPutchar +RPI_lcdPuts +RPI_lcdSendCommand diff --git a/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64Orientation.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64Orientation.sci new file mode 100755 index 0000000..5bfe4dc --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64Orientation.sci @@ -0,0 +1,48 @@ +// 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_lcd128x64Orientation(mode) +// Function to set lcd orientation. +// +// Calling Sequence +// RPI_lcd128x64Orientation(mode) +// +// Parameters +// mode: Orientation Mode, integer from 0 to 3 +// +// Description +// This function sets the orientation of the lcd display. +// +// mode can take values: +// <itemizedlist> +// <listitem>0 :Portrait</listitem> +// <listitem>1 :Landscape</listitem> +// <listitem>2 :Portrait, flipped</listitem> +// <listitem>3 :Landscape, flipped</listitem> +// </itemizedlist> +// +// Examples +// RPI_lcd128x64Orientation(1) +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="LOn#1#"+string(mode)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64circle.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64circle.sci new file mode 100755 index 0000000..96358a3 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64circle.sci @@ -0,0 +1,44 @@ +// 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_lcd128x64circle(x,y,r,color,fill) +// Function to draw a circle +// +// Calling Sequence +// RPI_lcd128x64circle(x,y,r,color,fill) +// +// Parameters +// x : integer, x coordinate of centre +// y : integer, y coordinate of centre +// r : integer, radius of the circle +// color: integer, color of the rectangle +// fill : 0 (for empty) or 1 (for filled) +// +// Description +// This function draws a circle of radius r with x,y as centre, specified color and fill. +// +// Examples +// RPI_lcd128x64circle(3,3,2,0,0) +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="Lci#5#"+string(x)+"#"+string(y)+"#"+string(r)+"#"+string(color)+"#"+string(fill)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64clear.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64clear.sci new file mode 100755 index 0000000..5b80049 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64clear.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 RPI_lcd128x64clear(color) +// Function to clear the lcd screen +// +// Calling Sequence +// RPI_lcd128x64clear(color) +// +// Parameters +// color: integer, color of the lcd +// +// Description +// This function clears the lcd display to the given colour. +// +// Examples +// RPI_lcd128x64clear(0) +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="LCl#1#"+string(color)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64ellipse.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64ellipse.sci new file mode 100755 index 0000000..b4281e6 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64ellipse.sci @@ -0,0 +1,45 @@ +// 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_lcd128x64ellipse(cx,cy,xr,yr,color,fill) +// Function to draw a ellipse +// +// Calling Sequence +// RPI_lcd128x64ellipse(cx,cy,xr,yr,color,fill) +// +// Parameters +// cx : integer, x coordinate of centre +// cy : integer, y coordinate of centre +// xr : integer, x radius +// yr : integer, y radius +// color: integer, color pf the ellipse +// fill : 0 (for empty) or 1 (for filled) +// +// Description +// This function draws an ellipse with centre at (cx,cy) x and y radii as xr and yr, specified color and fill +// +// Examples +// RPI_lcd128x64ellipse() +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="Lel#6#"+string(cx)+"#"+string(cy)+"#"+string(xr)+"#"+string(yr)+"#"+string(color)+"#"+string(fill)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64line.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64line.sci new file mode 100755 index 0000000..951a663 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64line.sci @@ -0,0 +1,44 @@ +// 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_lcd128x64line(x0,y0,x1,y1,color) +// Function to plota line. +// +// Calling Sequence +// RPI_lcd128x64line(x0,y0,x1,y1,color) +// +// Parameters +// x0 : integer, initial x coordinate +// y0 : integer, initial y coordinate +// x1 : integer, final x coordinate +// y1 : integer, final y coordinate +// color: integer, color of the line +// +// Description +// This function plots a line from (x0,y0) to (x1,y1). +// +// Examples +// RPI_lcd128x64line(0,0,1,1,0) +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="Lli#5#"+string(x0)+"#"+string(y0)+"#"+string(x1)+"#"+string(y1)+"#"+string(color)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64lineTo.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64lineTo.sci new file mode 100755 index 0000000..466713e --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64lineTo.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_lcd128x64lineTo(x,y,color) +// Function to plot a line +// +// Calling Sequence +// RPI_lcd128x64lineTo(x,y,color) +// +// Parameters +// x : integer, final x coordinate +// y : integer, final y coordinate +// color: integer, color of the line +// +// Description +// This function draws a line from the current position to the point (x,y) specified. +// +// Examples +// RPI_lcd128x64lineTo(2,2,0) +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="LlT#3#"+string(x)+"#"+string(y)+"#"+string(color)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64point.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64point.sci new file mode 100755 index 0000000..287b022 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64point.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_lcd128x64point(x,y,color) +// Function to plot a point +// +// Calling Sequence +// RPI_lcd128x64point(x,y,color) +// +// Parameters +// x : integer, x coordinate +// y : integer, y coordinate +// color: integer, color of the point +// +// Description +// This function plots a point at x,y. +// +// Examples +// RPI_lcd128x64point(2,2,0) +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="Lpo#3#"+string(x)+"#"+string(y)+"#"+string(color)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64putchar.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64putchar.sci new file mode 100755 index 0000000..a6b2724 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64putchar.sci @@ -0,0 +1,44 @@ +// 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_lcd128x64putchar(x,y,c,bg,fg) +// Function to print a single character. +// +// Calling Sequence +// RPI_lcd128x64putchar(x,y,c,bg,fg) +// +// Parameters +// x : integer, x coordinate of starting point +// y : integer, y coordinate of starting point +// c : integer, from 0 to 255, character to print +// bg: integer, background color +// fg: integer, foreground color +// +// Description +// This function prints a single character to the screen. +// +// Examples +// RPI_lcd128x64putchar(0,1,128,1,0) +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="Lpc#5#"+string(x)+"#"+string(y)+"#"+string(c)+"#"+string(bg)+"#"+string(fg)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64puts.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64puts.sci new file mode 100755 index 0000000..6785f06 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64puts.sci @@ -0,0 +1,44 @@ +// 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_lcd128x64puts(x,y,s,bf,fg) +// Function to send a string to the lcd display +// +// Calling Sequence +// RPI_lcd128x64puts(x,y,s,bg,fg) +// +// Parameters +// x : integer, x coordinate of starting point +// y : integer, y coordinate of starting point +// s : string to send +// bg: integer, background color +// fg: integer, foreground color +// +// Description +// This function sends a string to the display. Obeys \n and \r formatting. +// +// Examples +// RPI_lcd128x64puts(0,0,'Talos guide you',0,1) +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="LPu#5#"+string(x)+"#"+string(y)+"#"+string(s)+"#"+string(bg)+"#"+string(fg)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64rectangle.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64rectangle.sci new file mode 100755 index 0000000..ccda4c6 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64rectangle.sci @@ -0,0 +1,45 @@ +// 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_lcd128x64rectangle(x1,y1,x2,y2,color,fill) +// Function to draw a rectangle +// +// Calling Sequence +// RPI_lcd128x64rectangle(x1,y1,x2,y2,color,fill) +// +// Parameters +// x1 : integer, x coordinate of upper left corner +// y1 : integer, y coordinate of upper left corner +// x2 : integer, x coordinate of lower right corner +// y2 : integer, y coordinate of lower right corner +// color: integer, color of the rectangle +// fill : 0 (for empty) or 1 (for filled) +// +// Description +// This function draws a rectangle with (x1,y1) as the upper left point and (x2,y2) as the lower right point with specified color and fill. +// +// Examples +// RPI_lcd128x64rectangle(0,0,1,1,0,1) +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="Lre#6#"+string(x1)+"#"+string(y1)+"#"+string(x2)+"#"+string(y2)+"#"+string(color)+"#"+string(fill)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64setOrigin.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64setOrigin.sci new file mode 100755 index 0000000..996b062 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64setOrigin.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_lcd128x64setOrigin(x,y) +// Function to set origin +// +// Calling Sequence +// RPI_lcd128x64setOrigin(x,y) +// +// Parameters +// x: x coordinate +// y: y coordinate +// +// Description +// This function sets the origin of the lcd display +// +// Examples +// RPI_lcd128x64setOrigin(1,0) +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="LOr#2#"+string(x)+"#"+string(y)+"#"; + 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/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64setup.sci b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64setup.sci new file mode 100755 index 0000000..60ded7d --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/RPI_lcd128x64setup.sci @@ -0,0 +1,37 @@ +// 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_lcd128x64setup() +// Function to initialize the lcd display +// +// Calling Sequence +// RPI_lcd128x64setup() +// +// Description +// This function initialises the lcd display. +// +// Examples +// RPI_lcd128x64setup() +// See also +// RPI_lcd128x64setup, RPI_lcd128x64update, RPI_lcd128x64setOrigin, RPI_lcd128x64Orientation, RPI_lcd128x64orientCoord, RPI_lcd128x64ScreenSize, RPI_lcd128x64point, RPI_lcd128x64line, RPI_lcd128x64lineTo, RPI_lcd128x64rectangle, RPI_lcd128x64circle, RPI_lcd128x64ellipse, RPI_lcd128x64putchar, RPI_lcd128x64puts, RPI_lcd128x64clear, RPI_lcdCursorBlink, RPI_lcdCharDef, RPI_lcdClear, RPI_lcdCursor, RPI_lcdDisplay, RPI_lcdInit, RPI_lcdPutchar, RPI_lcdPosition, RPI_lcdPrintf, RPI_lcdPuts, RPI_lcdSendCommand +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="Lse#0#"; + 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/macros/Hardware/RasberryPi/lcd128x64/buildmacros.sce b/macros/Hardware/RasberryPi/lcd128x64/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/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/macros/Hardware/RasberryPi/lcd128x64/names b/macros/Hardware/RasberryPi/lcd128x64/names new file mode 100755 index 0000000..8243971 --- /dev/null +++ b/macros/Hardware/RasberryPi/lcd128x64/names @@ -0,0 +1,12 @@ +RPI_lcd128x64Orientation +RPI_lcd128x64circle +RPI_lcd128x64clear +RPI_lcd128x64ellipse +RPI_lcd128x64line +RPI_lcd128x64lineTo +RPI_lcd128x64point +RPI_lcd128x64putchar +RPI_lcd128x64puts +RPI_lcd128x64rectangle +RPI_lcd128x64setOrigin +RPI_lcd128x64setup diff --git a/macros/Hardware/RasberryPi/lib b/macros/Hardware/RasberryPi/lib Binary files differdeleted file mode 100644 index dc759fe..0000000 --- a/macros/Hardware/RasberryPi/lib +++ /dev/null diff --git a/macros/Hardware/RasberryPi/mcp/RPI_mcp23008Setup.sci b/macros/Hardware/RasberryPi/mcp/RPI_mcp23008Setup.sci new file mode 100755 index 0000000..03963bd --- /dev/null +++ b/macros/Hardware/RasberryPi/mcp/RPI_mcp23008Setup.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_mcp23008Setup(pinBase,i2cAddress) +// Function for setting up 8-bit MCP23008 I2C GPIO expansion chip. +// +// Calling Sequence +// RPI_mcp23008Setup(pinBase,i2cAddress) +// +// Parameters +// pinBase : any number above 64. The consecutive 8 pins will be allocated alongwith. +// i2cAdress: integer, the I2C address obtained using RPI_i2cdetect function +// +// Description +// This function sets up the extension module for the 8-bit MCP23008 I2C GPIO expansion chip. +// +// Examples +// RPI_mcp23008Setup(73,64) +// See also +// RPI_sr595Setup, RPI_pcf8574Setup, RPI_pcf8591Setup, RPI_mcp23016Setup, RPI_mcp23017Setup, RPI_mcp23s08Setup, RPI_mcp23s17Setup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="mp8#2#"+string(pinBase)+"#"+string(i2cAddress)+"#"; + 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/macros/Hardware/RasberryPi/mcp/RPI_mcp23016Setup.sci b/macros/Hardware/RasberryPi/mcp/RPI_mcp23016Setup.sci new file mode 100755 index 0000000..0424616 --- /dev/null +++ b/macros/Hardware/RasberryPi/mcp/RPI_mcp23016Setup.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_mcp23016Setup(pinBase,i2cAddress) +// Function for setting up 16-bit MCP23016 I2C GPIO expansion chip. +// +// Calling Sequence +// RPI_mcp23016Setup(pinBase,i2cAddress) +// +// Parameters +// pinBase : any number above 64. The consecutive 16 pins will be allocated alongwith. +// i2cAdress: integer, the I2C address obtained using RPI_i2cdetect function +// +// Description +// This function sets up the extension module for the MCP23017 (16-bit) I2C GPIO expansion chips. The MCP23016 is the fore-runner of the MCP23017 GPIO expansion chip and may be present on some older interface boards. +// +// Examples +// RPI_mcp23016Setup(73,100) +// See also +// RPI_sr595Setup, RPI_pcf8574Setup, RPI_pcf8591Setup, RPI_mcp23008Setup, RPI_mcp23017Setup, RPI_mcp23s08Setup, RPI_mcp23s17Setup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="mp6#2#"+string(pinBase)+"#"+string(i2cAddress)+"#"; + 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/macros/Hardware/RasberryPi/mcp/RPI_mcp23017Setup.sci b/macros/Hardware/RasberryPi/mcp/RPI_mcp23017Setup.sci new file mode 100755 index 0000000..c453ebb --- /dev/null +++ b/macros/Hardware/RasberryPi/mcp/RPI_mcp23017Setup.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_mcp23017Setup(pinBase,i2cAddress) +// Function for setting up 16-bit MCP23017 I2C GPIO expansion chip. +// +// Calling Sequence +// RPI_mcp23017Setup(pinBase,i2cAddress) +// +// Parameters +// pinBase : any number above 64. The consecutive 16 pins will be allocated alongwith. +// i2cAdress: integer, the I2C address obtained using RPI_i2cdetect function +// +// Description +// This function setups the extension module for the 16-bit MCP23017 I2C GPIO expansion chip. +// +// Examples +// RPI_mcp23017Setup(73,100) +// See also +// RPI_sr595Setup, RPI_pcf8574Setup, RPI_pcf8591Setup, RPI_mcp23008Setup, RPI_mcp23016Setup, RPI_mcp23s08Setup, RPI_mcp23s17Setup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="mp7#2#"+string(pinBase)+"#"+string(i2cAddress)+"#"; + 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/macros/Hardware/RasberryPi/mcp/RPI_mcp23s08Setup.sci b/macros/Hardware/RasberryPi/mcp/RPI_mcp23s08Setup.sci new file mode 100755 index 0000000..b5b215b --- /dev/null +++ b/macros/Hardware/RasberryPi/mcp/RPI_mcp23s08Setup.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_mcp23s08Setup(pinBase,spiPort,devId) +// Function for setting up 8-bit MCP23s08 SPI GPIO expansion chip. +// +// Calling Sequence +// RPI_mcp23s08Setup(pinBase,spiPort,devId) +// +// Parameters +// pinBase: any number above 64. The consecutive 8 pins will be allocated alongwith. +// spiPort: 0 or 1 for one of the two SPI ports on the Raspberry Pi. +// devId : the ID of the MCP23s08 on the SPI port. +// +// Description +// This function setups the extension module for the 8-bit MCP23s08 SPI GPIO expansion chip. +// +// Examples +// RPI_mcp23s08Setup(67,1,0) +// See also +// RPI_sr595Setup, RPI_pcf8574Setup, RPI_pcf8591Setup, RPI_mcp23008Setup, RPI_mcp23016Setup, RPI_mcp23017Setup, RPI_mcp23s17Setup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="ms8#3#"+string(pinBase)+"#"+string(spiPort)+"#"+string(devId)+"#"; + 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/macros/Hardware/RasberryPi/mcp/RPI_mcp23s17Setup.sci b/macros/Hardware/RasberryPi/mcp/RPI_mcp23s17Setup.sci new file mode 100755 index 0000000..4ba9fd6 --- /dev/null +++ b/macros/Hardware/RasberryPi/mcp/RPI_mcp23s17Setup.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_mcp23s17Setup(pinBase,spiPort,devId) +// Function for setting up 16-bit MCP23s17 SPI GPIO expansion chip. +// +// Calling Sequence +// RPI_mcp23s17Setup(pinBase,spiPort,devId) +// +// Parameters +// pinBase: any number above 64. The consecutive 16 pins will be allocated alongwith. +// spiPort: 0 or 1 for one of the two SPI ports on the Raspberry Pi. +// devId : the ID of the MCP23s17 on the SPI port. +// +// Description +// This function setups the extension module for the 16-bit MCP23s17 SPI GPIO expansion chip. +// +// Examples +// RPI_mcp23s17Setup(67,0,0) +// See also +// RPI_sr595Setup, RPI_pcf8574Setup, RPI_pcf8591Setup, RPI_mcp23008Setup, RPI_mcp23016Setup, RPI_mcp23017Setup, RPI_mcp23s08Setup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="ms7#3#"+string(pinBase)+"#"+string(spiPort)+"#"+string(devId)+"#"; + 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/macros/Hardware/RasberryPi/mcp/buildmacros.sce b/macros/Hardware/RasberryPi/mcp/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/mcp/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/macros/Hardware/RasberryPi/mcp/names b/macros/Hardware/RasberryPi/mcp/names new file mode 100755 index 0000000..23e7af0 --- /dev/null +++ b/macros/Hardware/RasberryPi/mcp/names @@ -0,0 +1,5 @@ +RPI_mcp23008Setup +RPI_mcp23016Setup +RPI_mcp23017Setup +RPI_mcp23s08Setup +RPI_mcp23s17Setup diff --git a/macros/Hardware/RasberryPi/names b/macros/Hardware/RasberryPi/names index fa64776..9f20c93 100644..100755 --- a/macros/Hardware/RasberryPi/names +++ b/macros/Hardware/RasberryPi/names @@ -1,21 +1,5 @@ GetRPISupportFunctions IsRPISupportFunction -RPI_DelayMicro -RPI_DelayMilli -RPI_DigitalIn -RPI_DigitalOut -RPI_DigitalSetup -RPI_GetMicros -RPI_GetMillis -RPI_HardPWMSetClock -RPI_HardPWMSetMode -RPI_HardPWMSetRange -RPI_HardPWMWrite -RPI_PinISR -RPI_SerialClose -RPI_SerialFlush -RPI_SerialGetChar -RPI_SerialSendChar -RPI_SerialSendData -RPI_SerialSetup -u16RPISerialDataAvail +RPI_adress +raspi +raspi_close diff --git a/macros/Hardware/RasberryPi/old/GetRPISupportFunctions.sci b/macros/Hardware/RasberryPi/old/GetRPISupportFunctions.sci new file mode 100644 index 0000000..3e6397b --- /dev/null +++ b/macros/Hardware/RasberryPi/old/GetRPISupportFunctions.sci @@ -0,0 +1,48 @@ +function RPiSupportFunctions = GetRPISupportFunctions() +// ----------------------------------------------------------------- +// Get list of RPI peripherals supported +// +// Input data: +// None +// +// Output data: +// None +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in +// +// ----------------------------------------------------------------- + +RPiSupportFunctions = [ + "RPI_DigitalIn" + "RPI_DigitalOut" + "RPI_DigitalSetup" + "RPI_DelayMilli" + "RPI_DelayMicro" + "RPI_GetMillis" + "RPI_GetMicros" + "RPI_SerialSetup" + "RPI_SerialClose" + "RPI_SerialSendChar" + "RPI_SerialFlush" + "RPI_SerialGetChar" + "RPI_ThreadCreate" + "RPI_PinISR" + "RPI_HardPWMWrite" + "RPI_HardPWMSetRange" + "RPI_HardPWMSetClock" + "RPI_HardPWMSetMode" + ]; + +//Note: "RPI_SerialSendData" is removed since distinction between input data +//types is required + + +endfunction diff --git a/macros/Hardware/RasberryPi/old/IsRPISupportFunction.sci b/macros/Hardware/RasberryPi/old/IsRPISupportFunction.sci new file mode 100644 index 0000000..c6a2c36 --- /dev/null +++ b/macros/Hardware/RasberryPi/old/IsRPISupportFunction.sci @@ -0,0 +1,32 @@ +function Output = IsRPISupportFunction(FunName) +// ----------------------------------------------------------------- +// Check whether input function name is a RPi support function or not. +// +// Input data: +// FunName: Name of the function to be checked +// +// Output data: +// Output: True or False depending whether given function is a RPi +// support functions or not +// +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in +// +// ----------------------------------------------------------------- + +//Get list of supported functions for AVR +RPISupportFunctions = GetRPISupportFunctions(); + +//Check whether input function is present in above list or not +FunNameInRPISupport = members(FunName,RPISupportFunctions); +Output = bool2s(FunNameInRPISupport~=0); + +endfunction diff --git a/macros/Hardware/RasberryPi/RPI_DelayMicro.sci b/macros/Hardware/RasberryPi/old/RPI_DelayMicro.sci index bbb0bb3..bbb0bb3 100644 --- a/macros/Hardware/RasberryPi/RPI_DelayMicro.sci +++ b/macros/Hardware/RasberryPi/old/RPI_DelayMicro.sci diff --git a/macros/Hardware/RasberryPi/RPI_DelayMilli.sci b/macros/Hardware/RasberryPi/old/RPI_DelayMilli.sci index 13b7962..13b7962 100644 --- a/macros/Hardware/RasberryPi/RPI_DelayMilli.sci +++ b/macros/Hardware/RasberryPi/old/RPI_DelayMilli.sci diff --git a/macros/Hardware/RasberryPi/RPI_DigitalIn.sci b/macros/Hardware/RasberryPi/old/RPI_DigitalIn.sci index 781c49c..781c49c 100644 --- a/macros/Hardware/RasberryPi/RPI_DigitalIn.sci +++ b/macros/Hardware/RasberryPi/old/RPI_DigitalIn.sci diff --git a/macros/Hardware/RasberryPi/RPI_DigitalOut.sci b/macros/Hardware/RasberryPi/old/RPI_DigitalOut.sci index dde3c93..dde3c93 100644 --- a/macros/Hardware/RasberryPi/RPI_DigitalOut.sci +++ b/macros/Hardware/RasberryPi/old/RPI_DigitalOut.sci diff --git a/macros/Hardware/RasberryPi/RPI_DigitalSetup.sci b/macros/Hardware/RasberryPi/old/RPI_DigitalSetup.sci index 01d6e07..01d6e07 100644 --- a/macros/Hardware/RasberryPi/RPI_DigitalSetup.sci +++ b/macros/Hardware/RasberryPi/old/RPI_DigitalSetup.sci diff --git a/macros/Hardware/RasberryPi/RPI_GetMicros.sci b/macros/Hardware/RasberryPi/old/RPI_GetMicros.sci index 6c4db57..6c4db57 100644 --- a/macros/Hardware/RasberryPi/RPI_GetMicros.sci +++ b/macros/Hardware/RasberryPi/old/RPI_GetMicros.sci diff --git a/macros/Hardware/RasberryPi/RPI_GetMillis.sci b/macros/Hardware/RasberryPi/old/RPI_GetMillis.sci index c034a70..c034a70 100644 --- a/macros/Hardware/RasberryPi/RPI_GetMillis.sci +++ b/macros/Hardware/RasberryPi/old/RPI_GetMillis.sci diff --git a/macros/Hardware/RasberryPi/RPI_HardPWMSetClock.sci b/macros/Hardware/RasberryPi/old/RPI_HardPWMSetClock.sci index 8448d36..8448d36 100644 --- a/macros/Hardware/RasberryPi/RPI_HardPWMSetClock.sci +++ b/macros/Hardware/RasberryPi/old/RPI_HardPWMSetClock.sci diff --git a/macros/Hardware/RasberryPi/RPI_HardPWMSetMode.sci b/macros/Hardware/RasberryPi/old/RPI_HardPWMSetMode.sci index 57b8260..57b8260 100644 --- a/macros/Hardware/RasberryPi/RPI_HardPWMSetMode.sci +++ b/macros/Hardware/RasberryPi/old/RPI_HardPWMSetMode.sci diff --git a/macros/Hardware/RasberryPi/RPI_HardPWMSetRange.sci b/macros/Hardware/RasberryPi/old/RPI_HardPWMSetRange.sci index c2075e2..c2075e2 100644 --- a/macros/Hardware/RasberryPi/RPI_HardPWMSetRange.sci +++ b/macros/Hardware/RasberryPi/old/RPI_HardPWMSetRange.sci diff --git a/macros/Hardware/RasberryPi/RPI_HardPWMWrite.sci b/macros/Hardware/RasberryPi/old/RPI_HardPWMWrite.sci index dba5e67..dba5e67 100644 --- a/macros/Hardware/RasberryPi/RPI_HardPWMWrite.sci +++ b/macros/Hardware/RasberryPi/old/RPI_HardPWMWrite.sci diff --git a/macros/Hardware/RasberryPi/RPI_PinISR.sci b/macros/Hardware/RasberryPi/old/RPI_PinISR.sci index c2354c1..c2354c1 100644 --- a/macros/Hardware/RasberryPi/RPI_PinISR.sci +++ b/macros/Hardware/RasberryPi/old/RPI_PinISR.sci diff --git a/macros/Hardware/RasberryPi/RPI_SerialClose.sci b/macros/Hardware/RasberryPi/old/RPI_SerialClose.sci index f27dd43..f27dd43 100644 --- a/macros/Hardware/RasberryPi/RPI_SerialClose.sci +++ b/macros/Hardware/RasberryPi/old/RPI_SerialClose.sci diff --git a/macros/Hardware/RasberryPi/RPI_SerialFlush.sci b/macros/Hardware/RasberryPi/old/RPI_SerialFlush.sci index 9bab386..9bab386 100644 --- a/macros/Hardware/RasberryPi/RPI_SerialFlush.sci +++ b/macros/Hardware/RasberryPi/old/RPI_SerialFlush.sci diff --git a/macros/Hardware/RasberryPi/RPI_SerialGetChar.sci b/macros/Hardware/RasberryPi/old/RPI_SerialGetChar.sci index a26e5b9..a26e5b9 100644 --- a/macros/Hardware/RasberryPi/RPI_SerialGetChar.sci +++ b/macros/Hardware/RasberryPi/old/RPI_SerialGetChar.sci diff --git a/macros/Hardware/RasberryPi/RPI_SerialSendChar.sci b/macros/Hardware/RasberryPi/old/RPI_SerialSendChar.sci index 769b21d..769b21d 100644 --- a/macros/Hardware/RasberryPi/RPI_SerialSendChar.sci +++ b/macros/Hardware/RasberryPi/old/RPI_SerialSendChar.sci diff --git a/macros/Hardware/RasberryPi/RPI_SerialSendData.sci b/macros/Hardware/RasberryPi/old/RPI_SerialSendData.sci index c05852b..c05852b 100644 --- a/macros/Hardware/RasberryPi/RPI_SerialSendData.sci +++ b/macros/Hardware/RasberryPi/old/RPI_SerialSendData.sci diff --git a/macros/Hardware/RasberryPi/RPI_SerialSetup.sci b/macros/Hardware/RasberryPi/old/RPI_SerialSetup.sci index 0f26661..0f26661 100644 --- a/macros/Hardware/RasberryPi/RPI_SerialSetup.sci +++ b/macros/Hardware/RasberryPi/old/RPI_SerialSetup.sci diff --git a/macros/Hardware/RasberryPi/old/buildmacros.sce b/macros/Hardware/RasberryPi/old/buildmacros.sce new file mode 100644 index 0000000..2954a42 --- /dev/null +++ b/macros/Hardware/RasberryPi/old/buildmacros.sce @@ -0,0 +1,4 @@ + +tbx_build_macros(TOOLBOX_NAME, get_absolute_file_path('buildmacros.sce')); + +clear tbx_build_macros; diff --git a/macros/Hardware/RasberryPi/old/names b/macros/Hardware/RasberryPi/old/names new file mode 100644 index 0000000..fa64776 --- /dev/null +++ b/macros/Hardware/RasberryPi/old/names @@ -0,0 +1,21 @@ +GetRPISupportFunctions +IsRPISupportFunction +RPI_DelayMicro +RPI_DelayMilli +RPI_DigitalIn +RPI_DigitalOut +RPI_DigitalSetup +RPI_GetMicros +RPI_GetMillis +RPI_HardPWMSetClock +RPI_HardPWMSetMode +RPI_HardPWMSetRange +RPI_HardPWMWrite +RPI_PinISR +RPI_SerialClose +RPI_SerialFlush +RPI_SerialGetChar +RPI_SerialSendChar +RPI_SerialSendData +RPI_SerialSetup +u16RPISerialDataAvail diff --git a/macros/Hardware/RasberryPi/u16RPISerialDataAvail.sci b/macros/Hardware/RasberryPi/old/u16RPISerialDataAvail.sci index 6eb29a1..6eb29a1 100644 --- a/macros/Hardware/RasberryPi/u16RPISerialDataAvail.sci +++ b/macros/Hardware/RasberryPi/old/u16RPISerialDataAvail.sci diff --git a/macros/Hardware/RasberryPi/pcf/RPI_pcf8574Setup.sci b/macros/Hardware/RasberryPi/pcf/RPI_pcf8574Setup.sci new file mode 100755 index 0000000..f3e7942 --- /dev/null +++ b/macros/Hardware/RasberryPi/pcf/RPI_pcf8574Setup.sci @@ -0,0 +1,43 @@ +// 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_pcf8574Setup(pinBase,i2cAddress) +// Function for setting up PCF8574 8-bit GPIO expander IC +// +// Calling Sequence +// RPI_pcf8574Setup(pinBase,i2cAddress) +// +// Parameters +// pinBase : any number above 64. The consecutive 8 pins will be allocated alongwith. +// i2cAddress: I2C address obtained using RPI_i2cdetect function +// +// Description +// This function sets up the extension module for the PCF8574 8-bit GPIO expander IC. Can be called multiple times for multiple PCF8574 using different pinBase for each. +// +//You don’t need to specify the number of pins here – the PCF8754 has 8 pins. +// +// Examples +// RPI_pcf8574Setup(67,100) +// See also +// RPI_pcf8591Setup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pf7#2#"+string(pinBase)+"#"+string(i2cAddress)+"#"; + 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/macros/Hardware/RasberryPi/pcf/RPI_pcf8591Setup.sci b/macros/Hardware/RasberryPi/pcf/RPI_pcf8591Setup.sci new file mode 100755 index 0000000..8705490 --- /dev/null +++ b/macros/Hardware/RasberryPi/pcf/RPI_pcf8591Setup.sci @@ -0,0 +1,43 @@ +// 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_pcf8591Setup(pinBase,i2cAddress) +// Function for setting up 8-bit PCF8591 Analog IO expander IC +// +// Calling Sequence +// RPI_pcf8591Setup(pinBase,i2cAddress) +// +// Parameters +// pinBase : any number above 64.The consecutive 4 pins will be allocated alongwith. +// i2cAddress: I2C address obtained using RPI_i2cdetect function +// +// Description +// This function sets up the extension module for the PCF8591 8-bit GPIO expander IC. Can be called multiple times for multiple PCF8591 using different pinBase for each. +// +//Specifying the number of pins is not necessary – the PCF8791 has 4 pins – the analog output uses base pin number 0 – the same as analog input 0. +// +// Examples +// RPI_pcf8591Setup(67,64) +// See also +// RPI_pcf8574Setup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pf9#2#"+string(pinBase)+"#"+string(i2cAddress)+"#"; + 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/macros/Hardware/RasberryPi/pcf/buildmacros.sce b/macros/Hardware/RasberryPi/pcf/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/pcf/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/macros/Hardware/RasberryPi/pcf/names b/macros/Hardware/RasberryPi/pcf/names new file mode 100755 index 0000000..3e326a0 --- /dev/null +++ b/macros/Hardware/RasberryPi/pcf/names @@ -0,0 +1,2 @@ +RPI_pcf8574Setup +RPI_pcf8591Setup diff --git a/macros/Hardware/RasberryPi/piGlow/RPI_piGlow1.sci b/macros/Hardware/RasberryPi/piGlow/RPI_piGlow1.sci new file mode 100755 index 0000000..e093238 --- /dev/null +++ b/macros/Hardware/RasberryPi/piGlow/RPI_piGlow1.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_piGlow1(leg,ring,intensity) +// Function to modify a single LED on the piGlow +// +// Calling Sequence +// RPI_piGlow1(leg,ring,intensity) +// +// Parameters +// leg : leg number +// ring : ring number +// intensity: brightness from 0 (off) to 255 (full) +// +// Description +// The function modifies the brightness of the single specified LED. +// +// Examples +// RPI_piGlow1(0,0,125) +// See also +// RPI_piGlowLeg, RPI_piGlowRing, RPI_piGlowSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pG1#3#"+string(leg)+"#"+string(ring)+"#"+string(intensity)+"#"; + 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/macros/Hardware/RasberryPi/piGlow/RPI_piGlowLeg.sci b/macros/Hardware/RasberryPi/piGlow/RPI_piGlowLeg.sci new file mode 100755 index 0000000..d042579 --- /dev/null +++ b/macros/Hardware/RasberryPi/piGlow/RPI_piGlowLeg.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_piGlowLeg(leg,intensity) +// Function to modify a full leg of LEDs on the piGlow +// +// Calling Sequence +// RPI_piGlowLeg(leg,intensity) +// +// Parameters +// leg : leg number +// intensity: brightness from 0 (off) to 255 (full) +// +// Description +// This function modifies the brightness of all the LEDs in the single specified leg of piGlow. +// +// Examples +// RPI_piGlowLeg(0,100) +// See also +// RPI_piGlow1, RPI_piGlowRing, RPI_piGlowSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pGL#2#"+string(leg)+"#"+string(intensity)+"#"; + 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/macros/Hardware/RasberryPi/piGlow/RPI_piGlowRing.sci b/macros/Hardware/RasberryPi/piGlow/RPI_piGlowRing.sci new file mode 100755 index 0000000..ef81620 --- /dev/null +++ b/macros/Hardware/RasberryPi/piGlow/RPI_piGlowRing.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_piGlowRing(ring,intensity) +// Function to modify a full ring of LEDs on the piGlow +// +// Calling Sequence +// RPI_piGlowRing(ring,intensity) +// +// Parameters +// ring : ring number +// intensity: brightness from 0 (off) to 255 (full) +// +// Description +// This function modifies the brightness of all the LEDs in the single specified ring of piGlow. +// +// Examples +// RPI_piGlowRing(1,200) +// See also +// RPI_piGlowLeg, RPI_piGlow1, RPI_piGlowSetup +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pGR#2#"+string(ring)+"#"+string(intensity)+"#"; + 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/macros/Hardware/RasberryPi/piGlow/RPI_piGlowSetup.sci b/macros/Hardware/RasberryPi/piGlow/RPI_piGlowSetup.sci new file mode 100755 index 0000000..718fa3b --- /dev/null +++ b/macros/Hardware/RasberryPi/piGlow/RPI_piGlowSetup.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_piGlowSetup(Empty) +// Function to initialize the piGlow board +// +// Calling Sequence +// RPI_piGlowSetup(Empty) +// +// Parameters +// Empty: integer, 0 or 1. If 1, then all the LEDs will be turned off to start with. +// +// Description +// This initialises the PiGlow devLib software. The I2C kernel module needs to be pre-loaded. ThePiGlow board has an SN3218 I2C LED controller and 18 LEDs arranged in 3 “legs” of 6 LEDs. (or 6 “rings” of 3 LEDs). +// +// The LED colours in each leg match and are in the order Red (at the outside), Yellow, Orange, Green, Blue and White (in the center) +// +// Examples +// RPI_piGlowSetup(TRUE) +// See also +// RPI_piGlowLeg, RPI_piGlow1, RPI_piGlowRing +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pGS#1#"+string(Empty)+"#"; + 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/macros/Hardware/RasberryPi/piGlow/buildmacros.sce b/macros/Hardware/RasberryPi/piGlow/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/piGlow/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/macros/Hardware/RasberryPi/piGlow/names b/macros/Hardware/RasberryPi/piGlow/names new file mode 100755 index 0000000..b63ec8f --- /dev/null +++ b/macros/Hardware/RasberryPi/piGlow/names @@ -0,0 +1,4 @@ +RPI_piGlow1 +RPI_piGlowLeg +RPI_piGlowRing +RPI_piGlowSetup diff --git a/macros/Hardware/RasberryPi/pinMap/RPI_physToGpio.sci b/macros/Hardware/RasberryPi/pinMap/RPI_physToGpio.sci new file mode 100755 index 0000000..9a59caa --- /dev/null +++ b/macros/Hardware/RasberryPi/pinMap/RPI_physToGpio.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_physToGpio(pin) +// Function to check the GPIO pin number corresponding to given physical pin number. +// +// Calling Sequence +// p=RPI_physToGpio(pin) +// +// Parameters +// pin: The pin number to check in physical numbering sequence. +// +// Description +// This funtion return the GPIO pin number corresponding to the supplied physical pin number. +// +// Examples +// p=RPI_physToGpio(11) +// See also +// RPI_wpiToGpio +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="ptG#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/macros/Hardware/RasberryPi/pinMap/RPI_wpiToGpio.sci b/macros/Hardware/RasberryPi/pinMap/RPI_wpiToGpio.sci new file mode 100755 index 0000000..deed426 --- /dev/null +++ b/macros/Hardware/RasberryPi/pinMap/RPI_wpiToGpio.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_wpiToGpio(pin) +// Function to check the GPIO pin number corresponding to given wiringpi pin number. +// +// Calling Sequence +// p=RPI_wpiToGpio(pin) +// +// Parameters +// pin: The pin number to check in wiringpi numbering sequence. +// +// Description +// This funtion return the GPIO pin number corresponding to the supplied wiringpi pin number. +// +// Examples +// p=RPI_wpiToGpio(0) +// See also +// RPI_physToGpio +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="wtG#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/macros/Hardware/RasberryPi/pinMap/buildmacros.sce b/macros/Hardware/RasberryPi/pinMap/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/pinMap/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/macros/Hardware/RasberryPi/pinMap/names b/macros/Hardware/RasberryPi/pinMap/names new file mode 100755 index 0000000..71efa23 --- /dev/null +++ b/macros/Hardware/RasberryPi/pinMap/names @@ -0,0 +1,2 @@ +RPI_physToGpio +RPI_wpiToGpio diff --git a/macros/Hardware/RasberryPi/pwm/RPI_pwmClock.sci b/macros/Hardware/RasberryPi/pwm/RPI_pwmClock.sci new file mode 100755 index 0000000..d065353 --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/RPI_pwmClock.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 RPI_pwmClock(value) +// Function to set the divisor for the PWM clock. +// +// Calling Sequence +// RPI_pwmClock(value) +// +// Parameters +// value: The divisor for the PWM clock. +// +// Description +// This function sets the divisor for the PWM clock. +// +// Examples +// RPI_pwmClock(100) +// See also +// RPI_pwmMode, RPI_pwmRange, RPI_pwmToneWrite, RPI_pwmWrite +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pwC#1#"+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/macros/Hardware/RasberryPi/pwm/RPI_pwmMode.sci b/macros/Hardware/RasberryPi/pwm/RPI_pwmMode.sci new file mode 100755 index 0000000..13d0c36 --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/RPI_pwmMode.sci @@ -0,0 +1,46 @@ +// 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_pwmMode(Mode) +// Function to set the mode for the PWM generator +// +// Calling Sequence +// RPI_pwmMode(mode) +// +// Parameters +// mode: The mode to set for the PWM generator. 'ms' (for mark:space) or 'bal' (for balanced) +// +// Description +// This function sets the mode for the PWM generator. The PWM generator can run in 2 modes – “balanced” and “mark:space”. The mark:space mode is traditional, however the default mode in the Pi is “balanced”. Switch modes by supplying the parameter: bal or ms +// +// Examples +// RPI_pwmMode('bal') +// See also +// RPI_pwmRange, RPI_pwmClock, RPI_pwmToneWrite, RPI_pwmWrite +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + if Mode=='ms' then + commande="pwM#1#0#"; + elseif Mode=='bal' then + commande="pwM#1#1#"; + else: + error("mode should be ""ms"" or ""bal"""); + end + 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/macros/Hardware/RasberryPi/pwm/RPI_pwmRange.sci b/macros/Hardware/RasberryPi/pwm/RPI_pwmRange.sci new file mode 100755 index 0000000..6a1503a --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/RPI_pwmRange.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 RPI_pwmRange(value) +// Function to set the divisor for the PWM clock. +// +// Calling Sequence +// RPI_pwmRange(value) +// +// Parameters +// value: maximum of the range for the PWM generator. +// +// Description +// This function sets the range register in the PWM generator. The default is 1024. +// +// Examples +// RPI_pwmRange(512) +// See also +// RPI_pwmMode, RPI_pwmClock, RPI_pwmToneWrite, RPI_pwmWrite +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pwR#1#"+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/macros/Hardware/RasberryPi/pwm/RPI_pwmToneWrite.sci b/macros/Hardware/RasberryPi/pwm/RPI_pwmToneWrite.sci new file mode 100755 index 0000000..d7ff6ed --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/RPI_pwmToneWrite.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_pwmToneWrite(pin,freq) +// Function to write a tone of a given frequency to the pin +// +// Calling Sequence +// RPI_pwmToneWrite(pin,freq) +// +// Parameters +// pin : The pin to set the frequency on. Numbering to be followed as initiated using RPI_pinNumbering. +// freq: frequency to write +// +// Description +// This function write the given frequency tone to the given pin. +// +// Examples +// RPI_pwmToneWrite(0,100) +// See also +// RPI_pwmMode, RPI_pwmRange, RPI_pwmClock, RPI_pwmWrite, PRI_pinNumbering +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pwT#2#"+string(pin)+"#"+string(freq)+"#"; + 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/macros/Hardware/RasberryPi/pwm/RPI_pwmWrite.sci b/macros/Hardware/RasberryPi/pwm/RPI_pwmWrite.sci new file mode 100755 index 0000000..113547a --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/RPI_pwmWrite.sci @@ -0,0 +1,45 @@ +// 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_pwmWrite(pin,value) +// Function to write voltage value to the PWM register for the given pin. +// +// Calling Sequence +// RPI_pwmWrite(pin,value) +// +// Parameters +// pin : The pin number set the voltage at. Numbering sequence to be followed as initiated using RPI_pinNumbering function. +// value: The voltage to set at the given pin. Range is 0-1024. +// +// Description +// Writes the value to the PWM register for the given pin. The Raspberry Pi has one on-board PWM pin, pin 1 (BMC_GPIO 18, Phys 12). Other PWM devices may have other PWM ranges. +// +// Examples +// RPI_pwmWrite(1,500) +// See also +// RPI_pwmMode, RPI_pwmRange, RPI_pwmClock, RPI_pwmToneWrite +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + if [0<value,value<1024] then + commande="pwW#2#"+string(pin)+"#"+string(value)+"#"; + else + error("Voltage has to be between 0 and 1024"); + end + 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/macros/Hardware/RasberryPi/pwm/buildmacros.sce b/macros/Hardware/RasberryPi/pwm/buildmacros.sce new file mode 100755 index 0000000..7d533f7 --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/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/macros/Hardware/RasberryPi/pwm/names b/macros/Hardware/RasberryPi/pwm/names new file mode 100755 index 0000000..87e7088 --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/names @@ -0,0 +1,5 @@ +RPI_pwmClock +RPI_pwmMode +RPI_pwmRange +RPI_pwmToneWrite +RPI_pwmWrite diff --git a/macros/Hardware/RasberryPi/raspi.sci b/macros/Hardware/RasberryPi/raspi.sci new file mode 100755 index 0000000..4da09ca --- /dev/null +++ b/macros/Hardware/RasberryPi/raspi.sci @@ -0,0 +1,94 @@ +// 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
+
+global RPI_piAdress;
+
+if getos()=="Linux" then
+ RPI_MacrosPath=get_absolute_file_path("raspi.sci");
+ RPI_MacrosPath=part(RPI_MacrosPath,1:(length(RPI_MacrosPath)-7));
+ RPI_MacrosPath=RPI_MacrosPath+'src/python/';
+// disp("Linux");
+ function raspi(adress,local,username)
+ // Function to initiate the connection to the raspberry pi
+ //
+ // Calling Sequence
+ // raspi(adress,local,username)
+ //
+ // Parameters
+ // address : Network address of the raspberry pi. Eg:10.42.0.82
+ // local : username of the local computer.
+ // username: username on the raspberry pi.
+ //
+ // Description
+ // This program initiates the connection to the raspberry pi at the given address by running the python server script on port 9077 on the pi.
+ //
+ // Examples
+ // raspi('10.42.0.82','panda','pi')
+ // See also
+ // raspi_close
+ //
+ // Authors
+ // Jorawar Singh
+
+ global RPI_piAdress;
+ RPI_piAdress=adress;
+
+ disp("Step 1/6")
+ TCL_EvalStr("if {[file exists /home/"+local+"/.ssh/id_rsa]} {} else {exec ssh-keygen -N """" -f /home/"+local+"/.ssh/id_rsa -q}");
+ disp("Step 2/6")
+ TCL_EvalStr("exec ssh-add >logs.txt 2>&1");
+ disp("Step 3/6")
+ TCL_EvalStr("exec ssh-copy-id -i /home/"+local+"/.ssh/id_rsa.pub "+username+"@"+adress+" > logs.txt 2>&1");
+ disp("Step 4/6")
+ TCL_EvalStr("exec rsync -avz "+RPI_MacrosPath+"serverWP.py "+username+"@"+adress+":.scilab/ >logs.txt");
+ disp("Step 5/6")
+ TCL_EvalStr("exec ssh "+username+"@"+adress+" sudo python /home/"+username+"/.scilab/serverWP.py &");
+ disp("Step 6/6")
+ TCL_EvalStr(["file delete logs.txt";"file delete &1"]);
+ endfunction
+elseif getos()=='Windows' then
+ tempPath=get_absolute_file_path("raspi.sci");
+ RPI_MacrosPath=strsubst(tempPath,'\','/');
+ RPI_MacrosPath=part(RPI_MacrosPath,1:(length(RPI_MacrosPath)-7));
+ RPI_MacrosPath=RPI_MacrosPath+'src/python/';
+ function raspi(adress,username)
+ // Function to initiate the connection to the raspberry pi
+ //
+ // Calling Sequence
+ // raspi(adress,username)
+ //
+ // Parameters
+ // address : Network address of the raspberry pi. Eg:10.42.0.82
+ // username: username on the raspberry pi.
+ //
+ // Description
+ // This program initiates the connection to the raspberry pi at the given address by running the python server script on port 9077 on the pi.
+ //
+ // Examples
+ // raspi('169.254.191.116','pi')
+ // See also
+ // raspi_close
+ //
+ // Authors
+ // Jorawar Singh
+
+ global RPI_piAdress;
+ RPI_piAdress=adress;
+
+ disp("Step 1/3")
+ TCL_EvalStr("exec mintty ssh "+username+"@"+adress+" mkdir .scilab");
+ disp("Step 2/3")
+ TCL_EvalStr("exec mintty scp "+RPI_MacrosPath+"serverWP.py "+username+"@"+adress+":/home/"+username+"/.scilab/");
+ disp("Step 3/3 (Wait ~15 seconds)")
+ TCL_EvalStr("exec mintty ssh "+username+"@"+adress+" sudo python /home/"+username+"/.scilab/serverWP.py &");
+ sleep(15000)
+ TCL_EvalStr("exec taskkill /IM mintty.exe");
+ endfunction
+end
diff --git a/macros/Hardware/RasberryPi/raspi_close.sci b/macros/Hardware/RasberryPi/raspi_close.sci new file mode 100755 index 0000000..b5bb0ee --- /dev/null +++ b/macros/Hardware/RasberryPi/raspi_close.sci @@ -0,0 +1,34 @@ +// 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 raspi_close() +// Function to close an open Raspberry-Pi connection. +// +// Calling Sequence +// raspi_close() +// +// Description +// This function causes the pyhton server script running on Raspberry pi to close, irrespective of it being started natively on pi or by using raspi function. +// +// Examples +// raspi_close() +// See also +// raspi +// +// Authors +// Jorawar Singh + + commande="cls#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/macros/ImageProcessing/core/lib b/macros/ImageProcessing/core/lib Binary files differdeleted file mode 100644 index 7f003c8..0000000 --- a/macros/ImageProcessing/core/lib +++ /dev/null diff --git a/macros/ImageProcessing/highgui/lib b/macros/ImageProcessing/highgui/lib Binary files differdeleted file mode 100644 index 787c25f..0000000 --- a/macros/ImageProcessing/highgui/lib +++ /dev/null diff --git a/macros/ImageProcessing/imgproc/lib b/macros/ImageProcessing/imgproc/lib Binary files differdeleted file mode 100644 index 93c8390..0000000 --- a/macros/ImageProcessing/imgproc/lib +++ /dev/null diff --git a/macros/Scilab-Arduino/buildmacros.sce b/macros/Scilab-Arduino/buildmacros.sce index dfeb475..7d533f7 100644..100755 --- a/macros/Scilab-Arduino/buildmacros.sce +++ b/macros/Scilab-Arduino/buildmacros.sce @@ -1,28 +1,13 @@ -// 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; +// 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')); diff --git a/macros/Scilab-Arduino/lib b/macros/Scilab-Arduino/lib Binary files differdeleted file mode 100644 index 5b7beab..0000000 --- a/macros/Scilab-Arduino/lib +++ /dev/null diff --git a/macros/SymbolTable/lib b/macros/SymbolTable/lib Binary files differdeleted file mode 100644 index c42cf1a..0000000 --- a/macros/SymbolTable/lib +++ /dev/null diff --git a/macros/ToolInitialization/lib b/macros/ToolInitialization/lib Binary files differdeleted file mode 100644 index 267c9c9..0000000 --- a/macros/ToolInitialization/lib +++ /dev/null diff --git a/macros/findDeps/lib b/macros/findDeps/lib Binary files differdeleted file mode 100644 index 69c3c0e..0000000 --- a/macros/findDeps/lib +++ /dev/null diff --git a/macros/lib b/macros/lib Binary files differdeleted file mode 100644 index f759663..0000000 --- a/macros/lib +++ /dev/null |