Description
I am in the stage where i am satisfied with the layout of the GUI. The next step is to make it function with GRBL. GRBL is a firmware for CNC machines for those not familiar with it. Currently, we tether cnc machines to the PC to send commands to the cnc machine
I made a GUI for ESP32 that can be loaded with GRBL. The buttons I layed out thru littlevgl will be calling macro like text commands sent to the serial port of the microcontroller. I have tried with success sending texts made from the custom keyboard to the serial monitor so I believe the remaining buttons will just be easy.
The main loop of GRBL has about ten function calls plus lv_task_handler(). One of the functions called finally by GRBL is protocol_main_loop(). This GRBL function freezes the UI.
Based on the comment on the function it is an idle function which waits for the users input with the following loop condition:
for (;;) {
}
What MCU/Processor/Board and compiler are you using?
ESP32
What do you want to achieve?
Make protocol_main_loop work without freezing the microcontroller.
What have you tried so far?
- I tried removing the for loop block which causes the GUI to freeze. I think having a GUI serves that purposed. Clicking buttons and sending commands thru the GUI is doing the same as waiting for the user input. But doing this makes the microcontroller make an endless loop of sending the welcome message at start up.
- Reading up on littlevgl’s task handler to make the calls on the ‘for’ loop work not freeze the GUI.
- tried running protocol_main_loop on core 0 of ESP. This blanks the screen display.
Code to reproduce
main program loop:
void loop() {
mainGRBL();
lv_task_handler();
delay(5);
}
mainGRBL();
/ Reset Grbl primary systems.
serial_reset_read_buffer(CLIENT_ALL); // Clear serial read buffer
gc_init(); // Set g-code parser to default state
spindle_init();
// coolant_init();
limits_init();
probe_init();
plan_reset(); // Clear block buffer and planner variables
st_reset(); // Clear stepper subsystem variables
// Sync cleared gcode and planner positions to current system position.
plan_sync_position();
gc_sync_position();
// put your main code here, to run repeatedly:
report_init_message(CLIENT_ALL);
// Start Grbl main loop. Processes program inputs and executes them.
protocol_main_loop();
mainGRBL() calls a series of functions the last of which calls protocol_main_loop(). protocol_main_loop() freezes the GUI. As mentioned above it uses a ( ; ; ) condition that makes it loop forever.
Please advice what i can do. Thanks.
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.