diff --git a/include/pros/misc.h b/include/pros/misc.h index 6bbbbafb0..843ffc7d3 100644 --- a/include/pros/misc.h +++ b/include/pros/misc.h @@ -337,7 +337,8 @@ int32_t controller_clear_line(controller_id_e_t id, uint8_t line); * Clears all of the lines on the controller screen. * * \note Controller text setting is currently in beta, so continuous, fast - * updates will not work well. + * updates will not work well. On vexOS version 1.0.0 this function will block + * for 110ms. * * This function uses the following values of errno when an error state is * reached: diff --git a/include/pros/misc.hpp b/include/pros/misc.hpp index f1e823c76..3135aac25 100644 --- a/include/pros/misc.hpp +++ b/include/pros/misc.hpp @@ -241,7 +241,8 @@ class Controller { * Clears all of the lines on the controller screen. * * \note Controller text setting is currently in beta, so continuous, fast - * updates will not work well. + * updates will not work well. On vexOS version 1.0.0 this function will + * block for 110ms. * * This function uses the following values of errno when an error state is * reached: diff --git a/src/devices/controller.c b/src/devices/controller.c index 8696e330e..b5bd0759e 100644 --- a/src/devices/controller.c +++ b/src/devices/controller.c @@ -206,9 +206,14 @@ int32_t controller_set_text(controller_id_e_t id, uint8_t line, uint8_t col, con char* buf = strndup(str, CONTROLLER_MAX_COLS + 1); - vexControllerTextSet(id, line, col, buf); + uint32_t rtn_val = vexControllerTextSet(id, line, col, buf); free(buf); internal_port_mutex_give(port); + + if (!rtn_val) { + errno = EAGAIN; + return PROS_ERR; + } return 1; } @@ -240,11 +245,16 @@ int32_t controller_print(controller_id_e_t id, uint8_t line, uint8_t col, const char* buf = (char*)malloc(CONTROLLER_MAX_COLS + 1); vsnprintf(buf, CONTROLLER_MAX_COLS + 1, fmt, args); - vexControllerTextSet(id, line, col, buf); + uint32_t rtn_val = vexControllerTextSet(id, line, col, buf); free(buf); va_end(args); internal_port_mutex_give(port); + + if (!rtn_val) { + errno = EAGAIN; + return PROS_ERR; + } return 1; } @@ -268,14 +278,27 @@ int32_t controller_clear_line(controller_id_e_t id, uint8_t line) { line++; const char* const blank = " "; - vexControllerTextSet(port, line, 0, blank); + uint32_t rtn_val = vexControllerTextSet(port, line, 0, blank); internal_port_mutex_give(port); + + if (!rtn_val) { + errno = EAGAIN; + return PROS_ERR; + } return 1; } int32_t controller_clear(controller_id_e_t id) { - for (int i = 0; i < 3; i++) controller_clear_line(id, i); - return 1; + if (vexSystemVersion() > 0x01000000) { + return controller_print(id, 0, 0, ""); + } else { + for (int i = 0; i < 3; i++) { + int32_t rtn = controller_clear_line(id, i); + if (rtn == PROS_ERR) return PROS_ERR; + if (i != 2) delay(55); + } + return 1; + } } int32_t controller_rumble(controller_id_e_t id, const char* rumble_pattern) {