📄 testucgui.c
字号:
GUI_DrawVLine(x, y0 + 11 * yStep, y0 + 12 * yStep - 1);
GUI_SetColor(0xff00ff + (255 - cs) * 0x100L);
GUI_DrawVLine(x, y0 + 12 * yStep, y0 + 13 * yStep - 1);
}
}
/*******************************************************************
*
* Modify the RGB-shares of all colors
*
********************************************************************
*/
static void ModifyLUT(int RFaktor, int GFaktor, int BFaktor) {
int NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS);
int i;
for (i=0; i<NumColors; i++) {
U32 Color = LCD_GetDevCap(LCD_DEVCAP_COLOR + i);
U32 R = Color&0xff;
U32 G = (Color>>8) &0xff;
U32 B = (Color>>16)&0xff;
/* Now modify color */
R = (R * RFaktor) / 100;
G = (G * GFaktor) / 100;
B = (B * BFaktor) / 100;
/* Write modified color into lookup table */
Color = R | (G<<8)| (B <<16);
GUI_SetLUTEntry(i,Color);
}
}
/*******************************************************************
*
* Modify the RGB-shares of all colors
*
********************************************************************
*/
static void DemoLUT(void) {
int i;
/* First draw something */
GUI_SetFont(&GUI_Font13HB_1);
GUI_DispStringHCenterAt("礐/GUI-sample demonstrating\nLUT-modifications", 160, 0);
ShowColorBar();
while(NotToExit()) {
/* Reduce the red share */
for (i=0; i<=100; i+=10) {
ModifyLUT(100 - i, 100, 100);
GUI_Delay(100);
}
GUI_Delay(500);
/* Reduce the green share */
for (i=0; i<=100; i+=10) {
ModifyLUT(0, 100 - i, 100);
GUI_Delay(100);
}
GUI_Delay(500);
/* Reduce the blue share */
for (i=0; i<=100; i+=10) {
ModifyLUT(0, 0, 100 - i);
GUI_Delay(100);
}
GUI_Delay(500);
/* Restore initial values */
LCD_InitLUT();
GUI_Delay(500);
}
}
/*******************************************************************
*
* main
*
********************************************************************
*/
void test_showcolor(void) {
GUI_Init();
DemoLUT();
}
#endif // #ifdef INCLUDE_SHOWCOLOR
#ifdef INCLUDE_PROBAR
#include "progbar.h"
/*******************************************************************
*
* Shows the use of progress bars
*
********************************************************************
*/
static void DemoProgBar(void) {
int i;
PROGBAR_Handle ahProgBar[2];
GUI_Clear();
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font8x16);
GUI_DispStringAt("Progress bar", 100,80);
/* Create `em */
ahProgBar[0] = PROGBAR_Create(100,100,100,20, WM_CF_SHOW);
ahProgBar[1] = PROGBAR_Create( 80,150,140,10, WM_CF_SHOW);
/* Use memory device (optional, for better looks) */
PROGBAR_EnableMemdev(ahProgBar[0]);
PROGBAR_EnableMemdev(ahProgBar[1]);
GUI_Delay (1000);
PROGBAR_SetMinMax(ahProgBar[1], 0, 500);
while(NotToExit()) {
PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16);
if (LCD_GetDevCap(LCD_DEVCAP_BITSPERPIXEL) <= 4) {
PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_DARKGRAY);
PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY);
} else {
PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_GREEN);
PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_RED);
}
for (i=0; i<=100; i++) {
PROGBAR_SetValue(ahProgBar[0], i);
PROGBAR_SetValue(ahProgBar[1], i);
GUI_Delay(5);
}
PROGBAR_SetText(ahProgBar[0], "Tank empty");
for (; i>=0; i--) {
PROGBAR_SetValue(ahProgBar[0], i);
PROGBAR_SetValue(ahProgBar[1], 200-i);
GUI_Delay(5);
}
PROGBAR_SetText(ahProgBar[0], "Any text ...");
PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_LEFT);
for (; i<=100; i++) {
PROGBAR_SetValue(ahProgBar[0], i);
PROGBAR_SetValue(ahProgBar[1], 200+i);
GUI_Delay(5);
}
PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_RIGHT);
for (; i>=0; i--) {
PROGBAR_SetValue(ahProgBar[0], i);
PROGBAR_SetValue(ahProgBar[1], 400-i);
GUI_Delay(5);
}
PROGBAR_SetFont(ahProgBar[0], &GUI_FontComic18B_1);
PROGBAR_SetText(ahProgBar[0], "Any font ...");
for (; i<=100; i++) {
PROGBAR_SetValue(ahProgBar[0], i);
PROGBAR_SetValue(ahProgBar[1], 400+i);
GUI_Delay(5);
}
GUI_Delay(1000);
}
}
/*******************************************************************
*
* main
*
********************************************************************
*/
void test_probar(void) {
GUI_Init();
DemoProgBar();
}
#endif // #ifdef INCLUDE_PROBAR
#include "gui.H"
#include "edit.h"
/*******************************************************************
*
* Edit a string until ESC or ENTER is pressed
*
********************************************************************
*/
static int Edit(void) {
int Key;
EDIT_Handle hEdit;
char aBuffer[28];
GUI_SetFont(&GUI_Font8x16);
GUI_DispStringHCenterAt("Use keyboard to modify string...", 160, 0);
/* Create edit widget */
hEdit = EDIT_Create( 50, 20, 219, 25, ' ', sizeof(aBuffer), 0 );
/* Modify edit widget */
EDIT_SetText(hEdit, "Press <ENTER> when done...");
EDIT_SetFont(hEdit, &GUI_Font8x16);
EDIT_SetTextColor(hEdit, 0, GUI_RED);
/* Set keyboard focus to edit widget */
WM_SetFocus(hEdit);
/* Handle keyboard until ESC or ENTER is pressed */
do {
Key = GUI_WaitKey();
} while ((Key != GUI_ID_ESCAPE) && (Key != GUI_ID_ENTER) && (Key != 0));
/* Fetch result from edit widget */
if (Key == GUI_ID_ENTER)
EDIT_GetText(hEdit, aBuffer, sizeof(aBuffer));
else
aBuffer[0] = 0;
EDIT_Delete(hEdit);
GUI_DispStringHCenterAt(aBuffer, 160, 50);
return Key;
}
/*******************************************************************
*
* main
*
********************************************************************
*/
void test_edit(void) {
GUI_Init();
Edit();
while(1)
GUI_Delay(100);
}
#include <stddef.h>
#include "GUI.H"
#include "DIALOG.h"
/*********************************************************************
*
* static data
*
**********************************************************************
*/
/*********************************************************************
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -