/************************************************************************ Function: void CreateAnimation(void) Overview: Creates the animation screen. Input: none Output: none ************************************************************************/ void CreateAnimation(void) { SHORT j, height, endPoint; // free memory for the objects in the previous linked list and start new list GOLFree(); SetColor(SCREEN_BACKGROUND_COLOR); ClearDevice(); // draw the band of lines with increasing thickness background of the demo height = 13; endPoint = GetMaxY() - 35; SetColor(RGB565CONVERT(0x4C, 0x8E, 0xFF)); for(j = 2; j <= endPoint; j += (height + 6)) { WAIT_UNTIL_FINISH(Bar(0, j, GetMaxX(), j + height)); if(height <= 0) height = 0; else height -= 1; } pPicture = PictCreate ( ID_PICTURE1, // ID PICTURE_XINDENT, PICTURE_YINDENT, PICTURE_XINDENT + PICTURE_WIDTH - 1, PICTURE_YINDENT + PICTURE_HEIGHT - 1, PICT_DRAW, // will be dislayed, has frame 2, // scale factor is x1 (void *) &Engine1, // bitmap altScheme ); // default GOL scheme pMeter = MtrCreate ( ID_METER2, (2 * PICTURE_XINDENT + PICTURE_WIDTH), PICTURE_YINDENT - 20, (2 * (PICTURE_XINDENT + PICTURE_WIDTH)), PICTURE_YINDENT + PICTURE_HEIGHT + 20, MTR_DRAW | MTR_RING | MTR_ACCURACY, // draw normal meter object MAX_METER_VALUE, // set initial value 0, MAX_METER_VALUE, // set range (void *) &GOLFontDefault, // Title font to be used (void *) &GOLMediumFont, // Value font to be used MeterStr, // meterScheme ); // alternative GOL scheme //pMeter->pTitleFont = (void*)&GOLFontDefault; //pMeter->pValueFont = (void*)&GOLMediumFont; // create the demo navigation/control buttons CreateCtrlButtons(ExitStr, ScaleStr, LeftArrowStr, RightArrowStr); }
/************************************************************************ Function: void CreateMultiFontsDemo(void) Overview: Creates the Multi-Font demo screen. Input: none Output: none ************************************************************************/ void CreateMultiFontsDemo(void) { SHORT i, j; // we need this since Static cannot have an uninitialized pointer to text // plus we need the static text area but we are only using it as a place // holder for the text that we will overwrite on the static text area static XCHAR spaceChar[2] = {0x20,0}; GOLFree(); // free memory for the objects in the previous linked list and start new list SetColor(SCREEN_BACKGROUND_COLOR); ClearDevice(); // draw the small squares SetColor(RGB565CONVERT(0x4C, 0x8E, 0xFF)); for(j = 5; j <= GetMaxY(); j += 16) { for(i = 5; i <= GetMaxX(); i += 16) { WAIT_UNTIL_FINISH(Bar(i, j, i + 3, j + 3)); } } InitHWData(); FontScheme2 = GOLCreateScheme(); // create alternative style scheme FontScheme2->pFont = pHWData->pHWFont; FontScheme2->Color0 = RGB565CONVERT(0xFF, 0xBB, 0x4C); FontScheme2->Color1 = RGB565CONVERT(0xFF, 0xBB, 0x4C); StCreate ( ID_STXT, STXXPOS, STXYPOS, STXXPOS + STXWIDTH, STXYPOS + STXHEIGHT, ST_DRAW | ST_FRAME, (void *) &spaceChar, FontScheme2 ); CreateCtrlButtons(ExitStr, LeftArrowStr, NULL, RightArrowStr); }
/******************************************************************************* * Function Name : DrawCross * Description : * Input : - Xpos: Row Coordinate * - Ypos: Line Coordinate * Output : None * Return : None * Attention : None *******************************************************************************/ void DrawCross(uint16_t Xpos,uint16_t Ypos) { LCD_DrawLine(Xpos-15,Ypos,Xpos-2,Ypos,0xffff); LCD_DrawLine(Xpos+2,Ypos,Xpos+15,Ypos,0xffff); LCD_DrawLine(Xpos,Ypos-15,Xpos,Ypos-2,0xffff); LCD_DrawLine(Xpos,Ypos+2,Xpos,Ypos+15,0xffff); LCD_DrawLine(Xpos-15,Ypos+15,Xpos-7,Ypos+15,RGB565CONVERT(184,158,131)); LCD_DrawLine(Xpos-15,Ypos+7,Xpos-15,Ypos+15,RGB565CONVERT(184,158,131)); LCD_DrawLine(Xpos-15,Ypos-15,Xpos-7,Ypos-15,RGB565CONVERT(184,158,131)); LCD_DrawLine(Xpos-15,Ypos-7,Xpos-15,Ypos-15,RGB565CONVERT(184,158,131)); LCD_DrawLine(Xpos+7,Ypos+15,Xpos+15,Ypos+15,RGB565CONVERT(184,158,131)); LCD_DrawLine(Xpos+15,Ypos+7,Xpos+15,Ypos+15,RGB565CONVERT(184,158,131)); LCD_DrawLine(Xpos+7,Ypos-15,Xpos+15,Ypos-15,RGB565CONVERT(184,158,131)); LCD_DrawLine(Xpos+15,Ypos-15,Xpos+15,Ypos-7,RGB565CONVERT(184,158,131)); }
void TouchPanel_Calibrate(void) { unsigned char i; Coordinate * Ptr; for(i=0;i<3;i++) { SSD1289_Clear(Black); SSD1289_CleanText(44,10,"Touch crosshair to calibrate",Red); Delay(250); SSD1289_DrawCross(DisplaySample[i].x,DisplaySample[i].y, Red, RGB565CONVERT(184,158,131)); do { Ptr = Read_XPT2046(); } while( Ptr == (void*)0 ); ScreenSample[i].x= Ptr->x; ScreenSample[i].y= Ptr->y; } setCalibrationMatrix( &DisplaySample[0],&ScreenSample[0],&matrix ); SSD1289_Clear(Black); }
u16 interpolate(u16 c1, u16 c2, float normalized_value) { if( normalized_value <= 0.0 ) { return c1; } if( normalized_value >= 1.0 ) { return c2; } u8 c1_red = (c1 & 0xF800) >> 8; u8 c1_green = (c1 & 0x7E0) >> 3; u8 c1_blue = (c1 & 0x1F) << 3; u8 c2_red = (c2 & 0xF800) >> 8; u8 c2_green = (c2 & 0x7E0) >> 3; u8 c2_blue = (c2 & 0x1F) << 3; uint8_t red = (uint8_t)((1.0-normalized_value)*c1_red + normalized_value*c2_red); uint8_t green = (uint8_t)((1.0-normalized_value)*c1_green + normalized_value*c2_green); uint8_t blue = (uint8_t)((1.0-normalized_value)*c1_blue + normalized_value*c2_blue); return RGB565CONVERT(red, green, blue); }
/************************************************************************ Function: WORD DrawBackgroundColorPalette() Overview: Function that draws a palette on a the screen. Input: None Output: none ************************************************************************/ WORD DrawBackgroundColorPalette() { // This function updates the global color variables: RedPos, GreenPos and BluePos // or draws the RGB color palette. // task meaning // DRAWPALCOLOR create the palette // GETPALCOLOR update the global color based on the x position given // When drawing the RGB color palette. The colors changes in the X direction. Y is not // affecting the colors. Here's how the colors changes: /* |------------------------------ RED --------------------------------| | inc-> | MAX | MAX | dec-> | 0 | 0 | |------------------------------ GREEN ---------------------------------| | 0 | 0 | inc-> | MAX | MAX | dec-> | |------------------------------ BLUE --------------------------------| | MAX | dec-> | 0 | 0 | inc-> | MAX | The light and dark (intensity) effects are also added into the equations. Controls are applied to the global variables RedMax, GreenMax, BlueMax for light effect and RedMin, GreenMin and BlueMin for dark effects. */ WORD red, green, blue, trueXPos, x; for(x = 0; x <= GetMaxX(); x++) { CalculatePaletteColor(&red, &green, &blue, x); //trueXPos = x + PLTXPOS; trueXPos = x; SetColor(RGB565CONVERT((BYTE) red, (BYTE) green, (BYTE) blue)); WAIT_UNTIL_FINISH(Bar(trueXPos, 0, trueXPos, GetMaxY())); } return (1); }
#include "stm32f4xx.h" #include "SSD1963_gradient.h" /* Red-Yellow-Green Gradient color variable */ const u8 RedYellowGreenGradient_Stops = 3; const u16 RedYellowGreenGradient[] = { RGB565CONVERT(228,25,3), RGB565CONVERT(239,154,19), RGB565CONVERT(86,189,19) }; u16 interpolate(u16 c1, u16 c2, float normalized_value) { if( normalized_value <= 0.0 ) { return c1; } if( normalized_value >= 1.0 ) { return c2; } u8 c1_red = (c1 & 0xF800) >> 8; u8 c1_green = (c1 & 0x7E0) >> 3; u8 c1_blue = (c1 & 0x1F) << 3; u8 c2_red = (c2 & 0xF800) >> 8; u8 c2_green = (c2 & 0x7E0) >> 3; u8 c2_blue = (c2 & 0x1F) << 3; uint8_t red = (uint8_t)((1.0-normalized_value)*c1_red + normalized_value*c2_red); uint8_t green = (uint8_t)((1.0-normalized_value)*c1_green + normalized_value*c2_green); uint8_t blue = (uint8_t)((1.0-normalized_value)*c1_blue + normalized_value*c2_blue); return RGB565CONVERT(red, green, blue); } u16 getRgb(u16 min, u16 max, uint16_t value, const u16 *GradientStops, u8 GradientStopsCount) {
/********************************************************************* * Function: void CreateSchemes(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: Create the styles used by the various screens * Since the creation process involves calls * to malloc/free vai the GOL we suspend all * other tasks from executing because the standard * malloc/free are not re-entrant * * Note: ********************************************************************/ void CreateSchemes(void) { vTaskSuspendAll(); // Initialize the GOL GOLInit(); // ANSAbits.ANSA7 = 1; //because GOLInit reinitialise PRESS2 analog input back to digital if(green_sch != NULL) free(green_sch); green_sch = GOLCreateScheme(); green_sch->Color0 = GREEN; green_sch->Color1 = GREEN; green_sch->ColorDisabled = GREEN; green_sch->CommonBkColor = GREEN; green_sch->EmbossDkColor = GREEN; green_sch->EmbossLtColor = GREEN; green_sch->TextColor0 = BLACK; green_sch->TextColor1 = BLACK; green_sch->pFont = (void*)&arial_narrow_0_0_0_14; if(basicscheme != NULL) free(basicscheme); basicscheme = GOLCreateScheme(); basicscheme->Color0 = 11542; basicscheme->Color1 = 64969; basicscheme->ColorDisabled = 55070; basicscheme->CommonBkColor = 59196; basicscheme->EmbossDkColor = 6172; basicscheme->EmbossLtColor = 44765; basicscheme->TextColor0 = 64520; basicscheme->TextColor1 = 31; basicscheme->pFont = (void*)&arial_narrow_0_0_0_14; if(topbar != NULL) free(topbar); topbar = GOLCreateScheme(); topbar->Color0 = BLUE_DARK; topbar->Color1 = BLUE_DARK; topbar->ColorDisabled = GRAY; topbar->TextColorDisabled = GRAY_LIGHT; topbar->CommonBkColor = BLUE_DARK; topbar->EmbossDkColor = BLUE_DARK; topbar->EmbossLtColor = BLUE_DARK; topbar->TextColor0 = WHITE; topbar->TextColor1 = WHITE; // topbar->pFont = (void*)&arial_narrow_0_0_0_14; topbar->pFont = (void*)&Arial_Narrow_26; // if(basicbig != NULL) free(basicbig); // basicbig = GOLCreateScheme(); // basicbig->Color0 = 19583; // basicbig->Color1 = 64969; // basicbig->ColorDisabled = 55070; // basicbig->CommonBkColor = 59196; // basicbig->EmbossDkColor = 6172; // basicbig->EmbossLtColor = 44765; // basicbig->TextColor0 = 64520; // basicbig->TextColor1 = 31; // basicbig->pFont = (void*)&arial_narrow_0_0_0_20; if(defscheme != NULL) free(defscheme); defscheme = GOLCreateScheme(); defscheme->Color0 = WHITE; defscheme->Color1 = GRAY_LIGHT; defscheme->ColorDisabled = 55070; defscheme->CommonBkColor = BLUE_LIGHT; defscheme->EmbossDkColor = BLUE_DARK; defscheme->EmbossLtColor = BLUE_DARK; defscheme->TextColor0 = BLACK; defscheme->TextColor1 = BLACK;//WHITE; defscheme->pFont = (void*)&Arial_Narrow_26; if(botbar != NULL) free(botbar); botbar = GOLCreateScheme(); botbar->Color0 = BLUE_DARK; botbar->Color1 = BLUE_LIGHT; botbar->ColorDisabled = 55070; botbar->CommonBkColor = BLUE_LIGHT; botbar->EmbossDkColor = WHITE; botbar->EmbossLtColor = WHITE; botbar->TextColor0 = WHITE; botbar->TextColor1 = WHITE; botbar->pFont = (void*)&Arial_Narrow_Bold_18; #if 0 // create the display schemes btnSchemeSmall = GOLCreateScheme(); btnSchemeSmall->EmbossDkColor = RGB565CONVERT(0x1E, 0x00, 0xE5); btnSchemeSmall->EmbossLtColor = RGB565CONVERT(0xA9, 0xDB, 0xEF); btnSchemeSmall->TextColor0 = RGB565CONVERT(0x1E, 0x00, 0xE5); btnSchemeSmall->TextColor1 = RGB565CONVERT(0x1E, 0x00, 0xE5); btnSchemeSmall->TextColorDisabled = RGB565CONVERT(0xFF, 0xFF, 0xFF); btnSchemeSmall->Color0 = RGB565CONVERT(0x1E, 0x00, 0xE5); btnSchemeSmall->Color1 = RGB565CONVERT(0x1E, 0x00, 0xE5); btnSchemeSmall->ColorDisabled = RGB565CONVERT(0x1E, 0x00, 0xE5); btnSchemeSmall->CommonBkColor = RGB565CONVERT(0x1E, 0x00, 0xE5); btnSchemeSmall->pFont = (void*) &GOLSmallFont; btnSchemeMedium = GOLCreateScheme(); memcpy(btnSchemeMedium, btnSchemeSmall, sizeof(GOL_SCHEME)); btnSchemeMedium->pFont = (void*) &GOLMediumFont; blueScheme = GOLCreateScheme(); blueScheme->TextColor0 = BLACK; blueScheme->TextColor1 = BLACK; blueScheme->TextColorDisabled = BLACK; greenScheme = GOLCreateScheme(); greenScheme->Color0 = RGB565CONVERT(0x23, 0x9E, 0x0A); greenScheme->Color1 = BRIGHTGREEN; greenScheme->ColorDisabled = RGB565CONVERT(0x23, 0x9E, 0x0A); greenScheme->EmbossDkColor = DARKGREEN; greenScheme->EmbossLtColor = PALEGREEN; greenScheme->TextColor0 = RGB565CONVERT(0xFF, 0xFF, 0xFF); greenScheme->TextColor1 = BLACK; greenScheme->TextColorDisabled = RGB565CONVERT(0xDF, 0xAC, 0x83); redScheme = GOLCreateScheme(); redScheme->Color0 = RGB565CONVERT(0xCC, 0x00, 0x00); redScheme->Color1 = BRIGHTRED; redScheme->EmbossDkColor = RED4; redScheme->EmbossLtColor = FIREBRICK1; redScheme->TextColor0 = RGB565CONVERT(0xC8, 0xD5, 0x85); redScheme->TextColor1 = BLACK; whiteScheme = GOLCreateScheme(); whiteScheme->EmbossDkColor = RGB565CONVERT(0x40, 0x40, 0x40); whiteScheme->EmbossLtColor = RGB565CONVERT(0xE0, 0xE0, 0xE0); whiteScheme->TextColor0 = RGB565CONVERT(0x00, 0x00, 0x00); whiteScheme->TextColor1 = RGB565CONVERT(0x00, 0x00, 0x00); whiteScheme->TextColorDisabled = RGB565CONVERT(0x00, 0x00, 0x00); whiteScheme->Color0 = RGB565CONVERT(0xA0, 0xA0, 0xA0); whiteScheme->Color1 = RGB565CONVERT(0xA0, 0xA0, 0xA0); whiteScheme->ColorDisabled = RGB565CONVERT(0xFF, 0xFF, 0xFF); whiteScheme->CommonBkColor = RGB565CONVERT(0xFF, 0xFF, 0xFF); whiteScheme->pFont = (void*) &GOLFontDefault; #endif blackScheme = GOLCreateScheme(); memcpy(blackScheme, botbar, sizeof(GOL_SCHEME)); blackScheme->Color0 = BLACK; blackScheme->CommonBkColor = BLACK; blackScheme->TextColor0 = RGB565CONVERT(0xFF, 0xFF, 0xFF); blackScheme->TextColor1 = BLACK; // blackScheme->pFont = (void*) &GOLMediumFont; ConfirmShemes(); AlarmShemes(); BolusShemes(); PrimeShemes(); RunShemes(); PwrdownShemes(); xTaskResumeAll(); }