I have an accelerometer in my tablet, that I can read from within javascript.
How can I access this data in python? Is there some ctypes trickery I can use to call a windows 8 Sensor API function?
I know this is old but I just found out that you can use winsdk pip install winsdk
(community maintained version of winrt)
import time
import winsdk.windows.devices.sensors
import winsdk.windows.devices.sensors as sensors
accel = sensors.Accelerometer.get_default()
def reading_changed_handler(accel, args: winsdk.windows.devices.sensors.AccelerometerReadingChangedEventArgs):
reading = args.reading
print(reading.acceleration_x, reading.acceleration_y, reading.acceleration_z)
accel.add_reading_changed(reading_changed_handler)
while True:
time.sleep(1)