From 261aa66311813e3a038c8bbd2d3ce0ce1db34f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Thu, 4 Jan 2018 13:46:44 +0100 Subject: [PATCH] updated i2c frame structure --- gex/units/I2C.py | 2 +- main.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gex/units/I2C.py b/gex/units/I2C.py index 8bd77d2..c192c50 100644 --- a/gex/units/I2C.py +++ b/gex/units/I2C.py @@ -42,7 +42,7 @@ class I2C(gex.Unit): """ pb = self._begin_i2c_pld(address, a10bit) pb.u8(reg) - pb.u8(width*count) # we assume the device will auto-increment (most do) + pb.u16(width*count) # we assume the device will auto-increment (most do) resp = self.query(0x03, pb.close()) fields = [] diff --git a/main.py b/main.py index f7d6a4b..ed2dcb1 100644 --- a/main.py +++ b/main.py @@ -61,18 +61,18 @@ if False: for i in range(0,512): j = i if i < 256 else 255-(i-256) neo.load([0x660000+j, 0x3300FF-j, 0xFFFF00-(j<<8), 0x0000FF+(j<<8)-j]) - time.sleep(.001) + time.sleep(.002) neo.load([0,0,0,0]) +if False: + i2c = gex.I2C(client, 'i2c') -i2c = gex.I2C(client, 'i2c') - -# i2c.write(0x76, payload=[0xD0]) -# print(i2c.read(0x76, count=1)) + # i2c.write(0x76, payload=[0xD0]) + # print(i2c.read(0x76, count=1)) -print(i2c.read_reg(0x76, 0xD0)) -print("%x" % i2c.read_reg(0x76, 0xF9, width=3, endian='big')) + print(i2c.read_reg(0x76, 0xD0)) + print("%x" % i2c.read_reg(0x76, 0xF9, width=3, endian='big')) -i2c.write_reg(0x76, 0xF4, 0xFA) -print(i2c.read_reg(0x76, 0xF4)) + i2c.write_reg(0x76, 0xF4, 0xFA) + print(i2c.read_reg(0x76, 0xF4))