feat: move odfu example from note-outboard-dfu and update readmes#177
feat: move odfu example from note-outboard-dfu and update readmes#177rdlauer wants to merge 3 commits into
Conversation
|
Let's use the Fluent API which covers all four requests used here ( Suggested rewrite of import time
import board
import digitalio
import notecard
from notecard import card, dfu, hub
# The unique Product Identifier for your device. Claim one in a Notehub project.
productUID = "com.your-company.your-project"
# The firmware version reported to Notehub via dfu.status. Bump this (and change
# BLINK_DELAY) when you build a new image to update to.
FIRMWARE_VERSION = "1.0.0"
# Seconds the LED stays on/off. Change this to make the update visually obvious.
BLINK_DELAY = 0.5
def configure_outboard_dfu(nCard):
"""Put the Notecard online and enable Outboard Firmware Update for the host.
Outboard Firmware Update requires the Notecard to be in "continuous" or
"periodic" mode. On a Notecarrier F the DFU signals are routed over the
Notecard's shared AUX pins, so card.dfu uses mode "aux" and card.aux is set
to "off" to free those pins for DFU.
"""
hub.set(nCard, product=productUID, mode="continuous", sn="circuitpython-notecard")
# Enable Outboard Firmware Update and tell the Notecard the host MCU type.
card.dfu(nCard, name="stm32", on=True, mode="aux")
# Free the AUX pins so they can be used for Outboard Firmware Update.
card.aux(nCard, mode="off")
# Enable host DFU and report the running firmware version to Notehub.
dfu.status(nCard, on=True, version=FIRMWARE_VERSION)
def main():
"""Enable Outboard DFU, then blink the built-in LED as the update payload."""
i2c = board.I2C()
nCard = notecard.OpenI2C(i2c, 0, 0, debug=True)
configure_outboard_dfu(nCard)
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
print("Running firmware version {}. Hit CTRL-C to stop.".format(FIRMWARE_VERSION))
while True:
led.value = True
time.sleep(BLINK_DELAY)
led.value = False
time.sleep(BLINK_DELAY)
main()Note the parameter/variable rename from |
Bucknalla
left a comment
There was a problem hiding this comment.
See comment re-changing to Fluent API
|
@Bucknalla I missed your complete code sample but Claude added the fluent API usage for me. Also while in here I updated the github actions to the latest versions to avoid the Node 20 deprecation warnings. Ready for a review. |
Migrating ODFU example from note-outboard-dfu repo