def measure(config): mcu = ArduinoTree() # mcu.soft_reset() vcc = mcu.vcc.read() timer = Stopwatch() measurements = [] # for _ in range(config.repeat): while 1: f = mcu.counter.read(config.gate_time) measurements.append(dict( t=timer.read(), frequency=nominal_value(f), )) if timer.last > config.interval: break data = dict( vcc=vcc, model=avr_name(mcu), measurements=measurements, gate_time=config.gate_time, ) return data
def measure(config, stop_condition=None): mcu = ArduinoTree() # if config.reset: # mcu.soft_reset() vcc = mcu.vcc.read() pin = mcu.pin.get(config.pin) interval = config.interval measurements = [] timer = Stopwatch() while 1: measurements.append(dict( t=timer.read(), A=pin.read_analog_value(), )) if timer.last > interval: break if stop_condition: if stop_condition(timer): break data = dict( vcc=vcc, model=avr_name(mcu), measurements=measurements, ) return data
def measure(config): random.seed() mcu = ArduinoTree() vcc = mcu.vcc.read() p_in = mcu.pin.get(config.pin_in) timer = Stopwatch(config.count) measurements = [] for i in range(config.count): measurements.append(dict( t=timer.read(), Ain=p_in.read_analog_value(), )) time.sleep(random.random() * config.max_sleep) timer.next(measurements) data = dict( vcc=vcc, model=avr_name(mcu), measurements=measurements, ) return data