/** * Display a menu and select menu item number * With 3 menu items * * text1 - text on line 1 (max 18 characters) * text2 - text on line 2 (max 18 characters) * text3 - text on line 3 (max 18 characters) * * returns selected menue alternative, 1, 2 or 3 */ int screenMenu3(unsigned char text1[], unsigned char text2[], unsigned char text3[]) { int dataX; int dataY; int i = 0; screenClear (); //write text screenOutputText(2, 1, Blue, text1); screenOutputText(4, 1, Blue, text2); screenOutputText(6, 1, Blue, text3); //draw rectangles xSemaphoreTake(lcdLock, portMAX_DELAY); GLCD_setTextColor(Blue); GLCD_drawRect(Line2 - 12, 5, 48, 310); GLCD_drawRect(Line4 - 12, 5, 48, 310); GLCD_drawRect(Line6 - 12, 5, 48, 310); xSemaphoreGive(lcdLock); //wait for user to select alternative while(i == 0) { //select alternative screenTouched(&dataX, &dataY); //find out which alternative selected if (dataY > Line2 - 12 && dataY < Line4 - 12) i = 1; if (dataY > Line4 - 12 && dataY < Line6 - 12) i = 2; if (dataY > Line6 - 12 && dataY < Line8 - 12) i = 3; } xSemaphoreTake(lcdLock, portMAX_DELAY); GLCD_setTextColor(Green); GLCD_setBackColor (Green); if ( i == 1) { GLCD_fillRect(Line2 - 12, 5, 48, 310); xSemaphoreGive(lcdLock); screenOutputText(2, 1, Blue, text1); } else if (i == 2) { GLCD_fillRect(Line4 - 12, 5, 48, 310); xSemaphoreGive(lcdLock); screenOutputText(4, 1, Blue, text2); } else { GLCD_fillRect(Line6 - 12, 5, 48, 310); xSemaphoreGive(lcdLock); screenOutputText(6, 1, Blue, text2); } xSemaphoreTake(lcdLock, portMAX_DELAY); GLCD_setBackColor (White); xSemaphoreGive(lcdLock); vTaskDelay(900 / portTICK_RATE_MS); return i; }
/** * Display a line with text and let the user confirm * * text - text on line, within rectangle max 18 characters) * */ int screenTextOk(unsigned char text[] ) { int dataX; int dataY; int i = 0; screenClear (); //write text screenOutputText(4, 1, Blue, text); screenOutputText(6, 5, Red, "Please confirm"); //draw rectangle xSemaphoreTake(lcdLock, portMAX_DELAY); GLCD_setTextColor(Blue); GLCD_drawRect(Line2, 5, 120,310); xSemaphoreGive(lcdLock); //wait for the user to confirm while(i == 0) { //select alternative screenTouched(&dataX, &dataY); //find out which alternative selected if (dataY > Line2 && dataY < Line6) i = 1; } return i; }
void display_button(int button) { xSemaphoreTake(lcdLock, portMAX_DELAY); GLCD_setTextColor(Black); GLCD_drawRect(buttons[button].upper, buttons[button].right, buttons[button].lower-buttons[button].upper, buttons[button].left-buttons[button].right); GLCD_displayChar(buttons[button].upper + 10, buttons[button].right + 20, *(buttons[button].text)); xSemaphoreGive(lcdLock); }