Ejemplo n.º 1
0
 def getProximity(self):
     write(self.bus, 0x80, 0x08)
     while (not (read(self.bus, 0x80) & 0x20)):
         pass
     h = read(self.bus, 0x87)
     d = h << 8 | read(self.bus, 0x88)
     return d
Ejemplo n.º 2
0
 def setInterrupt(self, state=0):
     if (state):
         write(self.bus, 0x80, 0x03)
         write(self.bus, 0x89, 0x02)
     else:
         write(self.bus, 0x80, 0x00)
         write(self.bus, 0x89, 0)
Ejemplo n.º 3
0
 def setHighThreshold(self, t):
     highBits = (0xFF00 & t) >> 8
     lowBits = (0x00FF & t)
     write(self.bus, 0x8C, highBits)
     write(self.bus, 0x8D, lowBits)
Ejemplo n.º 4
0
 def setLowThreshold(self, t):
     highBits = (0xFF00 & t) >> 8
     lowBits = (0x00FF & t)
     write(self.bus, 0x8A, highBits)
     write(self.bus, 0x8B, lowBits)
Ejemplo n.º 5
0
 def resetInterrupt(self):
     write(self.bus, 0x8E, 0x01)
Ejemplo n.º 6
0
 def setLedLevel(self, lvl: int):
     if (lvl >= 0 and lvl <= 20):
         write(self.bus, 0x83, lvl)