static void calibration_Draw(GL_PageControls_TypeDef* pThis, _Bool force) { if (!force) { return; } // Clear screen GL_Clear(LCD_COLOR_GREY); // Draw title & directions GL_SetFont(GL_FONTOPTION_16x24); GL_SetTextColor(LCD_COLOR_NAVY); GL_PrintString(10, TITLE_TOP, "Calibration Screen", 1); GL_SetFont(GL_FONTOPTION_8x12Bold); // Are we still getting user input? if (currentTouchPoint < TS_NUM_CALIBRATION_POINTS) { GL_PrintString(40, DIRECTIONS_TOP, "Tap the center of the + ...", 1); // Draw cross hairs uint16_t x, y; TS_GetCalibrationTarget(currentTouchPoint, &x, &y); GL_SetTextColor(LCD_COLOR_NAVY); GL_DrawLine(x - TOUCH_POINT_RADIUS, y, TOUCH_POINT_RADIUS * 2, LCD_WriteRAMDir_Right); GL_DrawLine(x, y - TOUCH_POINT_RADIUS, TOUCH_POINT_RADIUS * 2, LCD_WriteRAMDir_Down); } else { // Draw finished directions // (Unused if advancing to other screen immediately) GL_PrintString(40, DIRECTIONS_TOP, "Calibration complete.", 1); GL_PrintString(30, DONE_TOP, "Tap screen to continue", 1); } }
static void showTouches_Draw(GL_PageControls_TypeDef* pThis, _Bool force) { if (!force) { return; } // Clear screen GL_Clear(LCD_COLOR_YELLOW); // Draw title & directions GL_SetFont(GL_FONTOPTION_16x24); GL_SetTextColor(LCD_COLOR_NAVY); GL_PrintString(10, TITLE_TOP, "Check Calibration", 1); GL_SetTextColor(LCD_COLOR_BLACK); GL_SetFont(GL_FONTOPTION_8x12Bold); GL_PrintString(10, DIRECTIONS_TOP, "Tap screen to test touch-screen", 1); GL_PrintString(10, DIRECTIONS_TOP + 12, "calibration and display marker.", 1); GL_SetTextColor(LCD_COLOR_BLUE); GL_PrintString(10, DIRECTIONS_TOP + 30, "Tap same location 3 times to quit.", 1); // Do we have a value to display if (s_haveTouch) { GL_PrintString(30, DISPLAY_TOP, "Coordinates read:", 1); char buf[15]; sprintf(buf, "X Coord: %3d", s_lastTouchX); GL_PrintString(30, DISPLAY_TOP + 12, buf, 1); sprintf(buf, "Y Coord: %3d", s_lastTouchY); GL_PrintString(30, DISPLAY_TOP + 24, buf, 1); // Draw cross hairs GL_SetTextColor(LCD_COLOR_NAVY); GL_DrawLine(s_lastTouchX - TOUCH_POINT_RADIUS, s_lastTouchY, TOUCH_POINT_RADIUS * 2, LCD_WriteRAMDir_Right); GL_DrawLine(s_lastTouchX, s_lastTouchY - TOUCH_POINT_RADIUS, TOUCH_POINT_RADIUS * 2, LCD_WriteRAMDir_Down); } }
/* =================== R_ColorByStencilBuffer Sets the screen colors based on the contents of the stencil buffer. Stencil of 0 = black, 1 = red, 2 = green, 3 = blue, ..., 7+ = white =================== */ static void R_ColorByStencilBuffer() { int i; static float colors[8][3] = { {0,0,0}, {1,0,0}, {0,1,0}, {0,0,1}, {0,1,1}, {1,0,1}, {1,1,0}, {1,1,1}, }; // clear color buffer to white (>6 passes) GL_Clear( true, false, false, 0, 1.0f, 1.0f, 1.0f, 1.0f ); // now draw color for each stencil value qglStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); for ( i = 0; i < 6; i++ ) { GL_Color( colors[i] ); renderProgManager.BindShader_Color(); qglStencilFunc( GL_EQUAL, i, 255 ); RB_PolygonClear(); } qglStencilFunc( GL_ALWAYS, 0, 255 ); }
// Change to a new screen. void Screen_ShowScreen(GL_Page_TypeDef *pNewScreen) { debug(GUI, "Screen_ShowScreen:1\n"); assert(pNewScreen != 0); // Break out if already on this screen. debug(GUI, "Screen_ShowScreen:2\n"); if (pNewScreen == s_pCurrentScreen) { debug(GUI, "Screen_ShowScreen:3\n"); return; } debug(GUI, "Screen_ShowScreen:4\n"); if (s_pCurrentScreen != 0) { debug(GUI, "Screen_ShowScreen:5\n"); s_pCurrentScreen->ShowPage(s_pCurrentScreen, GL_FALSE); debug(GUI, "Screen_ShowScreen:6\n"); } GL_Clear(LCD_COLOR_BLACK); GL_SetBackColor(LCD_COLOR_BLACK); GL_SetTextColor(LCD_COLOR_WHITE); // Second parameter as true forces the screen to redraw itself // as opposed to allowing it choose what to redraw based on need. pNewScreen->ShowPage(pNewScreen, GL_TRUE); debug(GUI, "Screen_ShowScreen:7\n"); s_pCurrentScreen = pNewScreen; debug(GUI, "Screen_ShowScreen:8\n"); // set default waterfall/spectrum display }
/** * @brief Error callback function * @param None * @retval None */ void vApplicationMallocFailedHook( void ) { char temp[128]; GL_Clear(Black); GL_SetTextColor(GL_White); GL_SetFont(GL_FONT_SMALL); sprintf(temp, "Actual heap size : %d Bytes" , (int)xPortGetFreeHeapSize() ); GL_DisplayAdjStringLine(214, 310, (uint8_t *)"[Memory Error]", GL_TRUE); GL_DisplayAdjStringLine(227, 310, (uint8_t *)temp, GL_TRUE); while (1) {} }
/** * @brief Initialize the screen and display the main menu * @param None * @retval None */ uint32_t GL_Init (void) { /* Clear the screen */ GL_Clear(GL_White); xTaskCreate(Time_Task, (signed char const*)"TIME_B", configMINIMAL_STACK_SIZE, NULL, Time_Task_PRIO, &Core_Time_Task_Handle); /* Menu Initialisation*/ GL_ShowMainMenu(); return 0; }
/** * @brief display the initialization page * @param None * @retval None */ void GL_Startup (void) { uint8_t cnt = 0; GL_Clear(GL_White); GL_DrawButtonBMP( 210, 110, 148, (LCD_Height / 10)*2, (uint8_t*) STM32Logo ); for ( ; cnt < 2; cnt ++) { GL_DisplayAdjStringLine(144, 250, (uint8_t *)"STM32 System Initializing. ", GL_FALSE); GL_Delay(100); GL_DisplayAdjStringLine(144, 250, (uint8_t *)"STM32 System Initializing.. ", GL_FALSE); GL_Delay(100); GL_DisplayAdjStringLine(144, 250, (uint8_t *)"STM32 System Initializing...", GL_FALSE); GL_Delay(100); } }
/* ================= RB_ShowLightCount This is a debugging tool that will draw each surface with a color based on how many lights are effecting it ================= */ static void RB_ShowLightCount() { int i; const drawSurf_t *surf; const viewLight_t *vLight; if ( !r_showLightCount.GetBool() ) { return; } RB_SimpleWorldSetup(); GL_Clear( false, false, true, 0, 0.0f, 0.0f, 0.0f, 0.0f ); // optionally count everything through walls if ( r_showLightCount.GetInteger() >= 2 ) { GL_State( GLS_DEPTHFUNC_EQUAL | GLS_STENCIL_OP_FAIL_KEEP | GLS_STENCIL_OP_ZFAIL_INCR | GLS_STENCIL_OP_PASS_INCR ); } else { GL_State( GLS_DEPTHFUNC_EQUAL | GLS_STENCIL_OP_FAIL_KEEP | GLS_STENCIL_OP_ZFAIL_KEEP | GLS_STENCIL_OP_PASS_INCR ); } globalImages->defaultImage->Bind(); for ( vLight = backEnd.viewDef->viewLights; vLight; vLight = vLight->next ) { for ( i = 0; i < 2; i++ ) { for ( surf = i ? vLight->localInteractions: vLight->globalInteractions; surf; surf = (drawSurf_t *)surf->nextOnLight ) { RB_SimpleSurfaceSetup( surf ); RB_DrawElementsWithCounters( surf ); } } } // display the results R_ColorByStencilBuffer(); if ( r_showLightCount.GetInteger() > 2 ) { RB_CountStencilBuffer(); } }
/** * @brief Display the main menu * @param None * @retval None */ void GL_ShowMainMenu(void) { uint8_t TempStr[25]; RTC_TimeTypeDef RTC_TimeStructure; RTC_DateTypeDef RTC_DateStructure; GL_PageControls_TypeDef *Icon , *LabelTime , *LabelDate, *LabelBkgnd; uint8_t sec, min, hour, day, month; uint16_t year; GL_Clear(White); GL_HomePage = malloc(sizeof(GL_Page_TypeDef)); Create_PageObj( GL_HomePage, HOME_PAGE_ID ); /* Add group icons */ Icon = NewIcon(2 , Group_Connectivity_icon, BF_XSIZE, BF_YSIZE ,GL_ShowConnectivityGroup ); AddPageControlObj(305, 40, Icon, GL_HomePage ); Icon = NewIcon(3 , Group_Multimedia_icon, BF_XSIZE, BF_YSIZE ,GL_ShowMultimediaGroup ); AddPageControlObj(305, 103, Icon, GL_HomePage ); Icon = NewIcon(4 , Group_System_icon, BF_XSIZE, BF_YSIZE ,GL_ShowUtilitiesGroup ); AddPageControlObj(305, 166, Icon, GL_HomePage ); Icon = NewIcon(32 , STLogo, 40, 22 ,MOD_NullFunc ); AddPageControlObj(240, 216, Icon, GL_HomePage ); LabelBkgnd = NewLabel(33, (uint8_t *)"",GL_HORIZONTAL,GL_FONT_SMALL,GL_Red, GL_FALSE); AddPageControlObj(195, 227, LabelBkgnd, GL_HomePage); /* add modules */ switch(GL_Group) { case CONNECTIVITY_GROUP : GL_ShowConnectivityGroup(); break; case MULTIMEDIA_GROUP : GL_ShowMultimediaGroup(); break; case UTILITIES_GROUP : GL_ShowUtilitiesGroup(); break; } GL_HomePage->CustomPreDraw = DrawBackgroundZone; /* time section */ /* Get info from RTC here */ RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure); sec = RTC_TimeStructure.RTC_Seconds; min = RTC_TimeStructure.RTC_Minutes; hour = RTC_TimeStructure.RTC_Hours; sprintf((char *)TempStr, "%02d:%02d:%02d", hour , min, sec); LabelTime = NewLabel(30,TempStr,GL_HORIZONTAL,GL_FONT_SMALL,0x1253, GL_FALSE); AddPageControlObj(60, 215, LabelTime, GL_HomePage); RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure); year = RTC_DateStructure.RTC_Year + 2000; month = RTC_DateStructure.RTC_Month; day = RTC_DateStructure.RTC_Date; sprintf((char *)TempStr, "%02d %s %04d", day , strMonth[month-1], year); LabelDate = NewLabel(31,TempStr,GL_HORIZONTAL,GL_FONT_SMALL,0x1253, GL_FALSE); AddPageControlObj(88, 227, LabelDate, GL_HomePage); RefreshPage(GL_HomePage); vTaskResume(Core_Time_Task_Handle); Global_Config.b.Force_Background_Refresh = 1; }
/** * @brief Calibrate TouchScreen coordinates by LCD touch in 5 points * @param None * @retval None */ void TS_Calibration(void) { uint32_t coordinate_X1a = 0, coordinate_X2a = 0, coordinate_X3a = 0, coordinate_X4a = 0, coordinate_X5a = 0; uint32_t coordinate_Y1a = 0, coordinate_Y2a = 0, coordinate_Y3a = 0, coordinate_Y4a = 0, coordinate_Y5a = 0; uint32_t coordinate_X1b = 0, coordinate_X2b = 0, coordinate_X3b = 0, coordinate_X4b = 0, coordinate_X5b = 0; uint32_t coordinate_Y1b = 0, coordinate_Y2b = 0, coordinate_Y3b = 0, coordinate_Y4b = 0, coordinate_Y5b = 0; uint32_t coordinate_X1 = 0, coordinate_X2 = 0, coordinate_X3 = 0, coordinate_X4 = 0, coordinate_X5 = 0; uint32_t coordinate_Y1 = 0, coordinate_Y2 = 0, coordinate_Y3 = 0, coordinate_Y4 = 0, coordinate_Y5 = 0; uint16_t Xd1 = (LCD_Width / 2), Xd2 = 1 * (LCD_Width / 5), Xd3 = 4 * (LCD_Width / 5), Xd4 = 4 * (LCD_Width / 5), Xd5 = 1 * (LCD_Width / 5); uint16_t Yd1 = (LCD_Height / 2), Yd2 = 1 * (LCD_Height / 5), Yd3 = 1 * (LCD_Height / 5), Yd4 = 4 * (LCD_Height / 5), Yd5 = 4 * (LCD_Height / 5); double A = 0.0, B = 0.0, C = 0.0, D = 0.0, E = 0.0, F = 0.0; double d = 0.0, dx1 = 0.0, dx2 = 0.0, dx3 = 0.0, dy1 = 0.0, dy2 = 0.0, dy3 = 0.0; uint32_t X2_1 = 0, X2_2 = 0, X2_3 = 0, X2_4 = 0, X2_5 = 0; uint32_t Y2_1 = 0, Y2_2 = 0, Y2_3 = 0, Y2_4 = 0, Y2_5 = 0; uint32_t XxY_1 = 0, XxY_2 = 0, XxY_3 = 0, XxY_4 = 0, XxY_5 = 0; uint32_t XxXd_1 = 0, XxXd_2 = 0, XxXd_3 = 0, XxXd_4 = 0, XxXd_5 = 0; uint32_t YxXd_1 = 0, YxXd_2 = 0, YxXd_3 = 0, YxXd_4 = 0, YxXd_5 = 0; uint32_t XxYd_1 = 0, XxYd_2 = 0, XxYd_3 = 0, XxYd_4 = 0, XxYd_5 = 0; uint32_t YxYd_1 = 0, YxYd_2 = 0, YxYd_3 = 0, YxYd_4 = 0, YxYd_5 = 0; uint32_t alfa = 0, beta = 0, chi = 0, Kx = 0, Ky = 0, Lx = 0, Ly = 0; uint16_t epsilon = 0, fi = 0, Mx = 0, My = 0; GL_SetBackColor(GL_White); GL_SetTextColor(GL_Black); GL_Clear(White); GL_DisplayAdjStringLine(3 * (LCD_Height / 7), LCD_Width - 25, "Run Calibration.", GL_FALSE); GL_Delay(40); GL_DisplayAdjStringLine(3 * (LCD_Height / 7), LCD_Width - 25, "Run Calibration..", GL_FALSE); GL_Delay(40); GL_DisplayAdjStringLine(3 * (LCD_Height / 7), LCD_Width - 25, "Run Calibration...", GL_FALSE); GL_Delay(30); touch_done = 0; GL_Clear(White); GL_Cross( (LCD_Height / 2), (LCD_Width / 2) ); /* Absolute Central Point */ while ( touch_done == 0) { TSC_Read(); } coordinate_X1a = TSC_Value_X; coordinate_Y1a = TSC_Value_Y; GL_Delay(90); /* This is to catch only one touch event */ TSC_Init(); touch_done = 0; GL_Clear(White); GL_Cross(1*(LCD_Height / 5), 1*(LCD_Width / 5)); /* Nord-East Corner point */ while ( touch_done == 0) { TSC_Read(); } coordinate_X2a = TSC_Value_X; coordinate_Y2a = TSC_Value_Y; GL_Delay(90); /* This is to catch only one touch event */ TSC_Init(); touch_done = 0; GL_Clear(White); GL_Cross(1*(LCD_Height / 5), 4*(LCD_Width / 5)); /* Nord-West Corner */ while ( touch_done == 0) { TSC_Read(); } coordinate_X3a = TSC_Value_X; coordinate_Y3a = TSC_Value_Y; GL_Delay(90); /* This is to catch only one touch event */ TSC_Init(); touch_done = 0; GL_Clear(White); GL_Cross(4*(LCD_Height / 5), 4*(LCD_Width / 5)); /* Sud-West Corner */ while ( touch_done == 0) { TSC_Read(); } coordinate_X4a = TSC_Value_X; coordinate_Y4a = TSC_Value_Y; GL_Delay(90); /* This is to catch only one touch event */ TSC_Init(); touch_done = 0; GL_Clear(White); GL_Cross(4*(LCD_Height / 5), 1*(LCD_Width / 5)); /* Sud-East Corner point */ while ( touch_done == 0) { TSC_Read(); } coordinate_X5a = TSC_Value_X; coordinate_Y5a = TSC_Value_Y; GL_Delay(90); /* This is to catch only one touch event */ TSC_Init(); touch_done = 0; GL_Clear(White); GL_Cross( (LCD_Height / 2), (LCD_Width / 2) ); /* Absolute Central Point */ while ( touch_done == 0) { TSC_Read(); } coordinate_X1b = TSC_Value_X; coordinate_Y1b = TSC_Value_Y; GL_Delay(90); /* This is to catch only one touch event */ TSC_Init(); touch_done = 0; GL_Clear(White); GL_Cross(1*(LCD_Height / 5), 1*(LCD_Width / 5)); /* Nord-East Corner point */ while ( touch_done == 0) { TSC_Read(); } coordinate_X2b = TSC_Value_X; coordinate_Y2b = TSC_Value_Y; GL_Delay(90); /* This is to catch only one touch event */ TSC_Init(); touch_done = 0; GL_Clear(White); GL_Cross(1*(LCD_Height / 5), 4*(LCD_Width / 5)); /* Nord-West Corner */ while ( touch_done == 0) { TSC_Read(); } coordinate_X3b = TSC_Value_X; coordinate_Y3b = TSC_Value_Y; GL_Delay(90); /* This is to catch only one touch event */ TSC_Init(); touch_done = 0; GL_Clear(White); GL_Cross(4*(LCD_Height / 5), 4*(LCD_Width / 5)); /* Sud-West Corner */ while ( touch_done == 0) { TSC_Read(); } coordinate_X4b = TSC_Value_X; coordinate_Y4b = TSC_Value_Y; GL_Delay(90); /* This is to catch only one touch event */ TSC_Init(); touch_done = 0; GL_Clear(White); GL_Cross(4*(LCD_Height / 5), 1*(LCD_Width / 5)); /* Sud-East Corner point */ while ( touch_done == 0) { TSC_Read(); } coordinate_X5b = TSC_Value_X; coordinate_Y5b = TSC_Value_Y; GL_Delay(90); /* This is to catch only one touch event */ TSC_Init(); touch_done = 0; /* Average between X and Y coupled Touchscreen values */ coordinate_X1 = (coordinate_X1a + coordinate_X1b) / 2; coordinate_X2 = (coordinate_X2a + coordinate_X2b) / 2; coordinate_X3 = (coordinate_X3a + coordinate_X3b) / 2; coordinate_X4 = (coordinate_X4a + coordinate_X4b) / 2; coordinate_X5 = (coordinate_X5a + coordinate_X5b) / 2; coordinate_Y1 = (coordinate_Y1a + coordinate_Y1b) / 2; coordinate_Y2 = (coordinate_Y2a + coordinate_Y2b) / 2; coordinate_Y3 = (coordinate_Y3a + coordinate_Y3b) / 2; coordinate_Y4 = (coordinate_Y4a + coordinate_Y4b) / 2; coordinate_Y5 = (coordinate_Y5a + coordinate_Y5b) / 2; X2_1 = (coordinate_X1 * coordinate_X1); X2_2 = (coordinate_X2 * coordinate_X2); X2_3 = (coordinate_X3 * coordinate_X3); X2_4 = (coordinate_X4 * coordinate_X4); X2_5 = (coordinate_X5 * coordinate_X5); Y2_1 = (coordinate_Y1 * coordinate_Y1); Y2_2 = (coordinate_Y2 * coordinate_Y2); Y2_3 = (coordinate_Y3 * coordinate_Y3); Y2_4 = (coordinate_Y4 * coordinate_Y4); Y2_5 = (coordinate_Y5 * coordinate_Y5); XxY_1 = (coordinate_X1 * coordinate_Y1); XxY_2 = (coordinate_X2 * coordinate_Y2); XxY_3 = (coordinate_X3 * coordinate_Y3); XxY_4 = (coordinate_X4 * coordinate_Y4); XxY_5 = (coordinate_X5 * coordinate_Y5); XxXd_1 = ( coordinate_X1 * Xd1 ); XxXd_2 = ( coordinate_X2 * Xd2 ); XxXd_3 = ( coordinate_X3 * Xd3 ); XxXd_4 = ( coordinate_X4 * Xd4 ); XxXd_5 = ( coordinate_X5 * Xd5 ); YxXd_1 = ( coordinate_Y1 * Xd1 ); YxXd_2 = ( coordinate_Y2 * Xd2 ); YxXd_3 = ( coordinate_Y3 * Xd3 ); YxXd_4 = ( coordinate_Y4 * Xd4 ); YxXd_5 = ( coordinate_Y5 * Xd5 ); XxYd_1 = ( coordinate_X1 * Yd1 ); XxYd_2 = ( coordinate_X2 * Yd2 ); XxYd_3 = ( coordinate_X3 * Yd3 ); XxYd_4 = ( coordinate_X4 * Yd4 ); XxYd_5 = ( coordinate_X5 * Yd5 ); YxYd_1 = ( coordinate_Y1 * Yd1 ); YxYd_2 = ( coordinate_Y2 * Yd2 ); YxYd_3 = ( coordinate_Y3 * Yd3 ); YxYd_4 = ( coordinate_Y4 * Yd4 ); YxYd_5 = ( coordinate_Y5 * Yd5 ); alfa = X2_1 + X2_2 + X2_3 + X2_4 + X2_5; beta = Y2_1 + Y2_2 + Y2_3 + Y2_4 + Y2_5; chi = XxY_1 + XxY_2 + XxY_3 + XxY_4 + XxY_5; epsilon = coordinate_X1 + coordinate_X2 + coordinate_X3 + coordinate_X4 + coordinate_X5; fi = coordinate_Y1 + coordinate_Y2 + coordinate_Y3 + coordinate_Y4 + coordinate_Y5; Kx = XxXd_1 + XxXd_2 + XxXd_3 + XxXd_4 + XxXd_5; Ky = XxYd_1 + XxYd_2 + XxYd_3 + XxYd_4 + XxYd_5; Lx = YxXd_1 + YxXd_2 + YxXd_3 + YxXd_4 + YxXd_5; Ly = YxYd_1 + YxYd_2 + YxYd_3 + YxYd_4 + YxYd_5; Mx = Xd1 + Xd2 + Xd3 + Xd4 + Xd5; My = Yd1 + Yd2 + Yd3 + Yd4 + Yd5; d = 5 * ( ((double)alfa * beta) - ((double)chi * chi) ) + 2 * ((double)chi * epsilon * fi) - ((double)alfa * fi * fi ) - ( (double)beta * epsilon * epsilon ); dx1 = 5 * ( ((double)Kx * beta) - ((double)Lx * chi) ) + ((double)fi * ( ((double)Lx * epsilon) - ((double)Kx * fi) )) + ((double)Mx * ( ((double)chi * fi) - ((double)beta * epsilon) )); dx2 = 5 * ( ((double)Lx * alfa) - ((double)Kx * chi) ) + ((double)epsilon * ( ((double)Kx * fi) - ((double)Lx * epsilon) )) + ((double)Mx * ( ((double)chi * epsilon) - ((double)alfa * fi) )); dx3 = ((double)Kx * ( ((double)chi * fi) - ((double)beta * epsilon) )) + ((double)Lx * ( ((double)chi * epsilon) - ((double)alfa * fi) )) + ((double)Mx * ( ((double)alfa * beta) - ((double)chi * chi) )); dy1 = 5 * ( ((double)Ky * beta) - ((double)Ly * chi) ) + ((double)fi * ( ((double)Ly * epsilon) - ((double)Ky * fi) )) + ((double)My * ( ((double)chi * fi) - ((double)beta * epsilon) )); dy2 = 5 * ( ((double)Ly * alfa) - ((double)Ky * chi) ) + ((double)epsilon * ( ((double)Ky * fi) - ((double)Ly * epsilon) )) + ((double)My * ( ((double)chi * epsilon) - ((double)alfa * fi) )); dy3 = ((double)Ky * ( ((double)chi * fi) - ((double)beta * epsilon) )) + ((double)Ly * ( ((double)chi * epsilon) - ((double)alfa * fi) )) + ((double)My * ( ((double)alfa * beta) - ((double)chi * chi) )); A = dx1 / d; B = dx2 / d; C = dx3 / d; D = dy1 / d; E = dy2 / d; F = dy3 / d; /* To avoid computation with "double" variables A, B, C, D, E, F, we use the s32 variables A2, B2, C2, D2, E2, F2, multiplied for a Scale Factor equal to 100000 to retain the precision*/ A2 = (s32)(A * RESCALE_FACTOR); B2 = (s32)(B * RESCALE_FACTOR); C2 = (s32)(C * RESCALE_FACTOR); D2 = (s32)(D * RESCALE_FACTOR); E2 = (s32)(E * RESCALE_FACTOR); F2 = (s32)(F * RESCALE_FACTOR); GL_Clear(White); GL_DisplayAdjStringLine(3 * (LCD_Height / 7), 10 * (LCD_Width / 11), "Calibration done!", GL_FALSE); GL_Delay(25); /* Now show HOME Menu */ GL_Clear(White); calibration_done = 1; /********************* FLASH PROGRAMMING FOR SAVING "calibration_done" variable **********************/ TSC_FlashStatus = TSC_FLASH_COMPLETE; TSC_MemoryProgramStatus = PASSED; FlashFree_Address = CalibrationAddr; /* Unlock the Flash Program Erase controller */ TSC_FLASH_Unlock(); /* Erase Flash sectors ******************************************************/ #if defined(USE_STM3210C_EVAL) || defined(USE_STM32100E_EVAL) || defined(USE_STM3220F_EVAL) /* Clear All pending flags */ TSC_FLASH_ClearFlag( TSC_FLASH_FLAG_BSY | TSC_FLASH_FLAG_EOP | TSC_FLASH_FLAG_PGERR | TSC_FLASH_FLAG_WRPRTERR); /* Erase Last Flash Page */ TSC_FlashStatus = TSC_FLASH_ErasePage( FlashFree_Address ); #endif /* Writing calibration parameters to the Flash Memory */ TSC_FlashStatus = TSC_FLASH_ProgramWord( FlashFree_Address, calibration_done); /* Increasing Flash Memory Page Address */ FlashFree_Address = FlashFree_Address + 4; /* Writing Calibration Parameter */ TSC_FlashStatus = TSC_FLASH_ProgramWord( FlashFree_Address, A2); /* Increasing Flash Memory Page Address */ FlashFree_Address = FlashFree_Address + 4; /* Writing Calibration Parameter */ TSC_FlashStatus = TSC_FLASH_ProgramWord( FlashFree_Address, B2); /* Increasing Flash Memory Page Address */ FlashFree_Address = FlashFree_Address + 4; /* Writing Calibration Parameter */ TSC_FlashStatus = TSC_FLASH_ProgramWord( FlashFree_Address, C2); /* Increasing Flash Memory Page Address */ FlashFree_Address = FlashFree_Address + 4; /* Writing Calibration Parameter */ TSC_FlashStatus = TSC_FLASH_ProgramWord( FlashFree_Address, D2); /* Increasing Flash Memory Page Address */ FlashFree_Address = FlashFree_Address + 4; /* Writing Calibration Parameter */ TSC_FlashStatus = TSC_FLASH_ProgramWord( FlashFree_Address, E2); /* Increasing Flash Memory Page Address */ FlashFree_Address = FlashFree_Address + 4; /* Writing Calibration Parameter */ TSC_FlashStatus = TSC_FLASH_ProgramWord( FlashFree_Address, F2); /* Increasing Flash Memory Page Address */ FlashFree_Address = FlashFree_Address + 4; /* Reading Calibration Flag from the Flash Memory */ calibration_done = (*(__IO uint32_t*) CalibrationAddr) & 0x000000FF; }