You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- NOTE: You can check the javascript version: https://github.com/NVSL/Linuxduino
PiDuino Library is a C++ library that lets you write programs for Raspberry Pi as if you were writing an Arduino program.
This library does not support Analog to Digital Conversion (or ADC) functions as the Raspberry Pi hardware does not have an integrated ADC and we don´t want to create hardware dependant code. If you need ADC is recomended to use external libraries.
PiDuino Library aims to support the most basic official Arduino functions published in the [Arduino official website] (https://www.arduino.cc/en/Reference/Libraries) as of April 2016. Note that the Arduino API has many legacy functions that although keeped no longer used, the ported libraries and functions are only the ones published on the official website.
Implemented Arduino Functions :
Digital I/O, Analog I/O, Advanced I/O, Time, Math, Trigonometry, Random Numbers, Bits and Bytes, External Interrupts, Interrupts, Communication
Implemented Arduino Libraries :
Serial, Wire, SPI
Notes:
B some binary representation (e.g B1000000[7 bits] and B110[3 bits]) conflicts with some termios.h definitions so only 8 bit binary representations are supported (e.g B01000000[8 bits], B00010001[8 bits], etc). To represent a binary with less than 8 bits please use 0b instead.
Implemented Arduino Functions
Notes:
Functions that begin with (EXTRA) are functions that were added to provide extra functionality to the library.
NO/In Progress - Linux I2C Slave driver was added recently, still verifying
Wire.requestFrom(address, quantity)
YES
Wire.requestFrom(address, quantity, stop)
NO - There is no way to send an I2C stop msg to the driver
Wire.beginTransmission(address)
YES
Wire.endTransmission()
YES
Wire.endTransmission(stop)
NO - There is no way to send an I2C stop msg to the driver
Wire.write(value)
YES
Wire.write(string)
YES
Wire.write(data, length)
YES
Wire.available()
YES
Wire.read()
YES
Wire.onReceive(handler)
NO/In Progress - Linux I2C Slave driver was added recently, still verifying
Wire.onRequest(handler)
NO/In Progress - Linux I2C Slave driver was added recently, still verifying
- SPI
Function
Implemented (YES/NO-Comment/In Progress)
SPISettings
YES
SPI.begin()
YES
(EXTRA) SPI.begin(driverName)
YES
SPI.end()
YES
SPI.beginTransaction(mySettings)
YES
SPI.endTransaction()
YES
SPI.setBitOrder(order)
YES
SPI.setClockDivider(divider)
YES - Sets clock or if you use dividers (e.g SPI_CLOCK_DIV4) then sets clock at the divider speed for a 16Mhz Arduino microcontroller
SPI.setDataMode(mode)
YES
receivedVal = SPI.transfer(val)
YES
receivedVal16 = SPI.transfer16(val16)
NO - Is almost depreceated and could be fixed better adding a bitsPerWord in settings that includes 16 bits and 32 bits
SPI.transfer(buffer, size)
YES
SPI.usingInterrupt(interruptNumber)
In Progress
TODO'S
Make a SPI and I2C begin("/dev/i2c-x") to let developers choose any i2c-x number.
Check Linux i2c-slave.
Maybe only add B(8 bits) only and that way prevent conflicts with termios.h
Defintily separate files and make it C compatible (At the end)
Make an Arduino.h header containing piDuino.h so developers don't need to change too much code.
Add arduino String object
Maybe add a SPISettings(..., bitsPerWord, CS(High?low)) and their bit routines config. to SPI. For bitPerWord transfer len will need to be multiplied by (bitsPerWord/8)
Add string, String, (arg, ...) to prints.
Make an Arduino init function
Implement an exit rutine when SIGINT (Ctrl^Z) to turn GPIO OFF