def send_frame(self, c): bytestring = ''.join(c.bytestream) # Initialize the buffer once (after we have the first set of image data) if ( not self.databuffer or not self.spitransfer): self.transfer, self.databuffer, _ = spi_transfer(bytestring, readlen=0, speedhz=SPEED) self.databuffer = bytestring self.dev.do_transfers([self.transfer])
def send_frame(self, c): bytestring = ''.join(c.bytestream) # Initialize the buffer once (after we have the first set of image data) if (not self.databuffer or not self.spitransfer): self.transfer, self.databuffer, _ = spi_transfer(bytestring, readlen=0, speedhz=SPEED) self.databuffer = bytestring self.dev.do_transfers([self.transfer])
def writeDac(device,chan,val): v1 = 0x30 | (chan<<7) | (val>>4); v2 = ((val & 0xF) << 4); data = "%0.2X" % v1 + "%0.2X" % v2 #transfers data string transfer, buf, _ = spi_transfer(bytes.fromhex(data), readlen=0) b=device.do_transfers(transfer) return b;
def readAdc(device,chan): #This is my data that I want sent through my SPI bus v1 = 0xD0 | (chan<<5) ; v2 = 0; data = "%0.2X" % v1 + "%0.2X" % v2 #transfers data string transfer, buf, _ = spi_transfer(bytes.fromhex(data), readlen=2) b=device.do_transfers(transfer) # decode value answer=list(transfer) value= ( (answer[0]*128) | (answer[1]>>1) ) value= value & 0x3ff return value;