The text display is simpler. It is described in several parts:
(1) text display function
Gui_dispchar () // used to display a character
Gui_dispchars (); // used to repeatedly display the same character
Gui_dispcharat () // used to display a character at a specified position
Gui_dispstringat () // used to display a string of characters at a specified position
Gui_dispstringhcenterat () // use the X coordinate set in the function as the display
// Horizontal center of the text
These functions are commonly used, and I have never used other functions. This is the last function. The displayed function uses the X value set by itself as the center position of the entire string. A simple example is attached below.
Gui_setbkcolor (gui_blue); // you can specify the font color.
Gui_setcolor (gui_lightred); // you can specify the font color.
Gui_clear (); // clear the screen
Gui_setfont (& gui_font13b_ascii); // set the font size.
Gui_gotoxy (); // set the location
Gui_dispchar ('A'); // display one character
gui_dispcharat ('B', 8, 0); // a specified location displays a gui_gotox (16); // sets the location of X, Y unchanged
Gui_dispchars ('C', 4); // repeat one character for four times
(2) text writing style
Gui_settextstyle ();
There are four parameter settings
Gui_ts_normal is the default mode. This mode is generally used if it is not set.
Gui_ts_underline adds a line below the displayed string
Gui_ts_strikethru underline from the middle of the displayed string
Gui_ts_overline adds a line to the displayed string
An example is provided to illustrate
Gui_settextstyle (gui_ts_strikethru );
Gui_dispstringat ("hello", 0, y = 20 );
Gui_settextstyle (gui_ts_underline );
Gui_dispstringat ("hello", 100, y = 20 );
Gui_settextstyle (gui_ts_overline );
Gui_dispstringat ("hello", 200, y = 20 );
(3) text alignment
There are a lot of problems in writing, which need to be explained.
Gui_settextalign ()
In the horizontal direction
Gui_ta_left is the default value. For example, if X = 0 is set, it is displayed on the Right of x = 0.
For example, if you set gui_ta_hcenter to X = 100, the displayed text is centered on X = 100.
Gui_ta_right sets X = 100, and the displayed text is on the left of X = 100,
In the vertical direction
Gui_ta_top is the default case. For example, if y = 0, the displayed text is less than Y = 0.
For example, if you set Y = 100 for gui_ta_vcenter, the displayed text is centered on 100 in the vertical direction.
For example, if you set Y = 100, the displayed text is above y = 100.
You only need to pay attention to the mode of text display. This example shows the problem.
Gui_settextalign (gui_ta_right );
Gui_dispstringat ("Hello World", 200,0 );
Gui_settextalign (gui_ta_left );
Gui_dispstringat ("Hello World", 200,0 );
Gui_settextalign (gui_ta_left | gui_ta_bottom );
Gui_dispstringat ("Hello World", 0, 35 );
Gui_settextalign (gui_ta_hcenter | gui_ta_vcenter );
Gui_dispstringat ("Hello World", 400,5 );
(4) text mode
There is a detailed instruction routine in the instruction manual for the text mode ucgui, which is directly attached here.
Gui_setfont (& gui_font8x16 );
Gui_setfont (& gui_font8x16 );
Gui_setbkcolor (gui_blue );
Gui_clear ();
Gui_setpensize (10 );
Gui_setcolor (gui_red );
Gui_drawline (80, 10,240, 90 );// Come From : ST_M_8. c_N
Gui_drawline (80, 90,240, 10 );
Gui_setbkcolor (gui_black );
Gui_setcolor (gui_white );
Gui_settextmode (gui_tm_normal );
Gui_dispstringhcenterat ("gui_tm_normal", 160, 10 );
Gui_settextmode (gui_tm_rev );
Gui_dispstringhcenterat ("gui_tm_rev", 160, 26 );
Gui_settextmode (gui_tm_trans );
Gui_dispstringhcenterat ("gui_tm_trans", 160, 42 );
Gui_settextmode (gui_tm_xor );
Gui_dispstringhcenterat ("gui_tm_xor", 160, 58 );
Gui_settextmode (gui_tm_trans | gui_tm_rev );
Gui_dispstringhcenterat ("gui_tm_trans | gui_tm_rev", 160, 74 );