MIDI-CTRL -> Developer Manual -> Library Reference -> GUI
The GUI class¶
Overview¶
The GUI class is the main class used to interact with the LCD display, the buttons and the encoders. It is also in charge of displaying the current Page and running the current Sketch. Finally, it can run background tasks.
It provides a number of functions to display text on the display. In most firmwares you write, you will find yourself resorting to the methods of the GUI class only to display "flashing" text on the display. However, the need may arise to create some fancy display methods (for example for special Encoders which need to display their value in a non-standard fashion). In those cases, all the display methods of the GUI class are there to help you.
The GUI class is always instantiated as the GUI object.
Reference¶
GUIClass Class Reference
Sourcecode: source:hardware/libraries/GUI/GUI.h source:hardware/libraries/GUI/GUI.cpp
Displaying text using the GUI object¶
The methods used to display texts are available for both static texts, which is displayed permanently, and flashing text, which is only displayed for a short duration. The flashing text is displayed using the flash_* methods, which are equivalent to the normal methods, except that they take an additional optional argument duration, which specifies the duration of the flash in milliseconds.
The methods can be used to display text, by using the put_string, put_p_string (to display strings stored in program memory) and put_string_fill (to fill the rest of the display with spaces to blank it out). These methods take an additional first argument specifying the index the string has to be displayed. Because the display is mostly used to show data relating to the encoders, this index is in 4 character increments.
For example,
1 GUI.put_string_fill(1, "HELLO")
will display the following text: | _ _ _ _ H E L L O _ _ _ _ _ _ | .
If you want to display text at different places on the display, use the put_string_at, put_p_string_at and put_p_string_at_fill methods. For example,
1 GUI.put_string_at_fill(1, "HELLO")
will display | _ H E L L O _ _ _ _ _ _ _ _ _ _ |.
Setting the current sketch¶
When using Sketches to build your firmware, you need to activate the first sketch by telling the GUI object to run it. This is done by using the setSketch() method. Refer to Tutorial - Building your first Sketch class for more information about building a firmware with Sketch classes.