acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
Arduino_XL9535SWSPI.h (1722B)
1 #ifndef _ARDUINO_XL9535SWSPI_H_ 2 #define _ARDUINO_XL9535SWSPI_H_ 3 4 #include <Wire.h> 5 6 #include "Arduino_DataBus.h" 7 8 #define XL9535_IIC_ADDRESS 0X20 9 10 #define XL9535_INPUT_PORT_0_REG 0X00 11 #define XL9535_INPUT_PORT_1_REG 0X01 12 #define XL9535_OUTPUT_PORT_0_REG 0X02 13 #define XL9535_OUTPUT_PORT_1_REG 0X03 14 #define XL9535_INVERSION_PORT_0_REG 0X04 15 #define XL9535_INVERSION_PORT_1_REG 0X05 16 #define XL9535_CONFIG_PORT_0_REG 0X06 17 #define XL9535_CONFIG_PORT_1_REG 0X07 18 19 class Arduino_XL9535SWSPI : public Arduino_DataBus 20 { 21 public: 22 Arduino_XL9535SWSPI(int8_t sda, int8_t scl, int8_t pwd, int8_t cs, int8_t sck, int8_t mosi, TwoWire *wire = &Wire); 23 24 bool begin(int32_t speed = GFX_NOT_DEFINED, int8_t dataMode = GFX_NOT_DEFINED) override; 25 void beginWrite() override; 26 void endWrite() override; 27 void writeCommand(uint8_t) override; 28 void writeCommand16(uint16_t) override; 29 void write(uint8_t) override; 30 void write16(uint16_t) override; 31 void writeRepeat(uint16_t p, uint32_t len) override; 32 void writePixels(uint16_t *data, uint32_t len) override; 33 34 #if !defined(LITTLE_FOOT_PRINT) 35 void writeBytes(uint8_t *data, uint32_t len) override; 36 void writePattern(uint8_t *data, uint8_t len, uint32_t repeat) override; 37 #endif // !defined(LITTLE_FOOT_PRINT) 38 39 void pinMode(uint8_t pin, uint8_t mode); 40 void pinMode8(uint8_t port, uint8_t pin, uint8_t mode); 41 42 void digitalWrite(uint8_t pin, uint8_t val); 43 int digitalRead(uint8_t pin); 44 45 protected: 46 void writeRegister(uint8_t reg, uint8_t *data, uint8_t len); 47 uint8_t readRegister(uint8_t reg, uint8_t *data, uint8_t len); 48 49 uint8_t _address; 50 bool is_found; 51 52 int8_t _sda, _scl, _pwd, _cs, _sck, _mosi; 53 TwoWire *_wire; 54 55 private: 56 }; 57 58 #endif // _ARDUINO_XL9535SWSPI_H_