def command_reset(): """ RESET (0000 011x) Resets the device to the default values. Wait at least (50us + 32 · t(CLK)) after the RESET command is sent before sending any other command. """ spi.write([0x06])
def command_power_down(): """ POWERDOWN (0000 001x) The POWERDOWN command places the device into power-down mode. This command shuts down all internal analog components, opens the low-side switch, turns off both IDACs, but holds all register values. In case the POWERDOWN command is issued while a conversion is ongoing, the conversion completes before the ADS1220 enters power-down mode. As soon as a START/SYNC command is issued, all analog components return to their previous states. """ spi.write([0x02])
def display(self): """Write display buffer to physical display.""" self.command(SSD1306_COLUMNADDR) self.command(0) # Column start address. (0 = reset) self.command(self.width - 1) # Column end address. self.command(SSD1306_PAGEADDR) self.command(0) # Page start address. (0 = reset) self.command(self._pages - 1) # Page end address. # Write buffer data. # Set DC high for data. GPIO.output(DC_SEL, 1) # Write buffer. #print self._buffer spi.write(self._buffer)
def command_start(self): """ START/SYNC (0000 100x) In single-shot mode, the START/SYNC command is used to start a single conversion, or (when sent during an ongoing conversion) to reset the digital filter, and then restarts a single new conversion. When the device is set to continuous conversion mode, the START/SYNC command must be issued one time to start converting continuously. Sending the START/SYNC command while converting in continuous conversion mode resets the digital filter and restarts continuous conversions. """ # Make sure that PGA is disabled if AINn = AVSS if 0x07 < self.__mux < 0x0c: if not self.__pga_bypass: raise ValueError("When AINn = AVSS internal low-noise PGA must be disabled!") if self.__gain > 0x02: raise ValueError("When AINn = AVSS only gain 1, 2 and 4 can be used") spi.write([0x08])
def command_start(self): """ START/SYNC (0000 100x) In single-shot mode, the START/SYNC command is used to start a single conversion, or (when sent during an ongoing conversion) to reset the digital filter, and then restarts a single new conversion. When the device is set to continuous conversion mode, the START/SYNC command must be issued one time to start converting continuously. Sending the START/SYNC command while converting in continuous conversion mode resets the digital filter and restarts continuous conversions. """ # Make sure that PGA is disabled if AINn = AVSS if 0x07 < self.__mux < 0x0c: if not self.__pga_bypass: raise ValueError( "When AINn = AVSS internal low-noise PGA must be disabled!" ) if self.__gain > 0x02: raise ValueError( "When AINn = AVSS only gain 1, 2 and 4 can be used") spi.write([0x08])
def write_register(register, data): spi.write([0x40 | (register & 0x03) << 2, data])
def command(self, c): """Send command byte to display.""" GPIO.output(DC_SEL, 0) spi.write([c])
def data(self, c): """Send byte of data to display.""" GPIO.output(self.DC_SEL, 1) spi.write([c])