machine

🟠 means “not implemented yet”

class machine.Battery

Sensing battery power.

level()
Returns

the current battery level as a percentage

Camera() 🟠

Controlling feeds from the camera.

capture() 🟠

Sends the last captured image over Bluetooth

stream() 🟠

Starts streaming images over Bluetooth. Because Bluetooth is involved, this will have a low frame rate.

stop() 🟠

Stops any ongoing image stream or capture currently in progress

Display() 🟠

Drawing to the display.

show(framebuffer) 🟠

Pushes a framebuffer object to the FPGA for drawing onto the display

class machine.FPGA

Communication with the FPGA.

download() 🟠

Downloads and reboots the FPGA with the bitstream from Bluetooth. Automatically powers up the FPGA if it was powered down.

spi_read()

Not implemented, see spi_write() below.

spi_write(buf)
Parameters

buf (bytearray) – Buffer holding the data to write.

Writes all bytes from the bytearray buffer to the FPGA in a single SPI transaction (CS pin going down then up). The buffer is filled with the response data then returned. For instance, [0x80, 0x00, 0x00, 0x00, 0x00] would send a 0x80 query then read 4 more bytes. The same array, passed as argument would contain the response, such as [0x00, 0x12, 0x34, 0x56, 0x78].

status() 🟠
Returns

the current status of the FPGA

Microphone() 🟠

Controlling feeds fromthe microphone.

stream() 🟠

Starts streaming audio data over Bluetooth

stop() 🟠

Stops any ongoing audio stream

class machine.Power

Controlling general power state of the device.

hibernate(enable) 🟠

Enables or disables all the high power devices. Networking remains active. Upon re-enabling the FPGA will remain in reset until booted using FPGA.boot()

reset()

Resets the device

reset_cause()
Returns

the reason for the previous reset or startup state

shutdown(timeout) 🟠

Places the device into deep-sleep and powers down all high power devices. If a timeout is given, the device will wake up again after that many seconds, otherwise the device will only wake up upon inserting, and removing from the case. Upon wakeup, the device will reset, and the cause can be seen using the Power.reset_cause() function.

Timer(id, period, callback, oneshot) 🟠

Creates a new Timer object on timer id with the period in milliseconds and a given callback handler. The oneshot value can optionally be set to true if only a single trigger is required. By default the timer is repeating

value() 🟠
Returns

the current count value of the timer in milliseconds

deinit() 🟠

De-initializes the timer and stops any callbacks

class machine.Touch(callback)
Parameters

callback(event) (function) – The callback called upon a touch event, passed as argument.

Invoking Touch sets-up a function as callback, called upon any of those events:

TOUCH_TRIGGER_0_TAP
TOUCH_TRIGGER_1_TAP
TOUCH_TRIGGER_BOTH_TAP
TOUCH_TRIGGER_0_PRESS
TOUCH_TRIGGER_1_PRESS
TOUCH_TRIGGER_BOTH_PRESS
TOUCH_TRIGGER_0_LONG
TOUCH_TRIGGER_1_LONG
TOUCH_TRIGGER_BOTH_LONG
TOUCH_TRIGGER_0_1_SLIDE
TOUCH_TRIGGER_1_0_SLIDE
mac_address() 🟠
Returns

the 48bit MAC address of the device as a 17 character string. Each byte is delimited with a colon

machine.bootloader()

Reboot the monocle into bootloader mode.