In some rare cases, you might need to prevent the terminal from exiting GUI mode. However, this should be done carefully and only when absolutely necessary.
The most common scenario for this is when the terminal interface is not needed at all**βfor example, in a **video game, where the user should remain in the GUI environment without returning to the terminal.
To achieve this, simply assign an "end callback" to the screen object. Inside this callback, use the swapScreen
or beginScreen
methods to reinitialize the screen object.
Live Demo
Whole Code
bool trigger = false;
void setup(){
Serial.begin(115200);
shell.clear();
Serial.println( "Program Start!" );
grid.addWidget( &button_1, 0, 0 );
grid.addWidget( &button_2, 0, 1 );
grid.addWidget( &button_3, 1, 0 );
grid.addWidget( &button_4, 1, 1 );
button_1_event.
data = (uint8_t)
'a';
button_2_event.
data = (uint8_t)
'b';
button_3_event.
data = (uint8_t)
'c';
button_4_event.
data = (uint8_t)
'd';
button_1.attachEvent( button_1_event );
button_2.attachEvent( button_2_event );
button_3.attachEvent( button_3_event );
button_4.attachEvent( button_4_event );
button_1.attachTriggerFunction( button_click );
button_2.attachTriggerFunction( button_click );
button_3.attachTriggerFunction( button_click );
button_4.attachTriggerFunction( button_click );
grid.attachEndFunction( endCallback );
shell.begin( "arnold" );
shell.beginScreen( &grid );
}
void loop(){
shell.update();
}
parent = screen -> getParent();
if( parent == NULL ){
return;
}
trigger = !trigger;
if( trigger ){
}
else{
}
button_1.setColor( color );
button_2.setColor( color );
button_3.setColor( color );
button_4.setColor( color );
parent -> requestRedraw();
}
if( parent == NULL ){
return;
}
parent -> swapScreen( &grid );
}
@ SHELL_EVENT_KEY
To identify simple key events like: A, b...
textColor_t
VT100 color codes.
@ YELLOW
Yellow text color.
This is an abstract object for graphics element creation.
shellEventType_t type
Identifies the type of the event.
uint8_t data
In case of SHELL_EVENT_KEY type, stores the corresponding character to the pressed key.