codeair – CodeAIR hardware interface
Core low-level module for CodeAIR
The codeair module gives you direct access to all the hardware on the CodeAIR.
pixels =
NEOPixelsbuttons =
Buttonsleds =
LEDspower =
Powerspeaker =
Speakersdcard =
SDCardcamera =
espcamerarecorder =
FlightDataRecorderpipe =
EmbeddedDataPipe
- class codeair.codeair.Buttons[source]
Access to pushbutton switches BTN-0 and BTN-1.
- class codeair.codeair.LEDs(i2c)[source]
Access to the eight blue LEDs on the CodeAIR, plus the STAtus LED.
- get(num=None)[source]
Get the current brightness of an LED or all LEDs if None is specified.
- Returns:
brightness (0-255) of given LED num, OR tuple : eight numbers – one for each LED
- Return type:
number
- get_status()[source]
Get the current brightness of the status LED.
- Returns:
brightness (0-255) of the status LED
- Return type:
number
- class codeair.codeair.NEOPixels[source]
Access to the eight CodeAIR neopixels.
(TOP_FRONT_RIGHT, TOP_FRONT_LEFT, TOP_REAR_RIGHT, TOP_REAR_LEFT, BOTTOM_FRONT_RIGHT, BOTTOM_FRONT_LEFT, BOTTOM_REAR_RIGHT, BOTTOM_REAR_LEFT)
- fill(value, brightness=10)[source]
Set all NeoPixels to a single color.
- Parameters:
value (tuple) – A tuple of three values for RGB like (10,88,102)
- get(num=None)[source]
Get current RGB value of Codex NeoPixels. This will be the value after brightness was applied.
- Parameters:
num (int/None) – A number from 0 - 7 will return a single value, None will return tuple of all 8 values.
- Returns:
value (tuple/tuple of 8 tuples)
- class codeair.codeair.Power[source]
Access to the CodeAIR power monitoring.
- battery_voltage(sample_count=2000, battery_minimum=3.0)[source]
Measure the battery voltage.
A sample_count of 1 seems sufficient when a battery is connected, but when a battery is not connected, the computer sees a voltage that is output periodically by the battery CHARGER. 2000 or more samples are necessary to filter out these readings.
battery_minimum parameter allows observing effects of the battery charger with no battery connected.
Typical use case:
volts = power.battery_voltage() # slow but accurate
If you know for sure a battery is connected:
volts = power.battery_voltage(1) # faster but can be "tricked" by the voltage put out by the battery charger
If you want to see the real-world effects of the battery charger “probing” to see if a battery has been connected:
volts = power.battery_voltage(1, 0.0)
- class codeair.codeair.SDCard(baudrate=25000000)[source]
Access the SD Card - Flight Data Recorder. This provides a filesystem on ‘/sd’ for Python (no USB direct MSC access). When the SD card is removed/reinserted you’ll need to call ‘mount()’ again.
- class codeair.codeair.Speaker[source]
Access to the CodeAIR speaker.
- beep(frequency=440, duration=250, duty_cycle=32767)[source]
Output a beep (possibly continuous)
- Parameters:
frequency (int) – xxx or higher. The default value of 440 corresponds to a musical note “A4”
duration (int) – Must be >= 0, with 0 being a special case used for starting a beep and leaving it running When not equal to 0, duration indicates the number of milliseconds to play the beep for.
duty_cycle (16-bit int) – can be used to vary the width of the pulses sent to the speaker, which will have some effect on the sound characteristics and volume (you can hear the sound get “thinner” as you move off the center point, which is 32767)
- Returns:
None