Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/upload_file.py: implement getline() #271

Merged
merged 2 commits into from
Oct 20, 2023
Merged

Conversation

josuah
Copy link
Member

@josuah josuah commented Oct 12, 2023

This should make the I/O handling a lot easier, allowing to read data back from the Monocle.

This turns the data from Bluetooth, segmented into packets received asynchronously (low-level interface) into a stream that can be read using getline() (with a custom delimiter possible).

This makes it a lot more convenient to build scripts for the Monocle.
This could be turned into a Monocle library that connects to a Monocle:

monocle = Monocle(mac="monocle_mac_address_here")
monocle.send_command("print('abcd')")
assert monocle.getline(delim="\r\n\x04") == "abcd"

@josuah
Copy link
Member Author

josuah commented Oct 12, 2023

The current implementation does not go that far though. A bit of polishing, but the mechanism is there.

@josuah
Copy link
Member Author

josuah commented Oct 12, 2023

The output is also a bit more pleasant now:

$ python ../tools/upload_file.py color.py
uuids=['6e400001-b5a3-f393-e0a9-e50e24dcca9e']
Connected to the Monocle
>>> opening a file to write to
>>> writing the data to the file
.........................
>>> closing the file
>>> script done

Device was disconnected.
$

@josuah
Copy link
Member Author

josuah commented Oct 12, 2023

The usability and output got improved even a bit more:

$ python3 ../tools/upload_file.py *.py
uploading color.py ......................... done
uploading display.py .................... done
uploading font.py ........................................... done
uploading glyph.py ............................. done
uploading sprite.py .................................... done
uploading text.py .................................. done
uploading vector.py ................................................. done
$

@josuah josuah force-pushed the upload_file_getline branch from 23febdb to 84af52d Compare October 12, 2023 15:18
@siliconwitch siliconwitch merged commit 4091ae6 into main Oct 20, 2023
1 check passed
@siliconwitch siliconwitch deleted the upload_file_getline branch October 20, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants