-
-
Notifications
You must be signed in to change notification settings - Fork 80
Enable SPIKE Prime UI on EV3 to unblock progress on USB download and run #357
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
Conversation
The button HMI can still run. We just don't have to monitor the Bluetooth button.
This shouldn't call directly to the driver, but should use the system level pixel setter as it does everywhere else in this module.
A REPL is only useful while connected, so this option is only useful for work-in-progress builds like EV3 or NXT, so the REPL can be started from the UI even when there isn't any other communication protocol set up yet.
On platforms where the image module is disabled, we still need the image type for the static inline pbdrv_display_get_image.
This is not restricted to LED arrays.
This enables the SPIKE Prime UI on EV3 by mimicking a 5x5 grid display. This unblocks the path to implementing USB download and run on EV3 without having to decide or spend time on the UI yet. For now, attempting to run slot 0 will always start the UART REPL so that other developments can still be worked on in the mean time.
|
This is ready for use, but I suppose I need to check NXT builds now that we are working on that one too. |
|
WOW |
😄 I'm about to go into a meeting, but if you want to test that the NXT REPL still starts then we can merge it right after 😉 |
|
Great! UI on EV3! NXT goes nice into the REPL. USB of EV3 is not recognized on linux and not on windows. [EDIT] |
|
Thanks for testing. Yep, NXT just remains unchanged for now. It can get the same basic UI if we write a display driver though.
Yep. Got to have something working for now. Just one extra button press to get in. |
|
Thanks Laurens, The REPL in git hash 7c11ba2 is flaky. Hangs after a few lines. |
|
This has been the case for a while, prior to this change. It appears that the UART operation hangs sometimes. When this happened, USB was still available and happily going. (But the USB REPL has since been removed, so this is harder to verify.) |
|
It's possible that the run animation makes it worse. This is a good thing since it makes it more reproducible. 😄 |
It is harder to do anything on the REPL. |
I made some hacks that seem to improve things a bit. diff --git a/lib/pbio/drv/uart/uart_debug_first_port.c b/lib/pbio/drv/uart/uart_debug_first_port.c
index 8fe6e774a..85a21fced 100644
--- a/lib/pbio/drv/uart/uart_debug_first_port.c
+++ b/lib/pbio/drv/uart/uart_debug_first_port.c
@@ -13,13 +13,12 @@
#include <stdarg.h>
#include <string.h>
-#define BUF_SIZE (256)
-static uint8_t ring_buf[BUF_SIZE];
-static size_t ring_head = 0;
-static size_t ring_tail = 0;
+static uint8_t ring_buf[256 * 1024];
+static size_t ring_head;
+static size_t ring_tail;
-static pbdrv_uart_dev_t *debug_uart = NULL;
+static pbdrv_uart_dev_t *debug_uart;
/**
* Formats and stores a string in the UART debug ring buffer.
@@ -33,16 +32,16 @@ static pbdrv_uart_dev_t *debug_uart = NULL;
*/
void pbdrv_uart_debug_printf(const char *format, ...) {
- char buf[BUF_SIZE];
+ char buf[64];
va_list args;
va_start(args, format);
- vsnprintf(buf, sizeof(ring_buf), format, args);
+ vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
size_t len = strlen(buf);
for (size_t i = 0; i < len; i++) {
ring_buf[ring_head] = buf[i];
- ring_head = (ring_head + 1) % BUF_SIZE;
+ ring_head = (ring_head + 1) % sizeof(ring_buf);
}
if (!debug_uart) {
@@ -86,10 +85,13 @@ static pbio_error_t pbdrv_uart_debug_process_thread(pbio_os_state_t *state, void
PBIO_OS_AWAIT_UNTIL(state, ring_head != ring_tail);
// Write up to the end of the buffer without wrapping.
- size_t end = ring_head > ring_tail ? ring_head: BUF_SIZE;
+ size_t end = ring_head > ring_tail ? ring_head : sizeof(ring_buf);
write_size = end - ring_tail;
+ if (write_size > 32) {
+ write_size = 32;
+ }
PBIO_OS_AWAIT(state, &child, pbdrv_uart_write(&child, debug_uart, &ring_buf[ring_tail], write_size, 100));
- ring_tail = (ring_tail + write_size) % BUF_SIZE;
+ ring_tail = (ring_tail + write_size) % sizeof(ring_buf);
// Reset on failure.
if (err != PBIO_SUCCESS) {
diff --git a/lib/pbio/drv/uart/uart_ev3.c b/lib/pbio/drv/uart/uart_ev3.c
index 86d4a7f75..0fa350ed5 100644
--- a/lib/pbio/drv/uart/uart_ev3.c
+++ b/lib/pbio/drv/uart/uart_ev3.c
@@ -61,7 +61,7 @@ struct _pbdrv_uart_dev_t {
/** The current position in read_buf. */
uint8_t read_pos;
/** The buffer passed to the write function. */
- uint8_t *write_buf;
+ uint8_t * volatile write_buf;
/** The length of write_buf in bytes. */
uint8_t write_length;
/** The current position in write_buf. */I made the But the key thing I changed that actually seemed to help is only writing a smallish number of bytes at a time to |
This enables the SPIKE Prime UI on EV3. We can design a more elaborate UI later.
This is meant to unblock progress on USB program download and run. All facets of downloading, running, and stopping programs become testable this way. Graceful shutdown can be tested by pressing and holding the center button. And by making it similar to SPIKE Prime, less cross platform testing is required.
There is more to be done here, like properly clearing the screen between program runs, but that isn't the priority right now.
A build flag ensures that attempting to start slot 0 on EV3 will always start the REPL so we have a way to keep testing until USB support is complete.
So to test download and run, use the left/right buttons to pick any other slot.
ui.mp4