flipperzero_adc_test.py 484 B

1234567891011121314151617181920
  1. import flipperzero as f0
  2. import time
  3. f0.gpio_init_pin(f0.GPIO_PIN_PC1, f0.GPIO_MODE_ANALOG)
  4. for _ in range(1, 1000):
  5. raw_value = f0.adc_read_pin_value(f0.GPIO_PIN_PC1)
  6. raw_voltage = f0.adc_read_pin_voltage(f0.GPIO_PIN_PC1)
  7. value = "{value} #".format(value=raw_value)
  8. voltage = "{value} mV".format(value=raw_voltage)
  9. f0.canvas_clear()
  10. f0.canvas_set_text(10, 32, value)
  11. f0.canvas_set_text(70, 32, voltage)
  12. f0.canvas_update()
  13. time.sleep_ms(10)