├── I2C_ADC ├── examples │ └── I2C_ADC_Test │ │ └── I2C_ADC_Test.ino ├── keywords.txt ├── library.properties └── src │ ├── I2C_ADC.cpp │ └── I2C_ADC.h ├── I2C_DigitalPot ├── examples │ └── I2C_DigitalPot_Test │ │ └── I2C_DigitalPot_Test.ino ├── keywords.txt ├── library.properties └── src │ ├── I2C_DigitalPot.cpp │ └── I2C_DigitalPot.h ├── I2C_EEPROM ├── examples │ └── I2C_EEPROM_Test │ │ └── I2C_EEPROM_Test.ino ├── keywords.txt ├── library.properties └── src │ ├── I2C_EEPROM.cpp │ └── I2C_EEPROM.h ├── I2C_PortExpander ├── examples │ └── I2C_PortExpander_Test │ │ └── I2C_PortExpander_Test.ino ├── keywords.txt ├── library.properties └── src │ ├── I2C_PortExpander.cpp │ └── I2C_PortExpander.h ├── LICENSE └── README.md /I2C_ADC/examples/I2C_ADC_Test/I2C_ADC_Test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* I2C_ADC Test 5 | * Constantly read all 4 channels and print results to Serial 6 | */ 7 | 8 | // uncomment the following if using the Website Board 9 | #define PULL_ADC_PINS_HIGH 10 | 11 | void setup() 12 | { 13 | MYSERIAL.begin(38400); 14 | while (!MYSERIAL); // wait for Serial port to connect 15 | MYSERIAL.println("Started"); 16 | 17 | #ifdef PULL_ADC_PINS_HIGH 18 | pinMode(A6,OUTPUT); 19 | pinMode(A7,OUTPUT); 20 | digitalWrite(A6,HIGH); 21 | digitalWrite(A7,HIGH); 22 | #endif 23 | 24 | ADC2.begin(); 25 | MYSERIAL.println("I2C Initialised"); 26 | } 27 | 28 | void loop() 29 | { 30 | int i; 31 | 32 | while(1) 33 | { 34 | for(i=0;i 5 | sentence=Allows the AD7995 4 channel I2C ADC to be used in a similar manor to analogRead() 6 | paragraph=This library is created and maintained by Olly McBride on behalf of Open Bionics. 7 | category=Device Control 8 | url=http://www.openbionics.com 9 | architectures=avr,samd 10 | -------------------------------------------------------------------------------- /I2C_ADC/src/I2C_ADC.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C_ADC.cpp 3 | * 4 | * Created: 11/11/2015 14:08:12 5 | * Author: Olly McBride 6 | * 7 | * This work is licensed under the Creative Commons Attribution 4.0 International License. 8 | * To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 9 | * 10 | */ 11 | 12 | #include 13 | #include "I2C_ADC.h" 14 | 15 | // Constructors //////////////////////////////////////////////////////////////// 16 | I2C_ADC::I2C_ADC() 17 | { 18 | } 19 | 20 | // Public Methods ////////////////////////////////////////////////////////////// 21 | void I2C_ADC::begin() 22 | { 23 | uint8_t configMask = 0xF0; //enable CH3, CH2, CH1, CH0 B11110000 24 | 25 | #ifdef PULL_ADC_PINS_HIGH 26 | pinMode(A6,OUTPUT); 27 | pinMode(A7,OUTPUT); 28 | digitalWrite(A6,HIGH); 29 | digitalWrite(A7,HIGH); 30 | #endif 31 | 32 | enableADC[ADC2_CH0] = 1; 33 | enableADC[ADC2_CH1] = 1; 34 | enableADC[ADC2_CH2] = 1; 35 | enableADC[ADC2_CH3] = 1; 36 | 37 | Wire.begin(); 38 | 39 | Wire.beginTransmission(ADC2_ADDR); 40 | Wire.write(configMask); 41 | Wire.endTransmission(); 42 | 43 | #ifdef ADC2_DEBUG 44 | MYSERIAL.print("ADC2.begin() addr "); 45 | printBin(ADC2_ADDR); 46 | MYSERIAL.print(" configMask "); 47 | printBin(configMask); 48 | MYSERIAL.print("\n"); 49 | #endif 50 | } 51 | 52 | uint16_t I2C_ADC::read(uint8_t channel) 53 | { 54 | uint8_t i; 55 | uint8_t rxByte[2]; 56 | uint16_t ADCval[NUM_CHANNELS]; 57 | #ifdef ADC2_DEBUG 58 | MYSERIAL.print("ADC2.read() addr "); 59 | printBin(ADC2_ADDR); 60 | MYSERIAL.print(" "); 61 | #endif 62 | Wire.requestFrom(ADC2_ADDR,(NUM_CHANNELS*2)); 63 | for(i=0;i> 2) & B00111111); 70 | #ifdef ADC2_DEBUG 71 | MYSERIAL.print("rxByte["); 72 | MYSERIAL.print((2*i)); 73 | MYSERIAL.print("] "); 74 | printBin(rxByte[0]); 75 | MYSERIAL.print(" rxByte["); 76 | MYSERIAL.print((2*i)+1); 77 | MYSERIAL.print("] "); 78 | printBin(rxByte[1]); 79 | MYSERIAL.print(" "); 80 | #endif 81 | } 82 | else 83 | { 84 | ADCval[i] = 0; 85 | } 86 | } 87 | 88 | #ifdef ADC2_DEBUG 89 | MYSERIAL.print(" ADC2.read() channel "); 90 | MYSERIAL.print(channel); 91 | MYSERIAL.print(" ADCval[] "); 92 | MYSERIAL.println(ADCval[channel]); 93 | #endif 94 | 95 | return ADCval[channel]; 96 | } 97 | 98 | // Private Methods ////////////////////////////////////////////////////////////// 99 | 100 | void I2C_ADC::printBin(uint8_t inVal) 101 | { 102 | for (uint8_t i = 1; i < 8; i++) 103 | { 104 | if (inVal < pow(2, i)) MYSERIAL.print(B0); 105 | } 106 | MYSERIAL.print(inVal,BIN); 107 | } 108 | 109 | // Preinstantiate Objects ////////////////////////////////////////////////////// 110 | I2C_ADC ADC2 = I2C_ADC(); -------------------------------------------------------------------------------- /I2C_ADC/src/I2C_ADC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C_ADC.h 3 | * 4 | * Created: 11/11/2015 14:08:12 5 | * Author: Olly McBride 6 | * 7 | * This work is licensed under the Creative Commons Attribution 4.0 International License. 8 | * To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 9 | * 10 | * AD7995 4 channel I2C ADC 11 | * 12 | */ 13 | 14 | #ifndef I2C_ADC_H_ 15 | #define I2C_ADC_H_ 16 | 17 | #include 18 | #include 19 | 20 | // Architecture specific include 21 | #if defined(ARDUINO_ARCH_AVR) 22 | #ifndef MYSERIAL 23 | #define MYSERIAL Serial 24 | #endif 25 | #elif defined(ARDUINO_ARCH_SAMD) 26 | #ifndef MYSERIAL 27 | #define MYSERIAL SerialUSB 28 | #endif 29 | #endif 30 | 31 | //#define ADC2_DEBUG 32 | 33 | #define ADC2_ADDR 0x28 // I2C ADC address 0x28 010 1000 40 34 | 35 | #define ENABLE 1 36 | #define DISABLE 0 37 | 38 | #define NUM_CHANNELS 4 // number of channels available 39 | #define ADC2_CH0 0 40 | #define ADC2_CH1 1 41 | #define ADC2_CH2 2 42 | #define ADC2_CH3 3 43 | 44 | #define LENGTH 16 // length of data read for AD7995-0, 2 bytes 45 | 46 | //#define I2C_ADC_NC 959 // I2C disconnected value 47 | 48 | class I2C_ADC 49 | { 50 | public: 51 | I2C_ADC(); 52 | void begin(void); 53 | uint16_t read(uint8_t channel); 54 | 55 | uint8_t enableADC[NUM_CHANNELS] = {0}; 56 | 57 | private: 58 | void printBin(uint8_t inVal); 59 | }; 60 | 61 | extern I2C_ADC ADC2; 62 | 63 | #endif /* I2C_ADC_H_ */ -------------------------------------------------------------------------------- /I2C_DigitalPot/examples/I2C_DigitalPot_Test/I2C_DigitalPot_Test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* I2C_Pot Test 5 | * Potential divider test mode (v) 6 | * Sweep the pot from 0V to VIN in 10 steps 7 | * 8 | * Variable resistor test mode (r) 9 | * Sweep the pot from 0R to TOTAL_R in 10 steps 10 | * 11 | * 12 | * Note: 13 | * MYSERIAL.print is used instead of Serial.Print or SerialUSB.print to allow 14 | * this example to be used on both the Mega and the Zero without any modification 15 | */ 16 | 17 | // uncomment the following if using the Website Board 18 | //#define PULL_ADC_PINS_HIGH 19 | 20 | // uncomment one of the following that relates to the digital pot 21 | //#define TOTAL_R 1000 // 1k 22 | //#define TOTAL_R 5000 // 5k 23 | #define TOTAL_R 10000 // 10k 24 | //#define TOTAL_R 50000 // 50k 25 | //#define TOTAL_R 100000 // 100k 26 | 27 | // input voltage 28 | #define VIN 3.3 29 | 30 | // number of steps for test mode 31 | #define NUM_STEPS 10 32 | 33 | D_POT DPOT = D_POT(0,TOTAL_R,VIN); 34 | 35 | void setup() 36 | { 37 | MYSERIAL.begin(38400); 38 | while (!MYSERIAL); // wait for Serial port to connect 39 | MYSERIAL.println("Started"); 40 | 41 | #ifdef PULL_ADC_PINS_HIGH 42 | pinMode(A6,OUTPUT); 43 | pinMode(A7,OUTPUT); 44 | digitalWrite(A6,HIGH); 45 | digitalWrite(A7,HIGH); 46 | #endif 47 | 48 | MYSERIAL.println("Press 'v' to run the potential divider test, or press 'r' to run the variable resistor test"); 49 | } 50 | 51 | void loop(void) 52 | { 53 | if(MYSERIAL.available()) 54 | { 55 | char in = MYSERIAL.read(); 56 | if(in == 'v') 57 | { 58 | in = 0; 59 | dividerTest(); 60 | } 61 | else if(in == 'c') 62 | { 63 | in = 0; 64 | resistorTest(); 65 | } 66 | } 67 | } 68 | 69 | void dividerTest(void) 70 | { 71 | int i; 72 | float Vstep; 73 | 74 | Vstep = (float) VIN/NUM_STEPS; 75 | 76 | MYSERIAL.print("Voltage divider test mode"); 77 | MYSERIAL.print(NUM_STEPS); 78 | MYSERIAL.print(" from 0V to "); 79 | MYSERIAL.print(VIN); 80 | MYSERIAL.print("V, with a step size of"); 81 | MYSERIAL.println(Vstep); 82 | 83 | for(i=0;i 5 | sentence=Allows the AD5171 64 position OTP I2C digital potentiometer to be used 6 | paragraph=This library is created and maintained by Olly McBride on behalf of Open Bionics. 7 | category=Device Control 8 | url=http://www.openbionics.com 9 | architectures=avr,samd 10 | -------------------------------------------------------------------------------- /I2C_DigitalPot/src/I2C_DigitalPot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C_DigitalPot.cpp 3 | * 4 | * Created: 27/11/15 14:24 5 | * Author: Olly McBride 6 | * 7 | * This work is licensed under the Creative Commons Attribution 4.0 International License. 8 | * To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 9 | * 10 | * AD5171 64 position I2C digital potentiometer 11 | * 12 | */ 13 | 14 | #include 15 | #include "I2C_DigitalPot.h" 16 | 17 | // Constructors //////////////////////////////////////////////////////////////// 18 | D_POT::D_POT() 19 | { 20 | D_POT(0,10000,0); // set Rtotal to 10k, disable potential divider mode 21 | } 22 | 23 | D_POT::D_POT(bool AD0, uint16_t Rtotal) 24 | { 25 | D_POT(AD0,Rtotal,0); // disable potential divider mode 26 | } 27 | 28 | D_POT::D_POT(bool AD0, uint16_t Rtotal, uint8_t Vin) 29 | { 30 | _potAddr = DPOT_ADDR | AD0; // configurable address 31 | _OTP_EN = false; // disable one-time programming mode 32 | _Rab = Rtotal; // store total resistance 33 | _Vin = Vin; // store Vin 34 | 35 | #ifdef DPOT_DEBUG 36 | MYSERIAL.print("D_POT AD0 "); 37 | MYSERIAL.print(AD0); 38 | MYSERIAL.print(" addr "); 39 | printBin(_potAddr); 40 | MYSERIAL.print(" Rtotal "); 41 | MYSERIAL.print(Rtotal); 42 | MYSERIAL.print(" Vin "); 43 | MYSERIAL.print(Vin); 44 | if(_OTP_EN) 45 | MYSERIAL.print(" OTP ENABLED "); 46 | MYSERIAL.print("\n"); 47 | #endif 48 | 49 | Wire.begin(); 50 | } 51 | 52 | // Public Methods ////////////////////////////////////////////////////////////// 53 | 54 | // write date to pot 55 | void D_POT::writeD(uint8_t D) 56 | { 57 | uint8_t OTP_instr; 58 | 59 | // uncomment the next line to enable one-time programming mode 60 | //OTP_instr = (uint8_t) _OTP_EN; 61 | OTP_instr = 0; 62 | 63 | D = constrain(D,0,63); // 0 < D < 63 64 | 65 | #ifdef DPOT_DEBUG 66 | MYSERIAL.print("D_POT.writeD("); 67 | MYSERIAL.print(D); 68 | MYSERIAL.print(") to "); 69 | printBin(_potAddr); 70 | if(OTP_instr) 71 | MYSERIAL.print(" WARNING OTP ENABLED "); 72 | MYSERIAL.print("\n"); 73 | #endif 74 | 75 | Wire.beginTransmission(_potAddr); 76 | Wire.write(OTP_instr); // activate OTP if flag enabled 77 | Wire.write(D); // write data 78 | Wire.endTransmission(); 79 | 80 | #ifdef DPOT_DEBUG 81 | MYSERIAL.println("Complete"); 82 | #endif 83 | } 84 | 85 | void D_POT::writeRwb(uint16_t Rwb) 86 | { 87 | const uint8_t Rw = 60; // wiper resistance 88 | uint8_t D; 89 | 90 | D = (uint8_t)((Rwb - Rw) * 63)/_Rab; // convert target resistance Rwb to data value D (0 < D < Rw) 91 | 92 | #ifdef DPOT_DEBUG 93 | MYSERIAL.print("D_POT.writeRwb("); 94 | MYSERIAL.print(Rwb); 95 | MYSERIAL.print(") D = "); 96 | MYSERIAL.print(D); 97 | MYSERIAL.print(" addr "); 98 | printBin(_potAddr); 99 | MYSERIAL.print("\n"); 100 | #endif 101 | 102 | writeD(D); 103 | } 104 | 105 | void D_POT::writeRwa(uint16_t Rwa) 106 | { 107 | const uint8_t Rw = 60; // wiper resistance 108 | uint8_t D; 109 | 110 | D = (uint8_t)(63*(_Rab + Rw - Rwa))/_Rab; // convert target resistance Rwa to data value D (0 < D < Rw) 111 | 112 | #ifdef DPOT_DEBUG 113 | MYSERIAL.print("D_POT.writeRwa("); 114 | MYSERIAL.print(Rwa); 115 | MYSERIAL.print(") D = "); 116 | MYSERIAL.print(D); 117 | MYSERIAL.print(" addr "); 118 | printBin(_potAddr); 119 | MYSERIAL.print("\n"); 120 | #endif 121 | 122 | writeD(D); 123 | } 124 | 125 | void D_POT::writeR(uint16_t R) 126 | { 127 | writeRwb(R); 128 | } 129 | 130 | void D_POT::writeV(float Vw) 131 | { 132 | uint8_t D; 133 | 134 | D = (uint8_t) ((float)(Vw/_Vin)*63); 135 | 136 | #ifdef DPOT_DEBUG 137 | MYSERIAL.print("D_POT.writeV("); 138 | MYSERIAL.print(Vw); 139 | MYSERIAL.print(") D = "); 140 | MYSERIAL.print(D); 141 | MYSERIAL.print(" addr "); 142 | printBin(_potAddr); 143 | MYSERIAL.print("\n"); 144 | #endif 145 | 146 | writeD(D); 147 | } 148 | 149 | void D_POT::enableOTP(void) 150 | { 151 | // uncomment the following line to enable one-time programming mode 152 | //_OTP_EN = true; 153 | // you also need to uncomment the stated line within writeD() 154 | } 155 | 156 | // Private Methods ////////////////////////////////////////////////////////////// 157 | 158 | void D_POT::printBin(uint8_t inVal) 159 | { 160 | for (uint8_t i = 1; i < 8; i++) 161 | { 162 | if (inVal < pow(2, i)) MYSERIAL.print(B0); 163 | } 164 | MYSERIAL.print(inVal,BIN); 165 | } 166 | -------------------------------------------------------------------------------- /I2C_DigitalPot/src/I2C_DigitalPot.h: -------------------------------------------------------------------------------- 1 | D/* 2 | * I2C_DigitalPot.h 3 | * 4 | * Created: 27/11/15 14:24 5 | * Author: Olly McBride 6 | * 7 | * This work is licensed under the Creative Commons Attribution 4.0 International License. 8 | * To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 9 | * 10 | * AD5171 64 position I2C digital potentiometer 11 | * 12 | */ 13 | 14 | #ifndef I2C_DIGITALPOT_H_ 15 | #define I2C_DIGITALPOT_H_ 16 | 17 | #include 18 | #include 19 | 20 | // Architecture specific include 21 | #if defined(ARDUINO_ARCH_AVR) 22 | #ifndef MYSERIAL 23 | #define MYSERIAL Serial 24 | #endif 25 | #elif defined(ARDUINO_ARCH_SAMD) 26 | #ifndef MYSERIAL 27 | #define MYSERIAL SerialUSB 28 | #endif 29 | #endif 30 | 31 | #define DPOT_DEBUG 32 | 33 | #define DPOT_ADDR 0x2C // I2C ADC address configurable 010 110 AD0 34 | // AD0 = 0 0x2C 010 1100 OR AD0 = 1 0x2D 010 1101 35 | 36 | class D_POT 37 | { 38 | public: 39 | D_POT(); 40 | D_POT(bool AD0, uint16_t Rtotal); 41 | D_POT(bool AD0, uint16_t Rtotal, uint8_t Vin); 42 | void writeD(uint8_t D); 43 | void writeRwb(uint16_t R); 44 | void writeRwa(uint16_t R); 45 | void writeR(uint16_t R); 46 | void writeV(float Vw); 47 | 48 | void enableOTP(void); 49 | 50 | private: 51 | void printBin(uint8_t inVal); 52 | 53 | uint8_t _potAddr; 54 | bool _OTP_EN; 55 | uint16_t _Rab; 56 | uint8_t _Vin; 57 | }; 58 | 59 | #endif /* I2C_DIGITALPOT_H_ */ -------------------------------------------------------------------------------- /I2C_EEPROM/examples/I2C_EEPROM_Test/I2C_EEPROM_Test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // uncomment the following if using the Website Board 4 | //#define PULL_ADC_PINS_HIGH 5 | 6 | #include 7 | 8 | /* I2C_EEPROM Test 9 | * If the letter k is entered over serial, a read, write, read cycle is performed 10 | * as the EEPROM location denoted by MEM_POS 11 | */ 12 | 13 | #define AMOUNT_TO_WRITE 1000 14 | 15 | #define MEM_POS 12 // EEPROM location to store value 16 | int val = 70; // value to write to EEPROM 17 | 18 | int rxByte[3]; // buffer to store received values 19 | 20 | void setup() 21 | { 22 | MYSERIAL.begin(38400); 23 | while (!MYSERIAL); // wait for Serial port to connect 24 | MYSERIAL.println("Started"); 25 | 26 | EEPROM2.begin(); 27 | MYSERIAL.println("I2C Initialised"); 28 | 29 | MYSERIAL.println("Press 'k' to test the EEPROM, 'r' to read the contents (0-255) or press 'c' to clear the EEPROM (set all values to 255)"); 30 | } 31 | 32 | void loop(void) 33 | { 34 | if(MYSERIAL.available()) 35 | { 36 | char in = MYSERIAL.read(); 37 | if(in == 'k') 38 | { 39 | in = 0; 40 | MYSERIAL.print("About to read from pos "); 41 | MYSERIAL.println(MEM_POS); 42 | rxByte[0] = EEPROM2.read(MEM_POS); 43 | MYSERIAL.print("Value read = "); 44 | MYSERIAL.println(rxByte[0]); 45 | MYSERIAL.print("About to write the value "); 46 | MYSERIAL.print(val); 47 | MYSERIAL.print(" to pos "); 48 | MYSERIAL.println(MEM_POS); 49 | EEPROM2.write(MEM_POS, val); 50 | MYSERIAL.print("About to read again from pos "); 51 | MYSERIAL.println(MEM_POS); 52 | rxByte[1] = EEPROM2.read(MEM_POS); 53 | MYSERIAL.print("Value read = "); 54 | MYSERIAL.println(rxByte[1]); 55 | 56 | if(rxByte[1] == val) 57 | MYSERIAL.println("Test Passed "); 58 | else 59 | MYSERIAL.println("Test Failed :( "); 60 | 61 | MYSERIAL.println("Test Complete \n"); 62 | 63 | delay(33); 64 | } 65 | else if(in == 'c') 66 | { 67 | in = 0; 68 | MYSERIAL.println("Clearing EEPROM"); 69 | EEPROM2.clearAll(0,AMOUNT_TO_WRITE); 70 | MYSERIAL.println("Clear Complete \n"); 71 | } 72 | else if(in == 'r') 73 | { 74 | in = 0; 75 | int i; 76 | for(i=0;i 5 | sentence=Allows the T24C512C 512Kb I2C EEPROM to be used in a similar manor to the EEPROM.h library 6 | paragraph=This library is created and maintained by Olly McBride on behalf of Open Bionics. 7 | category=Device Control 8 | url=http://www.openbionics.com 9 | architectures=avr,samd 10 | -------------------------------------------------------------------------------- /I2C_EEPROM/src/I2C_EEPROM.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C_EEPROM.cpp 3 | * 4 | * Created: 11/11/2015 14:08:12 5 | * Author: Olly McBride 6 | * 7 | * This work is licensed under the Creative Commons Attribution 4.0 International License. 8 | * To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 9 | * 10 | */ 11 | 12 | #include 13 | #include "I2C_EEPROM.h" 14 | 15 | // Constructors //////////////////////////////////////////////////////////////// 16 | I2C_EEPROM::I2C_EEPROM() 17 | { 18 | } 19 | 20 | // Public Methods ////////////////////////////////////////////////////////////// 21 | void I2C_EEPROM::begin(void) 22 | { 23 | #ifdef PULL_ADC_PINS_HIGH 24 | pinMode(A6,OUTPUT); 25 | pinMode(A7,OUTPUT); 26 | digitalWrite(A6,HIGH); 27 | digitalWrite(A7,HIGH); 28 | #endif 29 | 30 | Wire.begin(); 31 | } 32 | 33 | uint8_t I2C_EEPROM::read(uint16_t addr) 34 | { 35 | uint8_t rxByte; 36 | 37 | Wire.beginTransmission(EEPROM_ADDR); 38 | writeAddr(addr); 39 | Wire.endTransmission(RESTART); 40 | rxByte = readLast(); 41 | 42 | #ifdef EEPROM2_DEBUG 43 | MYSERIAL.print("read chipAddr "); 44 | printBin(EEPROM_ADDR); 45 | MYSERIAL.print(" loc "); 46 | MYSERIAL.print(addr); 47 | MYSERIAL.print(" received "); 48 | MYSERIAL.println(rxByte); 49 | #endif 50 | 51 | return rxByte; 52 | } 53 | 54 | uint8_t I2C_EEPROM::readLast(void) 55 | { 56 | uint8_t rxByte; 57 | Wire.requestFrom(EEPROM_ADDR,1); 58 | rxByte = Wire.read(); 59 | return rxByte; 60 | } 61 | 62 | void I2C_EEPROM::readPage(uint16_t addr, uint8_t* val, uint8_t numToRead) 63 | { 64 | numToRead = constrain(numToRead,0,127); 65 | Wire.beginTransmission(EEPROM_ADDR); 66 | writeAddr(addr); 67 | Wire.endTransmission(); 68 | Wire.requestFrom(EEPROM_ADDR,(int)numToRead); 69 | for(int i=0;i> 8) & 0xFF)); // MSB 126 | Wire.write((uint8_t)(addr & 0xFF)); // LSB 127 | } 128 | 129 | void I2C_EEPROM::printBin(uint8_t inVal) 130 | { 131 | for (uint8_t i = 1; i < 8; i++) 132 | { 133 | if (inVal < pow(2, i)) MYSERIAL.print(B0); 134 | } 135 | MYSERIAL.print(inVal,BIN); 136 | } 137 | 138 | // Preinstantiate Objects ////////////////////////////////////////////////////// 139 | I2C_EEPROM EEPROM2 = I2C_EEPROM(); -------------------------------------------------------------------------------- /I2C_EEPROM/src/I2C_EEPROM.h: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C_EEPROM.h 3 | * 4 | * Created: 11/11/2015 14:08:12 5 | * Author: Olly McBride 6 | * 7 | * This work is licensed under the Creative Commons Attribution 4.0 International License. 8 | * To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 9 | * 10 | */ 11 | 12 | #ifndef I2C_EEPROM_H_ 13 | #define I2C_EEPROM_H_ 14 | 15 | #include 16 | #include 17 | 18 | // Architecture specific include 19 | #if defined(ARDUINO_ARCH_AVR) 20 | #ifndef MYSERIAL 21 | #define MYSERIAL Serial 22 | #endif 23 | #elif defined(ARDUINO_ARCH_SAMD) 24 | #ifndef MYSERIAL 25 | #define MYSERIAL SerialUSB 26 | #endif 27 | #endif 28 | 29 | //#define EEPROM2_DEBUG 30 | 31 | #define EEPROM_ADDR 0x50 // B01010000 32 | #define TWR 5 // num mS after EEPROM write 33 | #define RESTART 0 // send RESTART instead of STOP 34 | 35 | class I2C_EEPROM 36 | { 37 | public: 38 | I2C_EEPROM(); 39 | void begin(void); 40 | uint8_t read(uint16_t addr); 41 | uint8_t readLast(void); 42 | void readPage(uint16_t addr, uint8_t* val, uint8_t numToRead); 43 | void write(uint16_t addr, uint8_t val); 44 | void writePage(uint16_t addr, uint8_t* val, uint8_t numToWrite); 45 | void writeAll(uint8_t val, uint16_t start, uint16_t stop); 46 | void clearAll(uint16_t start, uint16_t stop); 47 | //void update(uint16_t idx, uint8_t val); 48 | 49 | private: 50 | void pollACK(void); 51 | void writeAddr(uint16_t addr); 52 | void printBin(uint8_t inVal); 53 | }; 54 | 55 | extern I2C_EEPROM EEPROM2; 56 | 57 | #endif /* I2C_EEPROM_H_ */ -------------------------------------------------------------------------------- /I2C_PortExpander/examples/I2C_PortExpander_Test/I2C_PortExpander_Test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // uncomment the following if using the Website Board 4 | //#define PULL_ADC_PINS_HIGH 5 | 6 | #include 7 | 8 | /* I2C_PortExpander Test 9 | * Blink all intialised pins, or toggle LED on button press 10 | */ 11 | 12 | 13 | void setup(void) 14 | { 15 | MYSERIAL.begin(38400); 16 | while (!MYSERIAL); // wait for Serial port to connect 17 | MYSERIAL.println("Started"); 18 | 19 | portExpander.begin(); 20 | MYSERIAL.println("I2C Initialised"); 21 | 22 | // turn on LED to show initialisation complete 23 | portExpander.write(ARM_LED,HIGH); 24 | } 25 | 26 | void loop(void) 27 | { 28 | int toggle = 0; 29 | int prev = 0; 30 | int cur = 0; 31 | while(1) 32 | { 33 | // blink all initialised pins 34 | MYSERIAL.print("Turning them all on..."); 35 | portExpander.write(ARM_LED,HIGH); 36 | portExpander.write(HAP_M0,HIGH); 37 | portExpander.write(HAP_M1,HIGH); 38 | portExpander.write(HAP_M2,HIGH); 39 | portExpander.write(HAP_M3,HIGH); 40 | portExpander.write(HAP_M4,HIGH); 41 | MYSERIAL.println(" Complete"); 42 | delay(1000); 43 | MYSERIAL.print("Turning them all off..."); 44 | portExpander.write(ARM_LED,LOW); 45 | portExpander.write(HAP_M0,LOW); 46 | portExpander.write(HAP_M1,LOW); 47 | portExpander.write(HAP_M2,LOW); 48 | portExpander.write(HAP_M3,LOW); 49 | portExpander.write(HAP_M4,LOW); 50 | MYSERIAL.println(" Complete"); 51 | delay(1000); 52 | 53 | 54 | /* // toggle the LED on the button press 55 | prev = cur; 56 | cur = portExpander.read(ARM_BTN); 57 | if((!prev)&&cur)toggle = !toggle; 58 | portExpander.write(ARM_LED,toggle); 59 | */ 60 | 61 | 62 | } 63 | } 64 | 65 | 66 | -------------------------------------------------------------------------------- /I2C_PortExpander/keywords.txt: -------------------------------------------------------------------------------- 1 | ###################################### 2 | # Syntax Coloring Map Finger 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | portExpander KEYWORD1 10 | I2C_PORTEXPANDER KEYWORD1 11 | I2C_PortExpander KEYWORD1 12 | 13 | ####################################### 14 | # Methods and Functions (KEYWORD2) 15 | ####################################### 16 | begin KEYWORD2 17 | write KEYWORD2 18 | read KEYWORD2 19 | portMode KEYWORD2 20 | portWrite KEYWORD2 21 | 22 | 23 | ####################################### 24 | # Constants (LITERAL1) 25 | ####################################### 26 | -------------------------------------------------------------------------------- /I2C_PortExpander/library.properties: -------------------------------------------------------------------------------- 1 | name=I2C_PortExpander 2 | version=1.0 3 | author=Olly McBride 4 | maintainer=Olly McBride 5 | sentence=Allows the PCA9535 I2C port expander to be used with read() write() functionality 6 | paragraph=This library is created and maintained by Olly McBride on behalf of Open Bionics. 7 | category=Device Control 8 | url=http://www.openbionics.com 9 | architectures=avr,samd 10 | -------------------------------------------------------------------------------- /I2C_PortExpander/src/I2C_PortExpander.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C_PortExpander.cpp 3 | * 4 | * Created: 11/11/2015 14:08:12 5 | * Author: Olly McBride 6 | * 7 | * This work is licensed under the Creative Commons Attribution 4.0 International License. 8 | * To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 9 | * 10 | */ 11 | 12 | #include 13 | #include "I2C_PortExpander.h" 14 | 15 | // Constructors //////////////////////////////////////////////////////////////// 16 | I2C_PORTEXPANDER::I2C_PORTEXPANDER() 17 | { 18 | } 19 | 20 | // Public Methods ////////////////////////////////////////////////////////////// 21 | void I2C_PORTEXPANDER::begin(void) 22 | { 23 | #ifdef PULL_ADC_PINS_HIGH 24 | pinMode(A6,OUTPUT); 25 | pinMode(A7,OUTPUT); 26 | digitalWrite(A6,HIGH); 27 | digitalWrite(A7,HIGH); 28 | #endif 29 | 30 | Wire.begin(); 31 | portMode(PORT0,OUTPUT); 32 | portMode(PORT1,INPUT); 33 | 34 | portWrite(PORT0,LOW); // initialise PORT0 to 0 35 | } 36 | 37 | void I2C_PORTEXPANDER::portMode(uint8_t port, uint8_t state) 38 | { 39 | uint8_t configByte; 40 | uint8_t txBuff; 41 | 42 | state = !state; 43 | 44 | configByte = 0x06 | port; // select port for config (B000000110 or B000000111) 45 | txBuff = 0xFF * state; 46 | 47 | #ifdef PORTE_DEBUG 48 | MYSERIAL.print("portMode port"); 49 | MYSERIAL.print(port); 50 | MYSERIAL.print(" state "); 51 | MYSERIAL.print(state); 52 | MYSERIAL.print(" configByte "); 53 | leadingZeros(configByte); 54 | MYSERIAL.print(configByte,BIN); 55 | MYSERIAL.print(" txBuff "); 56 | leadingZeros(txBuff); 57 | MYSERIAL.println(txBuff,BIN); 58 | #endif 59 | 60 | Wire.beginTransmission(PORT_EXPANDER_ADDR); 61 | Wire.write(configByte); 62 | Wire.write(txBuff); 63 | Wire.endTransmission(); 64 | } 65 | 66 | void I2C_PORTEXPANDER::portWrite(uint8_t port, uint8_t state) 67 | { 68 | uint8_t configByte; 69 | 70 | configByte = 0x02 | (port<<1); 71 | portMask[port] = 0xFF * port; 72 | 73 | #ifdef PORTE_DEBUG 74 | MYSERIAL.print("portWrite port"); 75 | MYSERIAL.print(port); 76 | MYSERIAL.print(" state "); 77 | MYSERIAL.print(state); 78 | MYSERIAL.print(" configByte "); 79 | leadingZeros(configByte); 80 | MYSERIAL.print(configByte,BIN); 81 | MYSERIAL.print(" portMask"); 82 | MYSERIAL.print(port); 83 | MYSERIAL.print(" "); 84 | leadingZeros(portMask[port]); 85 | MYSERIAL.println(portMask[port],BIN); 86 | #endif 87 | 88 | Wire.beginTransmission(PORT_EXPANDER_ADDR); 89 | Wire.write(configByte); 90 | Wire.write(portMask[port]); 91 | Wire.endTransmission(); 92 | } 93 | 94 | void I2C_PORTEXPANDER::write(uint8_t pin, uint8_t val, uint8_t duration) 95 | { 96 | uint8_t port, configByte; 97 | 98 | #ifdef PIN_LATCH 99 | if(duration>0) // if latch duration entered 100 | { 101 | latchIndex++; // increase stack index 102 | latchStack[latchIndex][PIN] = pin; 103 | latchStack[latchIndex][COUNT] = duration; 104 | latchStack[latchIndex][STATE] = val; 105 | } 106 | #endif 107 | 108 | port = getPort(pin); 109 | 110 | configByte = 0x02 | (port<<1); // select OUTPUT register (B00000010 or B00000011) 111 | 112 | if(val==HIGH) 113 | { 114 | portMask[port] |= 1<<(pin-(10*port)); 115 | } 116 | else if (val==LOW) 117 | { 118 | portMask[port] &= ~(1<<(pin-(10*port))); 119 | } 120 | 121 | #ifdef PORTE_DEBUG 122 | MYSERIAL.print("write pin "); 123 | MYSERIAL.print(pin); 124 | MYSERIAL.print(" writeVal "); 125 | MYSERIAL.print(val); 126 | MYSERIAL.print(" port"); 127 | MYSERIAL.print(port); 128 | MYSERIAL.print(" configByte "); 129 | leadingZeros(configByte); 130 | MYSERIAL.print(configByte,BIN); 131 | MYSERIAL.print(" portMask"); 132 | MYSERIAL.print(port); 133 | MYSERIAL.print(" "); 134 | leadingZeros(portMask[port]); 135 | MYSERIAL.println(portMask[port],BIN); 136 | #endif 137 | 138 | Wire.beginTransmission(PORT_EXPANDER_ADDR); 139 | Wire.write(configByte); // select output register 140 | Wire.write(portMask[port]); 141 | Wire.endTransmission(); 142 | } 143 | 144 | void I2C_PORTEXPANDER::write(uint8_t pin, uint8_t val) 145 | { 146 | write(pin,val,0); 147 | } 148 | 149 | uint8_t I2C_PORTEXPANDER::read(uint8_t pin) 150 | { 151 | uint8_t configByte; 152 | uint8_t port; 153 | uint8_t val; 154 | 155 | port = getPort(pin); 156 | 157 | configByte = port<<0; // select INPUT register (B00000000 or B00000001) 158 | 159 | Wire.beginTransmission(PORT_EXPANDER_ADDR); 160 | Wire.write(configByte); // send Input register (B00000000 or B00000001) 161 | Wire.endTransmission(); 162 | 163 | Wire.requestFrom(PORT_EXPANDER_ADDR,1); 164 | portMask[port] = Wire.read(); 165 | 166 | val = (portMask[port]>>(pin-(10*port))) & 0x01; 167 | 168 | #ifdef PORTE_DEBUG 169 | MYSERIAL.print("read pin "); 170 | MYSERIAL.print(pin); 171 | MYSERIAL.print(" port"); 172 | MYSERIAL.print(port); 173 | MYSERIAL.print(" configByte "); 174 | leadingZeros(configByte); 175 | MYSERIAL.print(configByte,BIN); 176 | MYSERIAL.print(" portMask"); 177 | MYSERIAL.print(port); 178 | MYSERIAL.print(" "); 179 | leadingZeros(portMask[port]); 180 | MYSERIAL.print(portMask[port],BIN); 181 | MYSERIAL.print(" rxVal "); 182 | MYSERIAL.println(val); 183 | #endif 184 | 185 | return val; 186 | 187 | } 188 | 189 | // Private Methods ////////////////////////////////////////////////////////////// 190 | uint8_t I2C_PORTEXPANDER::getPort(uint8_t pin) 191 | { 192 | if(pin>=10) 193 | { 194 | return PORT1; 195 | } 196 | else 197 | { 198 | return PORT0; 199 | } 200 | } 201 | 202 | void I2C_PORTEXPANDER::leadingZeros(uint8_t inVal) 203 | { 204 | for (uint8_t i = 1; i < 8; i++) 205 | { 206 | if (inVal < pow(2, i)) MYSERIAL.print(B0); 207 | } 208 | } 209 | 210 | // Preinstantiate Objects ////////////////////////////////////////////////////// 211 | I2C_PORTEXPANDER portExpander = I2C_PORTEXPANDER(); -------------------------------------------------------------------------------- /I2C_PortExpander/src/I2C_PortExpander.h: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C_PortExpander.h 3 | * 4 | * Created: 11/11/2015 14:08:12 5 | * Author: Olly McBride 6 | * 7 | * This work is licensed under the Creative Commons Attribution 4.0 International License. 8 | * To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 9 | * 10 | */ 11 | 12 | #ifndef I2C_PORTEXPANDER_H_ 13 | #define I2C_PORTEXPANDER_H_ 14 | 15 | #include 16 | #include 17 | 18 | // Architecture specific include 19 | #if defined(ARDUINO_ARCH_AVR) 20 | #ifndef MYSERIAL 21 | #define MYSERIAL Serial 22 | #endif 23 | #elif defined(ARDUINO_ARCH_SAMD) 24 | #ifndef MYSERIAL 25 | #define MYSERIAL SerialUSB 26 | #endif 27 | #endif 28 | 29 | //#define PORTE_DEBUG 30 | 31 | #define PORT_EXPANDER_ADDR 0x26 // I2C PortExpander address 0x26 010 0110 38 32 | 33 | 34 | /* PINS */ 35 | #define ARM_LED 0 // LED pin 36 | #define ARM_BTN 15 // button pin 37 | #define HAP_M0 1 // motor 0 38 | #define HAP_M1 2 // motor 1 39 | #define HAP_M2 3 // motor 2 40 | #define HAP_M3 4 // motor 3 41 | #define HAP_M4 5 // motor 4 42 | /* PORT NAMES */ 43 | #define PORT0 0 44 | #define PORT1 1 45 | /* VIBRATION NAMES */ 46 | #define CLOCKWISE 0 47 | #define ANTICLOCKWISE 1 48 | #define DOT_DOT_DOT 2 49 | #define DOT_DASH 3 50 | #define DASH_DASH 4 51 | #define LONG_DASH 5 52 | /* PULSE DURATION */ 53 | #define HAP_DOT 1 // default vibration duration for a dot 54 | #define HAP_DASH 5 // default vibration duration for a dash 55 | /* HAPTIC SETTINGS */ 56 | #define NUM_VIB 6 // number of animations 57 | #define NUM_VIB_STEPS 6 // number of steps per animation 58 | #define NUM_HAPTIC_MOTORS 5 // number of vibration motors 59 | 60 | class I2C_PORTEXPANDER 61 | { 62 | public: 63 | I2C_PORTEXPANDER(); 64 | void begin(void); 65 | void write(uint8_t pin, uint8_t val); 66 | void write(uint8_t pin, uint8_t val, uint8_t duration); 67 | uint8_t read(uint8_t pin); 68 | void portMode(uint8_t port, uint8_t state); 69 | void portWrite(uint8_t port, uint8_t state); 70 | 71 | uint8_t runVibFlag = 0; // flag to determine whether to run animation (-1 = no animation) 72 | uint8_t stepNum = 0; // counts through the steps in the haptic animation sequence 73 | uint16_t vibrCounter = 0; // counter for haptic animations/vibration patterns 74 | 75 | private: 76 | uint8_t getPort(uint8_t pin); 77 | void leadingZeros(uint8_t inVal); 78 | 79 | uint8_t portMask[2] = {0}; 80 | }; 81 | 82 | extern I2C_PORTEXPANDER portExpander; 83 | 84 | #endif /* I2C_PORTEXPANDER_H_ */ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Open Bionics - Other_Libraries 2 | 3 | Open Bionics Robotics is the Open Source branch of the Open Bionics company, in which we release proven software, electronics and 3D design files in order to aid the maker community in their experimentation with robotic hands. 4 | 5 | Included in this repositry; 6 | 7 | Arduino Libraries 8 | 9 | - I2C_ADC - Basic functionality of the AD7995, a 4 channel I2C ADC 10 | - I2C_DigitalPot - Basic functionality of the AD5171 64 position OTP I2C digital potentiometer 11 | - I2C_EEPROM - Basic functionality of the T24C512C 512Kb I2C EEPROM 12 | - I2C_PortExpander - Basic functionality of the PCA9535 I2C port expander 13 | 14 | 15 | This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. 16 | To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ 17 | --------------------------------------------------------------------------------