示例#1
0
    def test_adc_stop(self):
        SensorManager.mux_select(ADC)
        SensorManager.stop_adc_sensor(ADC)
        SensorManager.mux_select(ADC)
        SensorManager.init_adc(ADC)
        addr = SensorEntropy.addr(ADC)
        adc_reg = SensorEntropy.reg(ADC)
        bus = SensorManager.bus

        config = bus.read_byte_data(addr, adc_reg['CONFIG_REG'])
        self.assertEqual(config, 0x00)
示例#2
0
def main():
    SensorManager.gpio_output(PAYLOAD_EN_GPIO, ON)
    SensorManager.init_adc(ADC)
    start_time = time.time()
    try:
        while True:
            strain, force, adc_temp = SensorManager.read_adc(0, ADC)
            elapsed = time.time() - start_time
            print("[" + str(round(elapsed, 3)) + " s] ")
            print(strain, force, adc_temp)
            time.sleep(2)
    except KeyboardInterrupt:
        SensorManager.stop_adc_sensor(ADC)
        SensorManager.gpio_output(PAYLOAD_EN_GPIO, OFF)
示例#3
0
    def test_adc_init(self):
        SensorManager.mux_select(ADC)
        SensorManager.init_adc(ADC)
        addr = SensorEntropy.addr(ADC)
        adc_reg = SensorEntropy.reg(ADC)
        bus = SensorManager.bus

        config = bus.read_byte_data(addr, adc_reg['CONFIG_REG'])
        mode = bus.read_byte_data(addr, adc_reg['ADV_CONFIG_REG'])
        conv = bus.read_byte_data(addr, adc_reg['CONV_RATE_REG'])
        ch = bus.read_byte_data(addr, adc_reg['CHANNEL_DISABLE_REG'])
        limits = bus.read_byte_data(addr, adc_reg['LIMIT_REG_BASE'])

        self.assertEqual(config, 0x01)
        self.assertEqual(mode, 0x04)
        self.assertEqual(conv, 0x01)
        self.assertEqual(ch, 0x00)
        self.assertEqual(limits, 0x05)
示例#4
0
 def init_sensors(self):
     SensorManager.init_adc(ADC)
     SensorManager.init_temp_sensor(self.temp_sensor)