Port of Arduino Pixy Cmucam5 library.

Dependents:   __cam1

Fork of pixy by Arcadie Cracan

Committer:
acracan
Date:
Sun Nov 16 11:52:55 2014 +0000
Revision:
0:ed8dc4531ac1
Initial commit of ported version of the Arduino Pixy Cmucam5 library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
acracan 0:ed8dc4531ac1 1 #ifndef TUIASI_PIXYLINKI2C_H
acracan 0:ed8dc4531ac1 2 #define TUIASI_PIXYLINKI2C_H
acracan 0:ed8dc4531ac1 3
acracan 0:ed8dc4531ac1 4 #include "I2C.h"
acracan 0:ed8dc4531ac1 5 #include "PixyLink.h"
acracan 0:ed8dc4531ac1 6
acracan 0:ed8dc4531ac1 7 class PixyLinkI2C : public PixyLink, private I2C
acracan 0:ed8dc4531ac1 8 {
acracan 0:ed8dc4531ac1 9 public:
acracan 0:ed8dc4531ac1 10 PixyLinkI2C(PinName sda, PinName scl) :
acracan 0:ed8dc4531ac1 11 PixyLink(PIXY_DEFAULT_ADDR), I2C(sda, scl) {
acracan 0:ed8dc4531ac1 12 };
acracan 0:ed8dc4531ac1 13
acracan 0:ed8dc4531ac1 14 virtual uint16_t getWord() {
acracan 0:ed8dc4531ac1 15 uint8_t data[2] = {0, 0};
acracan 0:ed8dc4531ac1 16 I2C::read((int)m_addr, (char *)data, 2);
acracan 0:ed8dc4531ac1 17 return ((uint16_t)data[1] << 8) | data[0];
acracan 0:ed8dc4531ac1 18 };
acracan 0:ed8dc4531ac1 19
acracan 0:ed8dc4531ac1 20 virtual uint8_t getByte() {
acracan 0:ed8dc4531ac1 21 uint8_t data = 0;
acracan 0:ed8dc4531ac1 22 I2C::read((int)m_addr, (char*)&data, 1);
acracan 0:ed8dc4531ac1 23 return data;
acracan 0:ed8dc4531ac1 24 };
acracan 0:ed8dc4531ac1 25
acracan 0:ed8dc4531ac1 26 virtual int8_t send(uint8_t *data, uint8_t len) {
acracan 0:ed8dc4531ac1 27 return I2C::write((int)m_addr, (char*)data, len);
acracan 0:ed8dc4531ac1 28 };
acracan 0:ed8dc4531ac1 29
acracan 0:ed8dc4531ac1 30
acracan 0:ed8dc4531ac1 31 private:
acracan 0:ed8dc4531ac1 32 static const uint8_t PIXY_DEFAULT_ADDR = 0x54;
acracan 0:ed8dc4531ac1 33 };
acracan 0:ed8dc4531ac1 34
acracan 0:ed8dc4531ac1 35 #endif //TUIASI_PIXYLINKI2C_H