Fix and improve G-code queue (#21122)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
X-Ryl669
2021-02-26 23:54:46 +01:00
committed by GitHub
parent ccf990a0d7
commit ec42be346d
20 changed files with 498 additions and 308 deletions

View File

@ -162,7 +162,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) {
draw_return_ui();
break;
case GCodeCommand:
if (queue.length <= (BUFSIZE - 3)) {
if (!queue.ring_buffer.full(3)) {
// Hook anything that goes to the serial port
MYSERIAL0.setHook(lv_serial_capt_hook, lv_eom_hook, 0);
queue.enqueue_one_now(ret_ta_txt);

View File

@ -46,7 +46,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_M_POINT1 ... ID_M_POINT5:
if (queue.length == 0) {
if (queue.ring_buffer.empty()) {
if (uiCfg.leveling_first_time) {
uiCfg.leveling_first_time = false;
queue.inject_P(G28_STR);

View File

@ -54,7 +54,7 @@ enum {
static void event_handler(lv_obj_t *obj, lv_event_t event) {
char str_1[16];
if (event != LV_EVENT_RELEASED) return;
if (queue.length <= (BUFSIZE - 3)) {
if (!queue.ring_buffer.full(3)) {
bool do_inject = true;
float dist = uiCfg.move_dist;
switch (obj->mks_obj_id) {

View File

@ -1613,7 +1613,7 @@ void wifi_rcv_handle() {
if (wifiTransError.flag != 0x1) WIFI_IO1_RESET();
getDataF = 1;
}
if (need_ok_later && (queue.length < BUFSIZE)) {
if (need_ok_later && !queue.ring_buffer.full()) {
need_ok_later = false;
send_to_wifi((uint8_t *)"ok\r\n", strlen("ok\r\n"));
}
@ -1772,7 +1772,7 @@ void get_wifi_commands() {
static int wifi_read_count = 0;
if (espGcodeFifo.wait_tick > 5) {
while ((queue.length < BUFSIZE) && (espGcodeFifo.r != espGcodeFifo.w)) {
while (!queue.ring_buffer.full() && (espGcodeFifo.r != espGcodeFifo.w)) {
espGcodeFifo.wait_tick = 0;