### Compile Examples for PC Platform Source: https://www.shellminator.org/html/md_extras__assets__docu_pages_developer_zone This command sequence first generates example code using 'exampleGenerator.py' and then runs the 'build.py' script with the 'clean examples' target to compile all examples for the PC platform. It also shows the path to a compiled executable. ```shell python exampleGenerator.py python build.py -t 'clean examples' .\build\001_basic.exe ``` -------------------------------- ### Build Web Examples (without cleaning) Source: https://www.shellminator.org/html/md_extras__assets__docu_pages_developer_zone This command demonstrates running the build script with the 'web' target, compiling web examples. It highlights that 'clean' is not needed for subsequent builds, improving efficiency. ```python python build.py -t 'web' ``` -------------------------------- ### Generate Example Code for Target Platform Source: https://www.shellminator.org/html/md_extras__assets__docu_pages_developer_zone This command executes the 'exampleGenerator.py' script, which is responsible for generating the source code for examples, preparing them for compilation on the target platform. ```python python exampleGenerator.py ``` -------------------------------- ### Build and Host Documentation Locally Source: https://www.shellminator.org/html/md_extras__assets__docu_pages_developer_zone This sequence outlines the process for generating and viewing the project's HTML documentation. It involves building web examples, then running a local server to host the generated documentation files. ```shell python build.py -t 'clean web' python ..\ShellminatorDocs\run_server.py ``` -------------------------------- ### Full Shellminator Neofetch Example (C++) Source: https://www.shellminator.org/html/120_neofetch_basic_page This is a complete example demonstrating the setup and usage of Shellminator's Neofetch feature. It includes initializing the serial communication, clearing the terminal, attaching the Neofetch callback, and starting the Shellminator object with a specified user. ```cpp /* * Created on June 8 2024 * * Copyright (c) 2023 - Daniel Hajnal * hajnal.daniel96@gmail.com * This file is part of the Shellminator project. * Modified 2023.05.13 */ #include "Shellminator.hpp" #include "Shellminator-Neofetch.hpp" // Create a Shellminator object, and initialize it to use Serial Shellminator shell( &Serial ); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); // Attach the default neofetch callback. shell.attachNeofetchFunc( defaultShellminatorNeofetch ); // Initialize shell object. shell.begin( "arnold" ); } // Infinite loop. void loop(){ // Process the new data. shell.update(); } ``` -------------------------------- ### Shellminator Core and Commander Interface (C++) Source: https://www.shellminator.org/html/205_commander_cowsay_page This snippet shows the core setup for the Shellminator project. It includes necessary headers, defines constants for ASCII art, initializes a Commander object, and sets up the system command tree. The `setup` function initializes the serial communication, clears the terminal, and attaches the commander interface, while the `loop` function continuously updates the shell. The `cowsay_func` implements the cowsay-like functionality. ```cpp #include "Shellminator.hpp" #include "Shellminator-Commander-Interface.hpp" #include "Commander-API.hpp" #include "Commander-Arguments.hpp" // Not an average looking cow for sure const char* cow_top = " \ ^__^\r\n \ "; const char* cow_bottom = "\\______\r\n (__)\ )\/\\ \n ||----w | \n || ||\r\n"; // Eye configurations const char* default_eyes = "(oo)"; const char* tired_eyes = "(--)"; const char* wink_eyes = "(-O)"; const char* greedy_eyes = "($$)"; // We have to create an object from Commander class. Commander commander; bool cowsay_func( char *args, CommandCaller* caller ); Commander::systemCommand_t API_tree[] = { systemCommand( "cowsay", "Like the Linux command. Just give it a string.\r\n\tflags: --greedy\r\n\t --tired", cowsay_func ) }; // Create a ShellminatorCommanderInterface object, and initialize it to use Serial ShellminatorCommanderInterface shell( &Serial ); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); commander.attachDebugChannel( &Serial ); commander.attachTree( API_tree ); commander.init(); shell.attachCommander( &commander ); // Initialize shell object. shell.begin( "arnold" ); } // Infinite loop. void loop(){ // Process the new data. shell.update(); } bool cowsay_func(char *args, CommandCaller* caller ){ char textBuffer[ 30 ]; int i; // The text argument is place dependent but optional. // It has to be the first argument when it is given. Argument text( args, 0 ); // These are the optional flags for the command. Argument tired_flag( args, 't', "tired" ); Argument wink_flag( args, 'w', "wink" ); Argument greedy_flag( args, 'g', "greedy" ); // Try to find if these flags can be found in the command. tired_flag.find(); wink_flag.find(); greedy_flag.find(); caller -> print( "< " ); // Draw the user text when it is given. if( text.parseString( textBuffer ) ){ caller -> print( textBuffer ); caller -> println( " >" ); caller -> print( ' ' ); for( i = strlen( textBuffer ) + 2; i > 0 ; i-- ){ caller -> print( '-' ); } } // Draw the default text. else{ caller -> print( "booo >\r\n ------" ); } caller -> println(); caller -> print( cow_top ); // The eye drawing has a priority in case multiple flags are given. // Check each flag from top priority and draw the corresponding eyes. if( tired_flag.isFound() ){ caller -> print( tired_eyes ); } else if( wink_flag.isFound() ){ caller -> print( wink_eyes ); } else if( greedy_flag.isFound() ){ caller -> print( greedy_eyes ); } // If no flags are given, draw dhe default eyes. else{ caller -> print( default_eyes ); } caller -> print( cow_bottom ); return true; } ``` -------------------------------- ### Full Shellminator Commander Interface Example Source: https://www.shellminator.org/html/208_commander_colorizer_page This is a complete example demonstrating the setup and main loop of a Shellminator Commander Interface. It includes attaching the commander, system variables, and the colorizer, as well as processing shell updates. ```C++ /* * Created on Aug 10 2020 * * Copyright (c) 2023 - Daniel Hajnal * hajnal.daniel96@gmail.com * This file is part of the Shellminator project. * Modified 2023.05.13 */ #include "Shellminator.hpp" #include "Shellminator-Commander-Interface.hpp" #include "Commander-API.hpp" #include "Commander-Arguments.hpp" // We have to create an object from Commander class. Commander commander; // Create a colorizer object. CommanderColorizer colorizer; bool echo_func( char *args, CommandCaller* caller ); Commander::systemCommand_t API_tree[] = { systemCommand( "echo", "Simple echo command.", echo_func ) }; // These will be the system variables. char* VERSION = (char*)"V1.0.2a"; // Simple firmware version string. int MILLIS = 0; // It will store the milliseconds since boot. float BATTERY = 100.0; // It will store the battery percentage. // Create system variable tree. Commander::systemVariable_t System_variables[] = { // MILLIS variable is an int. systemVariableInt( MILLIS ), // VERSION variable is a string systemVariableString( VERSION ), // BATTERY variable is a float systemVariableFloat( BATTERY ) }; // Create a ShellminatorCommanderInterface object, and initialize it to use Serial ShellminatorCommanderInterface shell( &Serial ); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); commander.attachDebugChannel( &Serial ); commander.attachTree( API_tree ); // Attach system variables to the commander object. commander.attachVariables( System_variables ); commander.init(); shell.attachCommander( &commander ); // Attach the colorizer to the shell. shell.attachColorizer( &colorizer ); // Initialize shell object. shell.begin( "arnold" ); } // Infinite loop. void loop(){ // Calculate milliseconds since start. MILLIS = millis(); // Fictive battery calculation. Just to make it change over time. BATTERY = ( MILLIS % 1000 ) / 10.0; // Process the new data. shell.update(); } bool echo_func(char *args, CommandCaller* caller ){ char textBuffer[ 30 ]; // The text argument is required to parse system variables. Argument text( args, 0 ); // Try to parse string or system variables if( text.parseString( textBuffer ) ){ caller -> println( textBuffer ); return true; } // If parsing failes, just print out the args. caller -> println( args ); return true; } ``` -------------------------------- ### C++: Full Shellminator Setup with Detailed List Source: https://www.shellminator.org/html/307_gui_list_advanced_page This is a complete C++ code example for setting up and running a Shellminator application that utilizes a detailed list. It includes necessary headers, initialization of the Shellminator object, clearing the terminal, setting up the detailed list, attaching the callback, and managing the screen. ```cpp /* * Created on Aug 10 2020 * * Copyright (c) 2023 - Daniel Hajnal * hajnal.daniel96@gmail.com * This file is part of the Shellminator project. * Modified 2023.05.13 */ #include "Shellminator.hpp" #include "GUI/Shellminator-List-Detailed.hpp" #include "GUI/Shellminator-Notification.hpp" // Create a Shellminator object, and initialize it to use Serial Shellminator shell( &Serial ); ShellminatorNotification notification; // Generate a list of options const char* listOptions[] = { "Aladdin", "The Iron Giant", "Treasure Planet" }; // Generate a list of details // The order must match with the options const char* listDetails[] = { "1992. November 25.", "1999. June 31.", "2002. November 27." }; // Simple instructions text. const char* listText = "Choose a movie to watch:"; // Create a detailed list. ShellminatorListDetailed movieList( listOptions, listDetails, 3, listText ); // Callback for the list. void listCallback( const char* optionsList[], int listSize, int selected, ShellminatorScreen* ); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); Serial.println( "Program Start!" ); movieList.attachCallback( listCallback ); shell.begin( "arnold" ); shell.beginScreen( &movieList ); } // Infinite loop. void loop(){ shell.update(); } void listCallback( const char* optionsList[], int listSize, int selected, ShellminatorScreen* screen ){ Shellminator* parent; parent = screen -> getParent(); if( parent == NULL ){ return; } // Generate a notification based on the answer. if( selected == 0 ){ notification.setText( "Good choice, you can watch Aladdin here:\nhttps://www.imdb.com/title/tt0103639/" ); } else if( selected == 1 ){ notification.setText( "Good choice, you can watch The Iron Giant here:\nhttps://www.imdb.com/title/tt0129167/" ); } else{ notification.setText( "Good choice, you can watch the Treasure Planet here:\nhttps://www.imdb.com/title/tt0133240/" ); } parent -> swapScreen( ¬ification ); } ``` -------------------------------- ### Complete Shellminator Plot Example Source: https://www.shellminator.org/html/308_gui_plot_page This is a complete example demonstrating the setup and usage of the Shellminator Plot Module. It includes necessary headers, data definition, plot object creation, and the display of the plot within the setup function. ```c++ /* * Created on Aug 10 2020 * * Copyright (c) 2023 - Daniel Hajnal * hajnal.daniel96@gmail.com * This file is part of the Shellminator project. * Modified 2023.05.13 */ #include "Shellminator.hpp" #include "GUI/Shellminator-PlotModule.hpp" // Create a Shellminator object, and initialize it to use Serial Shellminator shell( &Serial ); // Data points float plotData[] = { 10, 20, 30, 20, 10, 0, -10, -20, -30, -20 }; // Number of points in the data int plotDataSize = sizeof( plotData ) / sizeof( plotData[ 0 ] ); // Create a plot object ShellminatorPlot plot( plotData, plotDataSize, "My Plot" ); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); Serial.println( "Program Start!" ); shell.begin( "arnold" ); shell.beginScreen( &plot ); } // Infinite loop. void loop(){ shell.update(); } ``` -------------------------------- ### Activate Conda Environment and Run Build Script Source: https://www.shellminator.org/html/md_extras__assets__docu_pages_developer_zone This sequence first activates the 'shellminator' Conda environment, making its installed packages available. Then, it executes the 'build.py' script with the target 'clean web', which cleans previous builds and compiles web examples. ```shell conda activate shellminator python build.py -t 'clean web' ``` -------------------------------- ### Full Example: Setup and Loop for QR Code Generation Source: https://www.shellminator.org/html/101_qr_code_page This is a complete Arduino sketch demonstrating the integration of the Shellminator QR Code Module. It includes the necessary includes, object instantiation, serial initialization, clearing the terminal, generating a QR code with a URL, and initializing the Shellminator object. ```cpp /* * Created on Aug 10 2020 * * Copyright (c) 2023 - Daniel Hajnal * hajnal.daniel96@gmail.com * This file is part of the Shellminator project. * Modified 2023.05.13 */ #include "Shellminator.hpp" #include "Shellminator-QR-Code-Module.hpp" // Create a Shellminator object, and initialize it to use Serial Shellminator shell( &Serial ); ShellminatorQR qrCode; // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); Serial.println( "Shellminator webpage:" ); Serial.println(); // Generate a link to the Github repo. qrCode.generate( &Serial, "https://www.shellminator.org/html/index.html" ); // Initialize shell object. shell.begin( "arnold" ); } // Infinite loop. void loop(){ // Process the new data. shell.update(); } ``` -------------------------------- ### Shellminator Setup with Button Grid and Event Handling (C++) Source: https://www.shellminator.org/html/402_endless_screen_page Initializes the Shellminator library, sets up a 2x2 grid of buttons, assigns specific key events to each button, and attaches a click handler. It also configures an end callback for the grid and begins the Shellminator screen. ```C++ #include "Shellminator.hpp" #include "Shellminator-Screen.hpp" #include "GUI/Shellminator-ScreenGrid.hpp" #include "GUI/Shellminator-Buttons.hpp" ShellminatorButton button_1( "BTN 1" ); ShellminatorButton button_2( "BTN 2" ); ShellminatorButton button_3( "BTN 3" ); ShellminatorButton button_4( "BTN 4" ); // Create a grid 2 rows and 2 columns ShellminatorScreenGrid grid( 2, 2 ); // Create a Shellminator object, and initialize it to use Serial Shellminator shell( &Serial ); Shellminator::shellEvent_t button_1_event; Shellminator::shellEvent_t button_2_event; Shellminator::shellEvent_t button_3_event; Shellminator::shellEvent_t button_4_event; bool trigger = false; void button_click( ShellminatorScreen* screen ); void endCallback( Shellminator* parent ); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); Serial.println( "Program Start!" ); // Place button_1 to the first row and the first column. grid.addWidget( &button_1, 0, 0 ); // Place button_2 to the first row and the second column. grid.addWidget( &button_2, 0, 1 ); // Place button_3 to the second row and the first column. grid.addWidget( &button_3, 1, 0 ); // Place button_3 to the second row and the second column. grid.addWidget( &button_4, 1, 1 ); button_1_event.type = Shellminator::SHELL_EVENT_KEY; button_1_event.data = (uint8_t)'a'; button_2_event.type = Shellminator::SHELL_EVENT_KEY; button_2_event.data = (uint8_t)'b'; button_3_event.type = Shellminator::SHELL_EVENT_KEY; button_3_event.data = (uint8_t)'c'; button_4_event.type = Shellminator::SHELL_EVENT_KEY; 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 ); // Initialize shell object. shell.begin( "arnold" ); // Register the Screen object. The terminal will pass // the control to it, until the user presses the ESC button. shell.beginScreen( &grid ); } // Infinite loop. void loop(){ // Process the new data. shell.update(); } void button_click( ShellminatorScreen* screen ){ Shellminator* parent; Shellminator::textColor_t color; parent = screen -> getParent(); if( parent == NULL ){ return; } trigger = !trigger; if( trigger ){ color = Shellminator::RED; } else{ color = Shellminator::YELLOW; } button_1.setColor( color ); button_2.setColor( color ); button_3.setColor( color ); button_4.setColor( color ); parent -> requestRedraw(); } void endCallback( Shellminator* parent ){ if( parent == NULL ){ return; } parent -> swapScreen( &grid ); } ``` -------------------------------- ### Complete Shellminator WebSocket Example (Arduino) Source: https://www.shellminator.org/html/500_web_socket_simple_page Provides a full Arduino sketch for the Shellminator WebSocket implementation. It includes WiFi connection setup, server initialization, and the main loop for processing messages. ```cpp /* * Created on Aug 10 2020 * * Copyright (c) 2023 - Daniel Hajnal * hajnal.daniel96@gmail.com * This file is part of the Shellminator project. * Modified 2023.05.13 */ #include "WiFi.h" #include "Shellminator.hpp" #include "Shellminator-Websocket.hpp" #define WEBSOCKET_PORT 443 char ssid[] = "Replace With Your SSID"; // your network SSID (name) char pass[] = "Replace With Your Password"; // your network password (use for WPA, or use as key for WEP) ShellminatorWebSocket ws( WEBSOCKET_PORT ); // Create a Shellminator object, and initialize it to use WebSocketsServer Shellminator shell( &ws ); // System init section. void setup(){ Serial.begin(115200); Serial.begin(115200); WiFi.begin(ssid, pass); // Attempt to connect to WiFi network: Serial.print("Attempting to connect to Network"); while( WiFi.status() != WL_CONNECTED ){ Serial.print( '.' ); delay( 1000 ); } Serial.print("Connected!"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); // initialize shell object. shell.begin( "arnold" ); ws.attachDebugChannel( &Serial ); ws.begin(); } // Infinite loop. void loop(){ ws.update(); shell.update(); // Give some time to the other tasks on RTOS systems. delay( 2 ); } ``` -------------------------------- ### Full Shellminator List Example (C++) Source: https://www.shellminator.org/html/306_gui_list_page A complete C++ code example for an Arduino-like environment using the Shellminator library. It initializes the system, sets up a list with options and a callback, and handles the main loop for updates. ```c++ /* * Created on Aug 10 2020 * * Copyright (c) 2023 - Daniel Hajnal * hajnal.daniel96@gmail.com * This file is part of the Shellminator project. * Modified 2023.05.13 */ #include "Shellminator.hpp" #include "GUI/Shellminator-List.hpp" #include "GUI/Shellminator-Notification.hpp" // Create a Shellminator object, and initialize it to use Serial Shellminator shell( &Serial ); // This will be used to display the answer for the chosen answer. ShellminatorNotification notification; // These options are available for choose. const char* listOptions[] = { "Red Pill", "Blue Pill" }; // Instructions for the list. const char* listText = "Choose your destiny Neo"; // Create a list. ShellminatorList neoList( listOptions, 2, listText ); // Create a callback for the list. void listCallback( const char* optionsList[], int listSize, int selected, ShellminatorScreen* ); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); Serial.println( "Program Start!" ); // Attach the callback for the list. neoList.attachCallback( listCallback ); shell.begin( "arnold" ); shell.beginScreen( &neoList ); } // Infinite loop. void loop(){ shell.update(); } void listCallback( const char* optionsList[], int listSize, int selected, ShellminatorScreen* screen ){ Shellminator* parent; parent = screen -> getParent(); if( parent == NULL ){ return; } // Generate answer based on the selected answer. if( selected == 0 ){ notification.setText( "You stay in Wonderland and I show\nyou how deep the rabbit hole goes." ); } else{ notification.setText( "The story ends, you wake up in your bed and\nbelieve whatever you want to believe." ); } parent -> swapScreen( ¬ification ); } ``` -------------------------------- ### C++ Shellminator Setup with WiFi and WebSockets Source: https://www.shellminator.org/html/502_web_socket_self_hosted_page This C++ code initializes the ESP32 for WiFi connectivity, sets up a Shellminator instance to communicate via WebSockets, and configures a themed web server. It includes defining network credentials, WebSocket ports, and attaching callbacks for user connection events. The `setup()` function handles WiFi connection, logo attachment, buffering, password protection, and starting the Shellminator and WebSocket services. The `loop()` function continuously updates these services. ```cpp #include "WiFi.h" #include "Shellminator.hpp" #include "Shellminator-WebServer.hpp" #include "Shellminator-Websocket.hpp" #define WEBSOCKET_PORT 443 // Webserver port for webpage and contents. #define WEBSERVER_PORT 80 char ssid[] = "Replace With Your SSID"; // your network SSID (name) char pass[] = "Replace With Your Password"; // your network password (use for WPA, or use as key for WEP) ShellminatorWebServerThemedOffline htmlServer( WEBSERVER_PORT ); ShellminatorWebSocket ws( WEBSOCKET_PORT ); // Create a Shellminator object, and initialize it to use WebSocketsServer Shellminator shell( &ws ); // We will need a buffer to avoid flickering. uint8_t printBuffer[ 100 ]; int printBufferSize = sizeof( printBuffer ); // Hash for 'Password' as password. Obviously, replace it // when working on something sensitive. uint8_t passwordHash[] = { 0xCC, 0xb4, 0x24, 0x83 }; // Shellminator logo. const char logo[] = " _____ __ ____ _ __ \r\n" " / ___// /_ ___ / / /___ ___ (_)___ ____ _/ /_____ _____ \n" " \\__ \\/ __ \\/ _ \\/ / / __ `__ \\/ / __ \\/ __ `/ __/ __ \\/ ___/\r\n" " ___/ / / / / __/ / / / / / / / / / / /_/ / /_/ /_/ / / \r\n" "/____/_/ /_/\\___/_/_/_/ /_/ /_/_/_/ /_/\\__,_/\\__/\\____/_/ \r\n" "\r\n\033[0;37m" "Visit on GitHub:\033[1;32m https://github.com/dani007200964/Shellminator\r\n\r\n" ; // Callbacks for connect and disconnect events. void userConnectedCallback( ShellminatorWebSocket* socket ); void userDisconnectedCallback( ShellminatorWebSocket* socket ); // System init section. void setup(){ Serial.begin(115200); WiFi.begin(ssid, pass); // Attempt to connect to WiFi network: Serial.print("Attempting to connect to Network"); while( WiFi.status() != WL_CONNECTED ){ Serial.print( '.' ); delay( 1000 ); } // Attach the logo. shell.attachLogo( logo ); // Enable buffering. shell.enableBuffering( printBuffer, printBufferSize ); // Enable password protection. shell.setPassword( passwordHash, sizeof( passwordHash ) ); // initialize shell object. shell.begin( "arnold" ); // Uncomment if you want to enable html server debug messages. // ws.attachDebugChannel( &Serial ); htmlServer.begin(); ws.attachDebugChannel( &Serial ); // Attach connect and disconnect callbacks. ws.attachConnectCallback( userConnectedCallback ); ws.attachDisconnectCallback( userDisconnectedCallback ); ws.begin(); } // Infinite loop. void loop(){ ws.update(); shell.update(); htmlServer.update(); // Give some time to the other tasks on RTOS systems. delay( 2 ); } void userConnectedCallback( ShellminatorWebSocket* socket ){ // Print 'welcome' screen after connection. shell.printLoginScreen(); } void userDisconnectedCallback( ShellminatorWebSocket* socket ){ // In case of disconnect event, close the terminal. shell.logOut(); } ``` -------------------------------- ### Initialize and Start Shellminator Web Server Source: https://www.shellminator.org/html/502_web_socket_self_hosted_page Instantiate the ShellminatorWebServerThemedOffline class, specifying the port for the web server. Then, attach a debug channel (optional) and start the server. This setup is crucial for offline WebTerminal hosting. ```c++ // Webserver port for webpage. #define WEBSERVER_PORT 80 ShellminatorWebServerThemedOffline htmlServer( WEBSERVER_PORT ); // In the init section: htmlServer.attachDebugChannel( &Serial ); htmlServer.begin(); ``` -------------------------------- ### Shellminator - Example Usage Source: https://www.shellminator.org/html/class_shellminator_ble_stream_1_1ble_rx_callback Provides a structured list of examples for Shellminator, ranging from simple command callbacks and text formatting to advanced features like input handling and ASCII art generation. Each example is designed to illustrate a specific aspect of the terminal's capabilities. ```shell ðŸ‘ķ 001 Basic 🊝 002 Command Callback 🖌ïļ 003 Text Formatting ðŸŽĻ 004 Format Matrix 📷 005 Logo 🔐 006 Password âŒĻïļ 007 Input ðŸ’Ŋ 008 Input Number 🔉 009 Beep 📜 010 Banner Text ðŸŽđ 100 Key Override 🔗 101 QR Code ðŸŦ— 102 Buffering ðŸ‘― 120 Neofetch Basic 🏄 121 Neofetch Advanced 🎖ïļ 200 Commander Basic ðŸ’ū 201 Commander Optimizations ðŸ—Ģ 202 Commander Simple Arguments 🏷ïļ 203 Commander Argument Types 📍 204 Position Independent Arguments ðŸŪ 205 Commander Cowsay ðŸ’ē 206 Commander System Variables ✏ïļ 207 Commander Set System Variables 🌈 208 Commander Colorizer 👆 300 GUI Button âģ 301 GUI Progress ⏱ïļ 302 GUI Progress Advanced 📈 303 GUI Level Meter 📊 304 GUI Level Meter Advanced 💎 305 GUI Notification ðŸĐđ 306 GUI List 📋 307 GUI List Advanced 📉 308 GUI Plot ðŸŽĒ 309 GUI Plot Advanced ðŸ’ŧ 400 Simple Screen ðŸĪ™ 401 Screen End Callback â™ūïļ 402 Endless Screen 🌐 500 WebSocket Simple ðŸĶĒ 501 WebSocket Pretty 🗄ïļ 502 WebSocket SelfHosted ðŸ“ķ 510 BLE Simple 🔌 520 TCP Simple ``` -------------------------------- ### BLE Simple Example Source: https://www.shellminator.org/html/class_shellminator_ble_stream_1_1_server_callbacks Provides an example of setting up a simple Bluetooth Low Energy (BLE) server with Shellminator. This allows for wireless communication with BLE-enabled devices. ```cpp #include #include #include #include ShellminatorBleStream shellminatorBLE; void setup() { Serial.begin(115200); shellminatorBLE.begin("ShellminatorBLE"); shellminatorBLE.println("BLE server started."); } void loop() { shellminatorBLE.processInput(); } ``` -------------------------------- ### Complete Shellminator Example Code (C++) Source: https://www.shellminator.org/html/001_basic_page A comprehensive example demonstrating the inclusion, instantiation, initialization, and update loop for the Shellminator library. This code provides a functional console interface. ```cpp /* * Created on June 8 2024 * * Copyright (c) 2023 - Daniel Hajnal * hajnal.daniel96@gmail.com * This file is part of the Shellminator project. * Modified 2023.05.13 */ #include "Shellminator.hpp" // Create a Shellminator object, and initialize it to use Serial Shellminator shell( &Serial ); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); // Initialize shell object. shell.begin( "arnold" ); } // Infinite loop. void loop(){ // Process the new data. shell.update(); } ``` -------------------------------- ### Initialize Serial and Start Shell Source: https://www.shellminator.org/html/md_extras__assets__docu_pages_installation_page Initializes the serial interface with a specified baud rate (115200) and then clears the terminal and starts the Shellminator with a given name. ```cpp usart3.begin( 115200 ); shell.clear(); shell.begin( "stm32" ); ``` -------------------------------- ### Start Web Server Source: https://www.shellminator.org/html/class_shellminator_web_server_themed_offline Initiates the web server functionality. This function typically starts listening for incoming connections and serving web content. ```cpp void begin () ``` -------------------------------- ### C++ Whole Code Example for Shellminator Source: https://www.shellminator.org/html/305_gui_notification_page A complete C++ example demonstrating the integration of Shellminator and ShellminatorNotification. It includes setting up a button, handling button clicks to trigger a notification, and managing the Shellminator application lifecycle. ```C++ /* * Created on Aug 10 2020 * * Copyright (c) 2023 - Daniel Hajnal * hajnal.daniel96@gmail.com * This file is part of the Shellminator project. * Modified 2023.05.13 */ #include "math.h" #include "Shellminator.hpp" #include "GUI/Shellminator-Buttons.hpp" #include "GUI/Shellminator-Notification.hpp" // Create a Shellminator object, and initialize it to use Serial Shellminator shell( &Serial ); ShellminatorNotification notification; // Create a plotter object. ShellminatorButton button( "Press" ); Shellminator::shellEvent_t buttonEvent; // This function will be called, when the button is pressed. void buttonClick( ShellminatorScreen* screen ); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); Serial.println( "Program Start!" ); buttonEvent.type = Shellminator::SHELL_EVENT_KEY; buttonEvent.data = (uint8_t)'x'; button.attachEvent( buttonEvent ); button.attachTriggerFunction( buttonClick ); button.setColor( Shellminator::RED ); shell.begin( "arnold" ); shell.beginScreen( &button, 100 ); } // Infinite loop. void loop(){ // Process the new data. shell.update(); } void buttonClick( ShellminatorScreen* screen ){ Shellminator* parent; parent = screen -> getParent(); if( parent == NULL ){ return; } notification.setText( "Hurray!\nYou pressed the button!" ); parent -> swapScreen( ¬ification ); } ``` -------------------------------- ### Complete Shellminator GUI Plot Example (Arduino) Source: https://www.shellminator.org/html/309_gui_plot_advanced_page The full C++ code for an Arduino project using Shellminator to simulate and plot capacitor voltage. Includes setup, loop, and simulation logic. ```cpp /* * Created on Aug 10 2020 * * Copyright (c) 2023 - Daniel Hajnal * hajnal.daniel96@gmail.com * This file is part of the Shellminator project. * Modified 2023.05.13 */ #include "Shellminator.hpp" #include "GUI/Shellminator-PlotModule.hpp" #include // Simulation constants #define R 5100.0 // Resistor (Ohm) #define C 0.01 // Capacitance (Farad) #define U0 5.0 // Supply Voltage (Volt) // Create a Shellminator object, and initialize it to use Serial Shellminator shell( &Serial ); float plotData[ 100 ]; int plotDataSize = sizeof( plotData ) / sizeof( plotData[ 0 ] ); uint32_t timerStart = 0; uint32_t timerPeriod = 1000; // Set a custom color for the plot. ShellminatorPlot plot( plotData, plotDataSize, "Capacitor Voltage[ V ]", Shellminator::RED ); void capacitorSimulator(); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); Serial.println( "Program Start!" ); shell.begin( "arnold" ); shell.beginScreen( &plot ); } // Infinite loop. void loop(){ // In the timerPeriod defined intervals, recalculate the current // state of the simulated capacitor. if( ( millis() - timerStart ) > timerPeriod ){ timerStart = millis(); capacitorSimulator(); // After calculation, we have to request the shell // to redraw the plot. shell.requestRedraw(); } shell.update(); } void capacitorSimulator(){ int i; // With the for loop, we shift every element in the plot to the left for( i = 0; i < plotDataSize - 1; i++ ){ plotData[ i ] = plotData[ i + 1 ]; } // To the last element, we calculate the new value based on system time. plotData[ plotDataSize - 1 ] = U0 * ( 1.0 - exp( -(millis() / 1000.0 ) * ( 1.0 / ( R * C ) ) ) ); } ``` -------------------------------- ### Shellminator C++ Setup and Loop Source: https://www.shellminator.org/html/400_simple_screen_page This C++ code sets up the Shellminator environment, initializes various GUI components like buttons, level meters, notifications, and progress bars, and arranges them on a grid. The setup function configures serial communication and displays initial messages and states. The loop function continuously processes updates from the Shellminator object. ```cpp #include "Shellminator.hpp" #include "Shellminator-Screen.hpp" #include "GUI/Shellminator-ScreenGrid.hpp" #include "GUI/Shellminator-Buttons.hpp" #include "GUI/Shellminator-Notification.hpp" #include "GUI/Shellminator-Level-Meter.hpp" #include "GUI/Shellminator-Progress.hpp" ShellminatorButton button_0( "BTN 0" ); ShellminatorButton button_1( "BTN 1" ); ShellminatorButton button_2( "BTN 2" ); ShellminatorButton button_3( "BTN 3" ); ShellminatorButton button_enter( "Enter" ); ShellminatorLevelMeter meter_1( "Audio L" ); ShellminatorLevelMeter meter_2( "Audio R" ); ShellminatorNotification notification; ShellminatorProgress progress_1; ShellminatorProgress progress_2; ShellminatorProgress progress_3; // Create a Shellminator object, and initialize it to use Serial Shellminator shell( &Serial ); // Create a grid 3 rows and 6 columns ShellminatorScreenGrid grid( 3, 6 ); // System init section. void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); Serial.println( "Program Start!" ); notification.setText( "Hello!" ); meter_1.setPercentage( 35.0 ); meter_2.setPercentage( 73.0 ); progress_1.setPercentage( 30.0 ); progress_2.setPercentage( 80.0 ); progress_3.setPercentage( 21.0 ); // Place button_0 to the first row and the first column. // If no span specified it defaults to one grid cell size. grid.addWidget( &button_0, 0, 0 ); // Place button_1 to the first row and the second column. grid.addWidget( &button_1, 0, 1 ); // Place button_2 to the second row and the first column. grid.addWidget( &button_2, 1, 0 ); // Place button_2 to the second row and the second column. grid.addWidget( &button_3, 1, 1 ); // Place button_enter to the third row and the first column. // Make it one cells heigh and two cell wide. grid.addWidget( &button_enter, 2, 0, 1, 2 ); // Place notification to the first row and the third column. // Make it two cells high and one cell wide. grid.addWidget( ¬ification, 0, 2, 2, 1 ); grid.addWidget( &progress_1, 0, 5 ); grid.addWidget( &progress_2, 1, 5 ); grid.addWidget( &progress_3, 2, 5 ); grid.addWidget( &meter_1, 0, 3, 3, 1 ); grid.addWidget( &meter_2, 0, 4, 3, 1 ); // Initialize shell object. shell.begin( "arnold" ); // Register the Screen object. The terminal will pass // the control to it, until the user presses the ESC button. shell.beginScreen( &grid ); } // Infinite loop. void loop(){ // Process the new data. shell.update(); } ``` -------------------------------- ### Commander System Variables Example Source: https://www.shellminator.org/html/class_shellminator_ble_stream_1_1_server_callbacks Illustrates how to get and set system variables within Shellminator's Commander. This is useful for managing application state and configuration. ```cpp #include Shellminator shellminator; void setup() { Serial.begin(115200); shellminator.println("System variables example."); // Set a system variable shellminator.setSystemVariable("greeting", "Hello World"); // Get and print a system variable shellminator.addCommand("greet", "Prints the greeting variable", [](Shellminator &sh, const std::vector &args) { String greeting = sh.getSystemVariable("greeting"); sh.println(greeting); }); // Set a system variable from command shellminator.addCommand("setgreet", "Sets the greeting variable", [](Shellminator &sh, const std::vector &args) { if (!args.empty()) { sh.setSystemVariable("greeting", args[0]); sh.println("Greeting set to: " + args[0]); } else { sh.println("Usage: setgreet "); } }); } void loop() { shellminator.processInput(); } ``` -------------------------------- ### Example Execution Function Implementation (C++) Source: https://www.shellminator.org/html/class_shellminator Provides a practical example of how to implement the execution function callback for Shellminator. This function demonstrates capturing a command and printing it using the Shellminator's channel. ```C++ void myExecFunc( char* command, Shellminator* caller ){ caller -> channel -> print( "Hurray! I got this: " ); caller -> channel -> println( command ); } ``` -------------------------------- ### Initialize System and Start Shell (C++) Source: https://www.shellminator.org/html/001_basic_page Sets up the serial communication, clears the console, and initializes the Shellminator object with a specified name. This function is typically part of the Arduino `setup()`. ```cpp void setup(){ Serial.begin(115200); // Clear the terminal shell.clear(); // Initialize shell object. shell.begin( "arnold" ); } ``` -------------------------------- ### WebSocket Simple Example Source: https://www.shellminator.org/html/class_shellminator_ble_stream_1_1_server_callbacks Demonstrates setting up a basic WebSocket server using Shellminator. This enables real-time communication between the terminal and web clients. ```cpp #include #include // Example for ESP32 ShellminatorWebSocket shellminatorWS; void setup() { Serial.begin(115200); WiFi.begin("SSID", "PASSWORD"); // Replace with your WiFi credentials while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi..."); } Serial.println("Connected to WiFi"); shellminatorWS.begin(80); shellminatorWS.println("WebSocket server started."); } void loop() { shellminatorWS.processInput(); } ``` -------------------------------- ### Commander Basic Example Source: https://www.shellminator.org/html/class_shellminator_ble_stream_1_1_server_callbacks Demonstrates the fundamental usage of the Commander interface in Shellminator for parsing and executing commands with arguments. ```cpp #include Shellminator shellminator; void setup() { Serial.begin(115200); shellminator.println("Commander interface ready."); shellminator.addCommand("add", "Adds two numbers", [](Shellminator &sh, const std::vector &args) { if (args.size() == 2) { int num1 = args[0].toInt(); int num2 = args[1].toInt(); sh.println("Result: " + String(num1 + num2)); } else { sh.println("Usage: add "); } }); } void loop() { shellminator.processInput(); } ``` -------------------------------- ### Shellminator Commander Setup and Loop (C++) Source: https://www.shellminator.org/html/202_commander_simple_arguments_page This snippet shows the setup and main loop for the Shellminator commander. It initializes the serial communication, clears the terminal, attaches a debug channel and command tree to the commander, and then begins the Shellminator interface with a given prompt. The loop continuously updates the shell to process incoming commands. ```C++ #include "Shellminator.hpp" #include "Shellminator-Commander-Interface.hpp" #include "Commander-API.hpp" #include "Commander-Arguments.hpp" Commander commander; bool cat_func( char *args, CommandCaller* caller ); bool dog_func( char *args, CommandCaller* caller ); bool sum_func( char *args, CommandCaller* caller ); Commander::systemCommand_t API_tree[] = { systemCommand( "cat", "Description for cat command.", cat_func ), systemCommand( "dog", "Description for dog command.", dog_func ), systemCommand( "sum", "This function sums two number from the argument list.", sum_func ) }; ShellminatorCommanderInterface shell( &Serial ); void setup(){ Serial.begin(115200); shell.clear(); commander.attachDebugChannel( &Serial ); commander.attachTree( API_tree ); commander.init(); shell.attachCommander( &commander ); shell.begin( "arnold" ); } void loop(){ shell.update(); } ```