API Reference
adafruit_xteink_x4
CircuitPython helper library to interface with the Xteink X4 eReader
Author(s): Liz Clark
Implementation Notes
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Based on the OpenX4 E-Paper Community SDK: https://github.com/open-x4-epaper/community-sdk
- class adafruit_xteink_x4.BatteryMonitor(adc_pin=None, divider_multiplier=2.0)
Monitor battery voltage and percentage via an ADC pin with a voltage divider.
- Parameters:
- deinit()
Release the underlying ADC resource.
- property millivolts
Battery voltage in millivolts, accounting for the voltage divider.
- property percentage
Estimated battery percentage (0-100) using a cubic fit curve for a typical Li-Ion discharge profile.
- property volts
Battery voltage in volts.
- class adafruit_xteink_x4.InputManager(adc_pin_1=None, adc_pin_2=None, power_pin=None, debounce=0.05)
Manage button input from two ADC channels and a digital power button.
Buttons are read from two ADC pins using resistor-ladder thresholds and a dedicated digital pin for the power button. Call
update()once per main-loop iteration to poll and debounce.- Parameters:
adc_pin_1 (Pin) – First ADC pin (Back, Confirm, Left, Right). Defaults to
board.BUTTON_ADC_1.adc_pin_2 (Pin) – Second ADC pin (Up, Down). Defaults to
board.BUTTON_ADC_2.power_pin (Pin) – Digital pin for the power button (active-low). Defaults to
board.BUTTON.debounce (float) – Debounce delay in seconds. Defaults to
0.05(50 ms).
- property any_pressed
Trueif any button was just pressed this update cycle.
- property any_released
Trueif any button was just released this update cycle.
- property back_pressed
Trueif the Back button is currently held.
- static button_name(button_index)
Return a human-readable name for a button index.
- Parameters:
button_index (int) – A button index constant.
- property confirm_pressed
Trueif the Confirm button is currently held.
- property current_state
Bitmask of currently held buttons (after debounce).
- deinit()
Release all underlying pin resources.
- property down_pressed
Trueif the Down button is currently held.
- property held_time
Duration in seconds a button has been or was held.
- is_pressed(button_index)
Return
Trueif the given button is currently held.- Parameters:
button_index (int) – A button index constant (e.g.
BTN_BACK).
- property left_pressed
Trueif the Left button is currently held.
- property power_button_pressed
Trueif the power button is currently held.
- property right_pressed
Trueif the Right button is currently held.
- property up_pressed
Trueif the Up button is currently held.
- update()
Poll buttons, debounce, and compute pressed/released events.
Call this once per main-loop iteration.