diff --git a/binding.gyp b/binding.gyp index b8440fb..8b110d9 100644 --- a/binding.gyp +++ b/binding.gyp @@ -6,10 +6,10 @@ 'src/bindings.cc' ], 'include_dirs': [ - 'deps' + 'wiringpi/wiringPi' ], 'libraries': [ - '. - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int drcSetupSerial (const int pinBase, const int numPins, const char *device, const int baud) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/libwiringPi.a b/deps/libwiringPi.a deleted file mode 100644 index def05a9..0000000 Binary files a/deps/libwiringPi.a and /dev/null differ diff --git a/deps/max31855.h b/deps/max31855.h deleted file mode 100644 index 385c4bd..0000000 --- a/deps/max31855.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * max31855.c: - * Extend wiringPi with the MAX31855 SPI Thermocouple driver - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int max31855Setup (int pinBase, int spiChannel) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/max5322.h b/deps/max5322.h deleted file mode 100644 index a217cf8..0000000 --- a/deps/max5322.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * max5322.h: - * Extend wiringPi with the MAX5322 SPI Digital to Analog convertor - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int max5322Setup (int pinBase, int spiChannel) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/mcp23008.h b/deps/mcp23008.h deleted file mode 100644 index e9299a8..0000000 --- a/deps/mcp23008.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 23008.h: - * Extend wiringPi with the MCP 23008 I2C GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp23008Setup (const int pinBase, const int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/mcp23016.h b/deps/mcp23016.h deleted file mode 100644 index f9b5cc5..0000000 --- a/deps/mcp23016.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * mcp23016.h: - * Extend wiringPi with the MCP 23016 I2C GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp23016Setup (const int pinBase, const int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/mcp23016reg.h b/deps/mcp23016reg.h deleted file mode 100644 index 9aea92d..0000000 --- a/deps/mcp23016reg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * mcp23016: - * Copyright (c) 2012-2013 Gordon Henderson - * - * Header file for code using the MCP23016 GPIO expander - * chip. - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -// MCP23016 Registers - -#define MCP23016_GP0 0x00 -#define MCP23016_GP1 0x01 -#define MCP23016_OLAT0 0x02 -#define MCP23016_OLAT1 0x03 -#define MCP23016_IPOL0 0x04 -#define MCP23016_IPOL1 0x05 -#define MCP23016_IODIR0 0x06 -#define MCP23016_IODIR1 0x07 -#define MCP23016_INTCAP0 0x08 -#define MCP23016_INTCAP1 0x09 -#define MCP23016_IOCON0 0x0A -#define MCP23016_IOCON1 0x0B - -// Bits in the IOCON register - -#define IOCON_IARES 0x01 - -// Default initialisation mode - -#define IOCON_INIT 0 diff --git a/deps/mcp23017.h b/deps/mcp23017.h deleted file mode 100644 index 79b4d7b..0000000 --- a/deps/mcp23017.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 23017.h: - * Extend wiringPi with the MCP 23017 I2C GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp23017Setup (const int pinBase, const int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/mcp23s08.h b/deps/mcp23s08.h deleted file mode 100644 index ebf93d1..0000000 --- a/deps/mcp23s08.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 23s08.h: - * Extend wiringPi with the MCP 23s08 SPI GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp23s08Setup (const int pinBase, const int spiPort, const int devId) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/mcp23s17.h b/deps/mcp23s17.h deleted file mode 100644 index 3b2a808..0000000 --- a/deps/mcp23s17.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 23s17.h: - * Extend wiringPi with the MCP 23s17 SPI GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp23s17Setup (int pinBase, int spiPort, int devId) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/mcp23x08.h b/deps/mcp23x08.h deleted file mode 100644 index c4e6b27..0000000 --- a/deps/mcp23x08.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * mcp23x17: - * Copyright (c) 2012-2013 Gordon Henderson - * - * Header file for code using the MCP23x17 GPIO expander chip. - * This comes in 2 flavours: MCP23017 which has an I2C interface, - * an the MXP23S17 which has an SPI interface. - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - - -// MCP23x17 Registers - -#define IODIRA 0x00 -#define IPOLA 0x02 -#define GPINTENA 0x04 -#define DEFVALA 0x06 -#define INTCONA 0x08 -#define IOCON 0x0A -#define GPPUA 0x0C -#define INTFA 0x0E -#define INTCAPA 0x10 -#define GPIOA 0x12 -#define OLATA 0x14 - -#define IODIRB 0x01 -#define IPOLB 0x03 -#define GPINTENB 0x05 -#define DEFVALB 0x07 -#define INTCONB 0x09 -#define IOCONB 0x0B -#define GPPUB 0x0D -#define INTFB 0x0F -#define INTCAPB 0x11 -#define GPIOB 0x13 -#define OLATB 0x15 - -// Bits in the IOCON register - -#define IOCON_UNUSED 0x01 -#define IOCON_INTPOL 0x02 -#define IOCON_ODR 0x04 -#define IOCON_HAEN 0x08 -#define IOCON_DISSLW 0x10 -#define IOCON_SEQOP 0x20 -#define IOCON_MIRROR 0x40 -#define IOCON_BANK_MODE 0x80 - -// Default initialisation mode - -#define IOCON_INIT (IOCON_SEQOP) - -// SPI Command codes - -#define CMD_WRITE 0x40 -#define CMD_READ 0x41 diff --git a/deps/mcp23x0817.h b/deps/mcp23x0817.h deleted file mode 100644 index 58bc038..0000000 --- a/deps/mcp23x0817.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * mcp23xxx: - * Copyright (c) 2012-2013 Gordon Henderson - * - * Header file for code using the MCP23x08 and 17 GPIO expander - * chips. - * This comes in 2 flavours: MCP230xx (08/17) which has an I2C - * interface, and the MXP23Sxx (08/17) which has an SPI interface. - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -// MCP23x08 Registers - -#define MCP23x08_IODIR 0x00 -#define MCP23x08_IPOL 0x01 -#define MCP23x08_GPINTEN 0x02 -#define MCP23x08_DEFVAL 0x03 -#define MCP23x08_INTCON 0x04 -#define MCP23x08_IOCON 0x05 -#define MCP23x08_GPPU 0x06 -#define MCP23x08_INTF 0x07 -#define MCP23x08_INTCAP 0x08 -#define MCP23x08_GPIO 0x09 -#define MCP23x08_OLAT 0x0A - -// MCP23x17 Registers - -#define MCP23x17_IODIRA 0x00 -#define MCP23x17_IPOLA 0x02 -#define MCP23x17_GPINTENA 0x04 -#define MCP23x17_DEFVALA 0x06 -#define MCP23x17_INTCONA 0x08 -#define MCP23x17_IOCON 0x0A -#define MCP23x17_GPPUA 0x0C -#define MCP23x17_INTFA 0x0E -#define MCP23x17_INTCAPA 0x10 -#define MCP23x17_GPIOA 0x12 -#define MCP23x17_OLATA 0x14 - -#define MCP23x17_IODIRB 0x01 -#define MCP23x17_IPOLB 0x03 -#define MCP23x17_GPINTENB 0x05 -#define MCP23x17_DEFVALB 0x07 -#define MCP23x17_INTCONB 0x09 -#define MCP23x17_IOCONB 0x0B -#define MCP23x17_GPPUB 0x0D -#define MCP23x17_INTFB 0x0F -#define MCP23x17_INTCAPB 0x11 -#define MCP23x17_GPIOB 0x13 -#define MCP23x17_OLATB 0x15 - -// Bits in the IOCON register - -#define IOCON_UNUSED 0x01 -#define IOCON_INTPOL 0x02 -#define IOCON_ODR 0x04 -#define IOCON_HAEN 0x08 -#define IOCON_DISSLW 0x10 -#define IOCON_SEQOP 0x20 -#define IOCON_MIRROR 0x40 -#define IOCON_BANK_MODE 0x80 - -// Default initialisation mode - -#define IOCON_INIT (IOCON_SEQOP) - -// SPI Command codes - -#define CMD_WRITE 0x40 -#define CMD_READ 0x41 diff --git a/deps/mcp3002.h b/deps/mcp3002.h deleted file mode 100644 index 0cd727f..0000000 --- a/deps/mcp3002.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * mcp3002.c: - * Extend wiringPi with the MCP3002 SPI Analog to Digital convertor - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp3002Setup (int pinBase, int spiChannel) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/mcp3004.h b/deps/mcp3004.h deleted file mode 100644 index a07c0bf..0000000 --- a/deps/mcp3004.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * mcp3004.c: - * Extend wiringPi with the MCP3004 SPI Analog to Digital convertor - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp3004Setup (int pinBase, int spiChannel) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/mcp3422.h b/deps/mcp3422.h deleted file mode 100644 index 5235fdc..0000000 --- a/deps/mcp3422.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * mcp3422.c: - * Extend wiringPi with the MCP3422 I2C ADC chip - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#define MCP3422_SR_3_75 3 -#define MCP3422_SR_15 2 -#define MCP3422_SR_60 1 -#define MCP3422_SR_240 0 - -#define MCP3422_GAIN_1 0 -#define MCP3422_GAIN_2 1 -#define MCP3422_GAIN_4 2 -#define MCP3422_GAIN_8 3 - - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp3422Setup (int pinBase, int i2cAddress, int sampleRate, int gain) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/mcp4802.h b/deps/mcp4802.h deleted file mode 100644 index effa024..0000000 --- a/deps/mcp4802.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * mcp4802.c: - * Extend wiringPi with the MCP4802 SPI Digital to Analog convertor - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int mcp4802Setup (int pinBase, int spiChannel) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/pcf8574.h b/deps/pcf8574.h deleted file mode 100644 index 8e2d818..0000000 --- a/deps/pcf8574.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * pcf8574.h: - * Extend wiringPi with the PCF8574 I2C GPIO expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int pcf8574Setup (const int pinBase, const int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/pcf8591.h b/deps/pcf8591.h deleted file mode 100644 index 6b44ccf..0000000 --- a/deps/pcf8591.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * pcf8591.h: - * Extend wiringPi with the PCF8591 I2C GPIO Analog expander chip - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int pcf8591Setup (const int pinBase, const int i2cAddress) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/sn3218.h b/deps/sn3218.h deleted file mode 100644 index 580d5f9..0000000 --- a/deps/sn3218.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * sn3218.c: - * Extend wiringPi with the SN3218 I2C LED driver board. - * Copyright (c) 2012-2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int sn3218Setup (int pinBase) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/softPwm.h b/deps/softPwm.h deleted file mode 100644 index 28ad299..0000000 --- a/deps/softPwm.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * softPwm.h: - * Provide 2 channels of software driven PWM. - * Copyright (c) 2012 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int softPwmCreate (int pin, int value, int range) ; -extern void softPwmWrite (int pin, int value) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/softServo.h b/deps/softServo.h deleted file mode 100644 index 794cf55..0000000 --- a/deps/softServo.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * softServo.h: - * Provide N channels of software driven PWM suitable for RC - * servo motors. - * Copyright (c) 2012 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern void softServoWrite (int pin, int value) ; -extern int softServoSetup (int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/softTone.h b/deps/softTone.h deleted file mode 100644 index d8b4e54..0000000 --- a/deps/softTone.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * softTone.c: - * For that authentic retro sound... - * Er... A little experiment to produce tones out of a Pi using - * one (or 2) GPIO pins and a piezeo "speaker" element. - * (Or a high impedance speaker, but don'y blame me if you blow-up - * the GPIO pins!) - * Copyright (c) 2012 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int softToneCreate (int pin) ; -extern void softToneWrite (int pin, int freq) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/sr595.h b/deps/sr595.h deleted file mode 100644 index 4a26dc7..0000000 --- a/deps/sr595.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * sr595.h: - * Extend wiringPi with the 74x595 shift registers. - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int sr595Setup (const int pinBase, const int numPins, - const int dataPin, const int clockPin, const int latchPin) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/wiringPi.h b/deps/wiringPi.h deleted file mode 100644 index ce4680a..0000000 --- a/deps/wiringPi.h +++ /dev/null @@ -1,187 +0,0 @@ -/* - * wiringPi: - * Arduino compatable (ish) Wiring library for the Raspberry Pi - * Copyright (c) 2012 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with wiringPi. If not, see . - *********************************************************************** - */ - -#ifndef __WIRING_PI_H__ -#define __WIRING_PI_H__ - -// Handy defines - -// Deprecated -#define NUM_PINS 17 - -#define WPI_MODE_PINS 0 -#define WPI_MODE_GPIO 1 -#define WPI_MODE_GPIO_SYS 2 -#define WPI_MODE_PHYS 3 -#define WPI_MODE_PIFACE 4 -#define WPI_MODE_UNINITIALISED -1 - -// Pin modes - -#define INPUT 0 -#define OUTPUT 1 -#define PWM_OUTPUT 2 -#define GPIO_CLOCK 3 - -#define LOW 0 -#define HIGH 1 - -// Pull up/down/none - -#define PUD_OFF 0 -#define PUD_DOWN 1 -#define PUD_UP 2 - -// PWM - -#define PWM_MODE_MS 0 -#define PWM_MODE_BAL 1 - -// Interrupt levels - -#define INT_EDGE_SETUP 0 -#define INT_EDGE_FALLING 1 -#define INT_EDGE_RISING 2 -#define INT_EDGE_BOTH 3 - -// Threads - -#define PI_THREAD(X) void *X (void *dummy) - -// Failure modes - -#define WPI_FATAL (1==1) -#define WPI_ALMOST (1==2) - - -// wiringPiNodeStruct: -// This describes additional device nodes in the extended wiringPi -// 2.0 scheme of things. -// It's a simple linked list for now, but will hopefully migrate to -// a binary tree for efficiency reasons - but then again, the chances -// of more than 1 or 2 devices being added are fairly slim, so who -// knows.... - -struct wiringPiNodeStruct -{ - int pinBase ; - int pinMax ; - - int fd ; // Node specific - unsigned int data0 ; // ditto - unsigned int data1 ; // ditto - unsigned int data2 ; // ditto - unsigned int data3 ; // ditto - - void (*pinMode) (struct wiringPiNodeStruct *node, int pin, int mode) ; - void (*pullUpDnControl) (struct wiringPiNodeStruct *node, int pin, int mode) ; - int (*digitalRead) (struct wiringPiNodeStruct *node, int pin) ; - void (*digitalWrite) (struct wiringPiNodeStruct *node, int pin, int value) ; - void (*pwmWrite) (struct wiringPiNodeStruct *node, int pin, int value) ; - int (*analogRead) (struct wiringPiNodeStruct *node, int pin) ; - void (*analogWrite) (struct wiringPiNodeStruct *node, int pin, int value) ; - - struct wiringPiNodeStruct *next ; -} ; - -extern struct wiringPiNodeStruct *wiringPiNodes ; - - -// Function prototypes -// c++ wrappers thanks to a comment by Nick Lott -// (and others on the Raspberry Pi forums) - -#ifdef __cplusplus -extern "C" { -#endif - -// Internal - -extern int wiringPiFailure (int fatal, const char *message, ...) ; - -// Core wiringPi functions - -extern struct wiringPiNodeStruct *wiringPiFindNode (int pin) ; -extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ; - -extern int wiringPiSetup (void) ; -extern int wiringPiSetupSys (void) ; -extern int wiringPiSetupGpio (void) ; -extern int wiringPiSetupPhys (void) ; - -extern void pinModeAlt (int pin, int mode) ; -extern void pinMode (int pin, int mode) ; -extern void pullUpDnControl (int pin, int pud) ; -extern int digitalRead (int pin) ; -extern void digitalWrite (int pin, int value) ; -extern void pwmWrite (int pin, int value) ; -extern int analogRead (int pin) ; -extern void analogWrite (int pin, int value) ; - -// PiFace specifics -// (Deprecated) - -extern int wiringPiSetupPiFace (void) ; -extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio program only - -// On-Board Raspberry Pi hardware specific stuff - -extern int piBoardRev (void) ; -extern int wpiPinToGpio (int wpiPin) ; -extern int physPinToGpio (int physPin) ; -extern void setPadDrive (int group, int value) ; -extern int getAlt (int pin) ; -extern void digitalWriteByte (int value) ; -extern void pwmSetMode (int mode) ; -extern void pwmSetRange (unsigned int range) ; -extern void pwmSetClock (int divisor) ; -extern void gpioClockSet (int pin, int freq) ; - -// Interrupts -// (Also Pi hardware specific) - -extern int waitForInterrupt (int pin, int mS) ; -extern int wiringPiISR (int pin, int mode, void (*function)(void)) ; - -// Threads - -extern int piThreadCreate (void *(*fn)(void *)) ; -extern void piLock (int key) ; -extern void piUnlock (int key) ; - -// Schedulling priority - -extern int piHiPri (const int pri) ; - -// Extras from arduino land - -extern void delay (unsigned int howLong) ; -extern void delayMicroseconds (unsigned int howLong) ; -extern unsigned int millis (void) ; -extern unsigned int micros (void) ; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/deps/wiringPiI2C.h b/deps/wiringPiI2C.h deleted file mode 100644 index 6db8c68..0000000 --- a/deps/wiringPiI2C.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * wiringPiI2C.h: - * Simplified I2C access routines - * Copyright (c) 2013 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int wiringPiI2CRead (int fd) ; -extern int wiringPiI2CReadReg8 (int fd, int reg) ; -extern int wiringPiI2CReadReg16 (int fd, int reg) ; - -extern int wiringPiI2CWrite (int fd, int data) ; -extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ; -extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ; - -extern int wiringPiI2CSetupInterface (const char *device, int devId) ; -extern int wiringPiI2CSetup (const int devId) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/wiringPiSPI.h b/deps/wiringPiSPI.h deleted file mode 100644 index f53697d..0000000 --- a/deps/wiringPiSPI.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * wiringPiSPI.h: - * Simplified SPI access routines - * Copyright (c) 2012 Gordon Henderson - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -int wiringPiSPIGetFd (int channel) ; -int wiringPiSPIDataRW (int channel, unsigned char *data, int len) ; -int wiringPiSPISetup (int channel, int speed) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/wiringSerial.h b/deps/wiringSerial.h deleted file mode 100644 index 430dc73..0000000 --- a/deps/wiringSerial.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * wiringSerial.h: - * Handle a serial port - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with wiringPi. If not, see . - *********************************************************************** - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int serialOpen (const char *device, const int baud) ; -extern void serialClose (const int fd) ; -extern void serialFlush (const int fd) ; -extern void serialPutchar (const int fd, const unsigned char c) ; -extern void serialPuts (const int fd, const char *s) ; -extern void serialPrintf (const int fd, const char *message, ...) ; -extern int serialDataAvail (const int fd) ; -extern int serialGetchar (const int fd) ; - -#ifdef __cplusplus -} -#endif diff --git a/deps/wiringShift.h b/deps/wiringShift.h deleted file mode 100644 index 419ade4..0000000 --- a/deps/wiringShift.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * wiringShift.h: - * Emulate some of the Arduino wiring functionality. - * - * Copyright (c) 2009-2012 Gordon Henderson. - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with wiringPi. If not, see . - *********************************************************************** - */ - -#define LSBFIRST 0 -#define MSBFIRST 1 - -#ifndef _STDINT_H -# include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order) ; -extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val) ; - -#ifdef __cplusplus -} -#endif diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..ce9fd49 --- /dev/null +++ b/install.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +git clone https://github.com/nekuz0r/wiringpi.git +cd ./wiringpi/wiringPi/ +make static +cd ../../ +node-gyp rebuild \ No newline at end of file diff --git a/lib/exports.js b/lib/exports.js index b8e7848..973fa36 100644 --- a/lib/exports.js +++ b/lib/exports.js @@ -27,6 +27,8 @@ exports = { OUTPUT: 1, PWM_OUTPUT: 2, GPIO_CLOCK: 3, + SOFT_PWM_OUTPUT: 4, + SOFT_TONE_OUTPUT: 5, LOW: 0, HIGH: 1, @@ -63,16 +65,39 @@ exports = { LSBFIRST: 0, MSBFIRST: 1, + // PI Model type + PI_MODEL_A: 0, + PI_MODEL_B: 1, + + // PI Model names + PI_MODEL_NAMES: [ + "Model A", + "Model B", + "Compute Module" + ], + + // PI Revision names + PI_REVISION_NAMES: [ + "1", + "1.1", + "2" + ], + + // PI Compute revision names + PI_COMPUTE_REVISION_NAMES: [ + + ], + //MCP3422 - MCP3422_SR_3_75: 0, - MCP3422_SR_15: 1, - MCP3422_SR_60: 2, - MCP3422_SR_240: 3, + MCP3422_SR_3_75: 3, + MCP3422_SR_15: 2, + MCP3422_SR_60: 1, + MCP3422_SR_240: 0, - MCP3422_GAIN_1: 3, - MCP3422_GAIN_2: 2, - MCP3422_GAIN_4: 1, - MCP3422_GAIN_8: 0, + MCP3422_GAIN_1: 0, + MCP3422_GAIN_2: 1, + MCP3422_GAIN_4: 2, + MCP3422_GAIN_8: 3, }; // Extends exports with properties of 'c' diff --git a/package.json b/package.json index d22c4f0..edf1d2f 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "wiring-pi", - "version": "1.0.2", + "version": "1.1.0", "description": "Bindings to wiringPi", "main": "lib/exports.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "install": "node-gyp rebuild" + "install": "/bin/bash ./install.sh" }, "repository": { "type": "git", diff --git a/src/bindings.cc b/src/bindings.cc index afa22a7..73d725b 100644 --- a/src/bindings.cc +++ b/src/bindings.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,12 @@ namespace wpi { DECLARE(pwmWrite); DECLARE(analogRead); DECLARE(analogWrite); + DECLARE(pulseIn); + + DECLARE(delay); + DECLARE(delayMicroseconds); + DECLARE(millis); + DECLARE(micros); // PiFace specifics (Deprecated) //DECLARE(wiringPiSetupPiFace); @@ -59,6 +66,7 @@ namespace wpi { // On-Board Rasberry Pi hardware specific stuff DECLARE(piBoardRev); + DECLARE(piBoardId); DECLARE(wpiPinToGpio); DECLARE(physPinToGpio); DECLARE(setPadDrive); @@ -86,10 +94,12 @@ namespace wpi { DECLARE(pcf8591Setup); DECLARE(sn3218Setup); DECLARE(sr595Setup); + DECLARE(pca9685Setup); // Soft PWM DECLARE(softPwmCreate); DECLARE(softPwmWrite); + DECLARE(softPwmStop); // Soft Servo DECLARE(softServoWrite); @@ -98,6 +108,7 @@ namespace wpi { // Soft Tone DECLARE(softToneCreate); DECLARE(softToneWrite); + DECLARE(softToneStop); // WiringPI I2C DECLARE(wiringPiI2CRead); @@ -519,6 +530,96 @@ IMPLEMENT(analogWrite) { return scope.Close(Undefined()); } +IMPLEMENT(pulseIn) { + HandleScope scope; + int pin; + int state; + int microseconds; + + //CHECK: Number of argument + if (args.Length() != 2) { + ThrowException(Exception::TypeError( + String::New("Wrong number of arguments."))); + return scope.Close(Undefined()); + } + + //CHECK: Argument types + if (!args[0]->IsNumber() || !args[1]->IsNumber()) { + ThrowException(Exception::TypeError( + String::New("Incorrect argument type. Number expected."))); + return scope.Close(Undefined()); + } + + pin = args[0]->NumberValue(); + state = args[1]->NumberValue(); + + microseconds = ::pulseIn(pin, state); + + return scope.Close(Int32::New(microseconds)); +} + +IMPLEMENT(delay) { + HandleScope scope; + unsigned int howLong; + + if (args.Length() != 1) { + ThrowException(Exception::TypeError( + String::New("Wrong number of arguments."))); + return scope.Close(Undefined()); + } + + if (!args[0]->IsNumber()) { + ThrowException(Exception::TypeError( + String::New("Incorrect argument type. Number expected."))); + return scope.Close(Undefined()); + } + + howLong = args[0]->Uint32Value(); + + ::delay(howLong); + + return scope.Close(Undefined()); +} + +IMPLEMENT(delayMicroseconds) { + HandleScope scope; + unsigned int howLong; + + if (args.Length() != 1) { + ThrowException(Exception::TypeError( + String::New("Wrong number of arguments."))); + return scope.Close(Undefined()); + } + + if (!args[0]->IsNumber()) { + ThrowException(Exception::TypeError( + String::New("Incorrect argument type. Number expected."))); + return scope.Close(Undefined()); + } + + howLong = args[0]->Uint32Value(); + + ::delay(howLong); + + return scope.Close(Undefined()); +} + +IMPLEMENT(millis) { + HandleScope scope; + + unsigned int ms = ::millis(); + + return scope.Close(Uint32::New(ms)); +} + +IMPLEMENT(micros) { + HandleScope scope; + + unsigned int us = ::micros(); + + return scope.Close(Uint32::New(us)); +} + // === Raspberry Pi specific === // Func : int piBoardRev(void) @@ -542,6 +643,31 @@ IMPLEMENT(piBoardRev) { return scope.Close(Int32::New(res)); } +IMPLEMENT(piBoardId) { + HandleScope scope; + int model; + int rev; + int mem; + char* marker; + + //CHECK: Number of argument + if (args.Length() != 0) { + ThrowException(Exception::TypeError( + String::New("Wrong number of arguments."))); + return scope.Close(Undefined()); + } + + ::piBoardId(&model, &rev, &mem, &marker); + + Local obj = Object::New(); + obj->Set(String::NewSymbol("model"), Int32::New(model)); + obj->Set(String::NewSymbol("rev"), Int32::New(rev)); + obj->Set(String::NewSymbol("mem"), Int32::New(mem)); + obj->Set(String::NewSymbol("marker"), String::New(marker)); + + return scope.Close(obj); +} + // Func : int wpiPinToGpio(int wpiPin) // Description : This returns the BCM_GPIO pin number of the supplied wiringPi pin. // It takes the board revision into account. @@ -1494,6 +1620,40 @@ IMPLEMENT(sr595Setup) { return scope.Close(Int32::New(res)); } +IMPLEMENT(pca9685Setup) { + HandleScope scope; + int pinBase; + int i2cAddress; + int freq; + int res; + + if (args.Length() != 3) { + ThrowException(Exception::TypeError( + String::New("Wrong number of arguments."))); + return scope.Close(Undefined()); + } + + if (!args[0]->IsNumber() || !args[1]->IsNumber() || !args[2]->IsNumber()) { + ThrowException(Exception::TypeError( + String::New("Incorrect arguments type. Number expected."))); + return scope.Close(Undefined()); + } + + pinBase = args[0]->Int32Value(); + i2cAddress = args[1]->Int32Value(); + freq = args[2]->Int32Value(); + + if (pinBase <= 64) { + ThrowException(Exception::TypeError( + String::New("Incorrect pinBase value. >64 expected"))); + return scope.Close(Undefined()); + } + + res = ::pca9685Setup(pinBase, i2cAddress, freq); + + return scope.Close(Int32::New(res)); +} + // === Soft PWM === // Func : int softPwmCreate(int pin, int value, int range) @@ -1570,6 +1730,30 @@ IMPLEMENT(softPwmWrite) { return scope.Close(Undefined()); } +IMPLEMENT(softPwmStop) { + HandleScope scope; + int pin; + + if (args.Length() != 1) { + ThrowException(Exception::TypeError( + String::New("Wrong number of arguments."))); + return scope.Close(Undefined()); + } + + //CHECK: Argument types + if (!args[0]->IsNumber()) { + ThrowException(Exception::TypeError( + String::New("Incorrect argument type. Number expected."))); + return scope.Close(Undefined()); + } + + pin = args[0]->Int32Value(); + + ::softPwmStop(pin); + + return scope.Close(Undefined()); +} + // === Soft Servo === // Func : void softServoWrite(int pin, int value) @@ -1714,6 +1898,30 @@ IMPLEMENT(softToneWrite) { return scope.Close(Undefined()); } +IMPLEMENT(softToneStop) { + HandleScope scope; + int pin; + + if (args.Length() != 1) { + ThrowException(Exception::TypeError( + String::New("Wrong number of arguments."))); + return scope.Close(Undefined()); + } + + //CHECK: Argument types + if (!args[0]->IsNumber()) { + ThrowException(Exception::TypeError( + String::New("Incorrect argument type. Number expected."))); + return scope.Close(Undefined()); + } + + pin = args[0]->Int32Value(); + + ::softToneStop(pin); + + return scope.Close(Undefined()); +} + // === WiringPI I2C === IMPLEMENT(wiringPiI2CRead) { @@ -2203,6 +2411,12 @@ void init(Handle target) { EXPORT(pwmWrite); EXPORT(analogRead); EXPORT(analogWrite); + EXPORT(pulseIn); + + EXPORT(delay); + EXPORT(delayMicroseconds); + EXPORT(millis); + EXPORT(micros); // PiFace specifics (Deprecated) //EXPORT(wiringPiSetupPiFace); @@ -2210,6 +2424,7 @@ void init(Handle target) { // On-Board Rasberry Pi hardware specific stuff EXPORT(piBoardRev); + EXPORT(piBoardId); EXPORT(wpiPinToGpio); EXPORT(physPinToGpio); EXPORT(setPadDrive); @@ -2237,10 +2452,12 @@ void init(Handle target) { EXPORT(pcf8591Setup); EXPORT(sn3218Setup); EXPORT(sr595Setup); + EXPORT(pca9685Setup); // Soft PWM EXPORT(softPwmCreate); EXPORT(softPwmWrite); + EXPORT(softPwmStop); // Soft Servo EXPORT(softServoWrite); @@ -2249,6 +2466,7 @@ void init(Handle target) { // Soft Tone EXPORT(softToneCreate); EXPORT(softToneWrite); + EXPORT(softToneStop); // WiringPI I2C EXPORT(wiringPiI2CRead);