emfcamp / badge-2024-software

27 stars 16 forks source link

Hardware APIs #32

Open hughrawlinson opened 2 weeks ago

hughrawlinson commented 2 weeks ago

I'm not sure which hardware is on the device beyond the accelerometer, but we should decide how we want app writers to interface with it - I know it's fairly well documented for hexpansions, but onboard hardware would be good.

If I understand correctly we have a couple of options:

1) The hardware is already connected over the i2c mux. We document how to use the i2c mux and which devices are at which addresses, and leave app authors to it 2) We write little driver apps to talk to the hardware over i2c and translate messages into an event bus based interface. We then document these interfaces, and in the hexpansion guide, for hexpansion devs who are attaching i2c hardware, we tell them to provide similar event bus based interfaces to the hardware 3) We have micropython classes/objects that we provide in a library to app authors, that under the hood speak either i2c or over the event bus to the hardware. We encourage hexpansion authors to provide these classes for app authors to copy paste into their apps?

If someone could add a list of all the hardware, that would be cool

ChrisDick commented 2 weeks ago

The power module has the following API covering the PMIC and USB C ports: import power BatteryChargeState() battery charge status - "Not Charging", "Pre-Charging", "Fast Charging", "Terminated" BatteryLevel() charge state estimate (%.) Fault() Battery, charge and boost fault states. Icharge() Battery charge current (A.) Off() Turn the badge off, if plugged into USB, badge will turn off when disconnected. SupplyCapabilities reports the capabilities of the power supply attached. Vbat() Battery voltage (V.) Vin() Input voltage (V.) Vsys() system voltage (V.) Enable5V(enable) turn the 5V usb out supply on or off.

The IMU we haven't looked at as we changed it last minute and no one has one to test. likely follow the fl0w3r.

The port expanders will be part of the hexpansion and top board APIs

There is no direct access to the i2c mux, the fusb of the top board channel of the mux or the system channel.

ChrisDick commented 2 weeks ago

for reference the Flow3r IMU API is acc_read() x, y, z readings gyro_read x, y, z readings pressure_read() pressure and temperature readings

Molive-0 commented 6 days ago

If it is possible, having the pedometer interface would be something I am interested in.