void DemoCpuTemperature(void) { uint16 i,y; LCD_ClearScreen(); LCD_SetPenColor(1); LCD_SetFont(1); LCD_PrintXY(40,0,"CPU:"); LCD_PrintXY(80,0,TempString); LCD_SetFont(0); LCD_PrintXY(0,0, "60-"); LCD_PrintXY(0,18,"50-"); LCD_PrintXY(0,37,"40-"); LCD_PrintXY(0,56,"30-"); LCD_DrawLine(15,0,15,63); for(i=16;i<128;i++) { y = DemoMem[127-i]; if(y > 290) { y = ((y - 290) / 5); y = 64 - y; LCD_PutPixel(i,y,1); LCD_PutPixel(i,y+1,1); } } }
/******************************************************************************* * Function Name : DrawClear_iLine * Description : отрисовка или очистка одной линии при линейной интерполяции * Input : X0pos, Y0pos, X1pos, Y1pos, clear * Return : None *******************************************************************************/ static __inline void DrawClear_MAXMIN_Line(uint16_t X0pos, uint16_t Y0pos, uint16_t Y1pos, DrawState NewDrawState) { uint16_t tmL = 0, tmpY; uint16_t clrColor; // цвет очистки int16_t Length; // длинна линни для отрисовки/очистки if(Y1pos < Y0pos){ tmpY = Y0pos; Y0pos = Y1pos; Y1pos = tmpY; } Set_LCD_CS(); // установить низкий уровень CS LCD // используем "низкоуровневый" доступ к ЖК для макс. скорости LCD_SetCursor(X0pos, Y0pos); Length = Y1pos - Y0pos; if((Length <= 0) || (Length > 190)) Length = 1; if(NewDrawState == CLEAR) { while(tmL++ != Length) // очищаем линию от минимума до максимума { /* Проверяем на совпадение координат очистки с сеткой, если совпало то очищаем цветом сетки */ clrColor = Verify_Grid_Match(X0pos, Y0pos + tmL - 1); LCD_PutPixel(clrColor); } } else // if(NewDrawState == DRAW) { while(tmL++ != Length) LCD_PutPixel(pINFO->Color); // Нарисовать точку на установленной позиции } Reset_LCD_CS(); }
void CpuTemperatureView(void) { uint16_t i,y; MEASUREMENT_VIEW_struct * viewMem = cpu_temp_getViewMem(); LCD_ClearScreen(); LCD_SetPenColor(1); LCD_SetFont(1); LCD_PrintXY(40,0,"CPU:"); LCD_PrintXY(80,0,viewMem->cur_value); LCD_SetFont(0); LCD_PrintXY(0,0, "60-"); LCD_PrintXY(0,18,"50-"); LCD_PrintXY(0,37,"40-"); LCD_PrintXY(0,56,"30-"); LCD_DrawLine(15,0,15,63); for(i=16;i<128;i++) { y = viewMem->Mem[127-i]; if(y > 290) { y = ((y - 290) / 5); y = 64 - y; LCD_PutPixel(i,y,1); LCD_PutPixel(i,y+1,1); } } }
/******************************************************************************* * Function Name : DrawClear_iLine * Description : отрисовка или очистка одной линии при линейной интерполяции * Input : X0pos, Y0pos, X1pos, Y1pos, clear * Return : None *******************************************************************************/ static __inline void DrawClear_iLine(uint16_t X0pos, uint16_t Y0pos, uint16_t Y1pos, DrawState NewDrawState) { uint16_t clrColor; uint16_t i, j; uint16_t tmpY; if(Y1pos < Y0pos){ tmpY = Y0pos; Y0pos = Y1pos; Y1pos = tmpY; } if(Y1pos - Y0pos == 0) j = 1; else j = Y1pos - Y0pos; Set_LCD_CS(); LCD_SetCursor(X0pos,Y0pos); // Установка курсора в нужную позицию if(NewDrawState == CLEAR) { for (i = 0; i < j; i++) { /* Проверяем на совпадение координат очистки с сеткой, если совпало то очищаем цветом сетки */ clrColor = Verify_Grid_Match(X0pos, Y0pos); LCD_PutPixel(clrColor); // очистить точку на установленной позиции Y0pos++; } } else // if(NewDrawState == DRAW) { for (i = 0; i < j; i++) LCD_PutPixel(pINFO->Color); // Нарисовать точку на установленной позиции } Reset_LCD_CS(); }
void AbgasTemperatureView(void) { uint16_t i,y; MEASUREMENT_VIEW_struct * viewMem = pt100_getViewMem(); LCD_ClearScreen(); LCD_SetPenColor(1); LCD_SetFont(0); LCD_PrintXY(30,0,"ABGAS:"); LCD_PrintXY(80,0,viewMem->cur_value); LCD_SetFont(0); int max = roundUp(viewMem->max); int min = roundDown(viewMem->min); int diff = max-min; int span; if(!diff) { span = 10; if(min) min -= 10; }else { span = diff/3; } if(span < 10) span = 10; char dummy[10]; sprintf(dummy,"%4u-",min+(span*3)); LCD_PrintXY(0,0, dummy); sprintf(dummy,"%4u-",min+(span*2)); LCD_PrintXY(0,18,dummy); sprintf(dummy,"%4u-",min+(span*1)); LCD_PrintXY(0,37,dummy); sprintf(dummy,"%4u-",min); LCD_PrintXY(0,56,dummy); LCD_DrawLine(27,0,27,63); diff = (span*3); for(i=27;i<128;i++) { y = viewMem->Mem[127-i]; y = 64 - ((double)(y-min)*(double)(64.0/diff)); LCD_PutPixel(i,y,1); LCD_PutPixel(i,y+1,1); } }
/******************************************************************************* * Function Name : LCD_Circle * Description : Draws circle with radius r and center in (x,y) point. * Input : õ - center x-coordinate * : y - center y-coordinate * : r - radius (in pixels)s * Output : None * Return : None *******************************************************************************/ void LCD_Circle(uint32_t xc, uint32_t yc, uint32_t r) { int32_t d, x, y; for (x = 0, y = r, d = 3-2*r; ;) { LCD_PutPixel(x+xc, y+yc); LCD_PutPixel(x+xc, -y+yc); LCD_PutPixel(-x+xc, -y+yc); LCD_PutPixel(-x+xc, y+yc); LCD_PutPixel(y+xc, x+yc); LCD_PutPixel(y+xc, -x+yc); LCD_PutPixel(-y+xc, -x+yc); LCD_PutPixel(-y+xc, x+yc); if (x >= y) { break; } if (d <= 0) { d += 4*x+6; } else { d += 4*(x-y)+10; y--; } x++; } }
//-------------------------------------------------------// // Draws horizontal line with penColor //-------------------------------------------------------// void LCD_DrawHorLine(uint16_t x, uint16_t y, uint16_t length) { uint8_t dashCompare; uint8_t dashPeriod; uint8_t dashCounter = 0; switch(lineStyle) { case LINE_STYLE_DASHED: dashPeriod = LCD_DASH_PERIOD; dashCompare = LCD_DASH_COMPARE; break; case LINE_STYLE_DOTTED: dashPeriod = LCD_DOT_PERIOD; dashCompare = LCD_DOT_COMPARE; break; default: //LINE_STYLE_SOLID: dashPeriod = 10; dashCompare = 10; // arbitrary, but >= dashPeriod break; } while(length--) { if (dashCounter < dashCompare) LCD_PutPixel(x,y,penColor); x++; dashCounter++; if (dashCounter == dashPeriod) dashCounter = 0; } }
/*! Вывод диаграммы на экран \param[in] *chart Указатель на объект диаграммы */ void guiChartDraw(GUI_CHART * chart) { uint16_t i; //uint16_t xGridSpace, yGridSpace; if (chart->wmObj.Visible) { // Axes LCD_SetTextColor(chart->wmObj.BorderColor); LCD_DrawLine(chart->wmObj.xPos, chart->wmObj.yPos, chart->wmObj.Height, LCD_DIR_VERTICAL); LCD_DrawLine(chart->wmObj.xPos, chart->wmObj.yPos + chart->wmObj.Height-1, chart->wmObj.Width, LCD_DIR_HORIZONTAL); LCD_SetTextColor(chart->wmObj.Color); LCD_DrawFillRect(chart->wmObj.xPos+1, chart->wmObj.yPos, chart->wmObj.Width - 1, chart->wmObj.Height - 1); // Grid Lines // Graph LCD_SetTextColor(chart->LineColor); for (i = 0; i < chart->wmObj.Width-1; i++) { if (chart->table[i] > chart->wmObj.Height-1) chart->table[i] = chart->wmObj.Height-11; if (chart->Dot_nLine) // dot graph LCD_PutPixel(chart->wmObj.xPos+1+i, chart->wmObj.yPos + chart->wmObj.Height - 1 - chart->table[i]); else // line graph (histogram) LCD_DrawLine(chart->wmObj.xPos+1+i, chart->wmObj.yPos + chart->wmObj.Height - 1 - chart->table[i], chart->table[i], LCD_DIR_VERTICAL); } } }
/******************************************************************************* * Function Name : Clear_OLD_Data_MIN_MAX * Description : очистка, режим максимумов/минимумов * Input : None * Return : None *******************************************************************************/ static void Clear_OLD_Data_MIN_MAX(uint16_t X0, uint16_t X1) { uint16_t cnt_, point = X0 - leftLimit, tmL, Length, clrColor; uint16_t num = (X1 - X0) * 2; /* Очищаем старую осциллограмму */ Set_LCD_CS(); for (cnt_ = (point * 2); cnt_ < num; cnt_ += 2) { if(pINFO->OldData_PointsFlag[point] == ENABLE) { LCD_SetCursor(point + leftLimit + 1, pINFO->visDATA[cnt_]); Length = fabs(pINFO->visDATA[cnt_+1] - pINFO->visDATA[cnt_]); if((Length < 1) || (Length > 190)) Length = 1; tmL = 0; /* очищаем линию от минимума до максимума */ while(tmL++ != Length) { /* Проверяем на совпадение координат очистки с сеткой, если совпало то очищаем цветом сетки */ clrColor = Verify_Grid_Match(point + leftLimit + 1, pINFO->visDATA[cnt_] + tmL - 1); LCD_PutPixel(clrColor); } } pINFO->OldData_PointsFlag[point] = DISABLE; point++; } Reset_LCD_CS(); }
//-------------------------------------------------------// // Fills a rectangle with fillColor //-------------------------------------------------------// void LCD_FillRect(rect_t* rect) { uint16_t x,y; rect_t drawRect = *rect; for (x=drawRect.x1; x<=drawRect.x2; x++) for (y=drawRect.y1; y<=drawRect.y2; y++) LCD_PutPixel(x,y,fillColor); }
void DrawLine(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned char color) { int dy ; int dx ; int step_x, step_y, fraction; dy = y2 - y1; dx = x2 - x1; if (dy < 0) { dy = -dy; step_y = -1; } else { step_y = 1; } if (dx < 0) { dx = -dx; step_x = -1; } else { step_x = 1; } dy <<= 1; dx <<= 1; LCD_PutPixel(x1,y1,color); if (dx > dy) { fraction = dy - (dx >> 1); while (x1 != x2) { if (fraction >= 0) { y1 += step_y; fraction -= dx; } x1 += step_x; fraction += dy; LCD_PutPixel(x1,y1,color); } }
void LCD_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2) { int16_t dy = 0; int16_t dx = 0; int16_t stepx = 0; int16_t stepy = 0; int16_t fraction = 0; // if (x1>LCD_X_RES || x2>LCD_X_RES || y1>LCD_Y_RES || y2>LCD_Y_RES) return; dy = y2 - y1; dx = x2 - x1; if (dy < 0) { dy = -dy; stepy = -1; } else stepy = 1; if (dx < 0) { dx = -dx; stepx = -1; } else stepx = 1; dy <<= 1; dx <<= 1; LCD_PutPixel(x1,y1,penColor); if (dx > dy) { fraction = dy - (dx >> 1); while (x1 != x2) { if (fraction >= 0) { y1 += stepy; fraction -= dx; } x1 += stepx; fraction += dy; LCD_PutPixel(x1,y1,penColor); } }
void O2View(void) { uint16_t i,y; if(lambda_fehler()) { O2_ErrorView(); return; } else if(!lambda_run()) { O2_StatusView(); return; } MEASUREMENT_VIEW_struct * viewMem = lambda_getViewMem(); LCD_ClearScreen(); LCD_SetPenColor(1); LCD_SetFont(0); LCD_PrintXY(40,0,"O2:"); LCD_PrintXY(80,0,viewMem->cur_value); LCD_SetFont(0); LCD_PrintXY(0,0, "25-"); LCD_PrintXY(0,18,"15-"); LCD_PrintXY(0,37," 5-"); LCD_PrintXY(0,56," 0-"); LCD_DrawLine(15,0,15,63); for(i=16;i<128;i++) { y = viewMem->Mem[127-i]; if(y < 25) { y = 64 - ((double)(y)*(double)(64.0/25)); LCD_PutPixel(i,y,1); LCD_PutPixel(i,y+1,1); } } }
//-------------------------------------------------------// // Draws B/W packed image, coordinates are absolute. // Image is printed using: // - penColor // - altPenColor // - outputMode //-------------------------------------------------------// void LCD_drawPackedImage(const uint8_t *img, uint16_t x_pos, uint16_t y_pos, uint16_t img_width, uint16_t img_height) { uint8_t bit_mask = 0x01; uint8_t temp; uint16_t img_index; uint16_t img_start_index = 0; uint16_t x; uint16_t y_fin = y_pos + img_height; while(y_pos < y_fin) { img_index = img_start_index; for (x = x_pos; x < x_pos + img_width; x++) { temp = img[img_index++]; if (temp & bit_mask) { if (imageOutputMode & IMAGE_PAINT_SET_PIXELS) { LCD_PutPixel(x,y_pos,penColor); } } else if (imageOutputMode & IMAGE_PAINT_VOID_PIXELS) { LCD_PutPixel(x,y_pos,altPenColor); } } y_pos++; if (bit_mask == 0x80) { bit_mask = 0x01; img_start_index += img_width; } else { bit_mask = bit_mask << 1; } } }
/** * @brief Display a cursor at new position. In depence to DrawPhase parameter * one of the following phases is performed: * - Draw last cursors behind at last position - hide cursor. * - Read new cursors behind at specified position. * - Draw cursor at new position - display cursor. * @param Xpos: specifies cursor X position. * @param Ypos: specifies cursor Y position. * @param DrawPhase: drawing phase, possible values are: * @arg CUR_DRAW_ALL: entire process. * @arg CUR_DRAW_BEH: draw behind at last position. * @arg CUR_READ_BEH: read behind at new position. * @arg CUR_READ_DRAW_CUR: read behind and draw cursor at new position. * @retval None */ void CursorDraw(uint16_t X, uint16_t Y, uint8_t DrawPhase) { uint8_t tmpX, tmpY = 0x00; uint8_t Mask, Temp = 0x00; CursorHeader_Typedef *CursorHeader = (CursorHeader_Typedef *)Cursor->CursorPointer; uint8_t* CursorImagePointer; uint16_t* CursorBehindPointer; /*Draw last cursors behind at last position - hide cursor*/ if (DrawPhase & CUR_DRAW_BEH_MASK) { /*Initiate pointers on Cursor bit map image and on array of cursors behind to draw*/ CursorImagePointer = (uint8_t *)(Cursor->CursorPointer) + sizeof(CursorHeader_Typedef); CursorBehindPointer = Cursor->BehindCursor; /*Repeat for all lines of cursor symbol*/ for (tmpY = 0x00 ; tmpY < CursorHeader->Height ; tmpY++) { Mask = 0x00; /*Repeat for all columns of cursor symbol*/ for (tmpX = 0x00 ; tmpX < CursorHeader->Width; tmpX++) { if (Mask == 0) { /*Read next byte of bit map image and initiate mask*/ Temp = *CursorImagePointer; CursorImagePointer++; Mask = 0x80; } /*Mask actual byte of cursor bitmap image*/ if (Temp & Mask) { /*Draw pixel of cursor behind*/ LCD_PutPixel(Cursor->X + tmpX, Cursor->Y + tmpY, *CursorBehindPointer++, SinglePixel); } /*Shift a mask right*/ Mask >>= 1; } } }
void DrawCircle(unsigned char X, unsigned char Y ,unsigned char R, unsigned char color) { int xc = 0, yc, p; yc=R; p = 3 - (R<<1); while (xc <= yc) { LCD_PutPixel (X + xc, Y + yc, color); LCD_PutPixel (X + xc, Y - yc, color); LCD_PutPixel (X - xc, Y + yc, color); LCD_PutPixel (X - xc, Y - yc, color); LCD_PutPixel (X + yc, Y + xc, color); LCD_PutPixel (X + yc, Y - xc, color); LCD_PutPixel (X - yc, Y + xc, color); LCD_PutPixel (X - yc, Y - xc, color); if (p < 0) p += (xc++ << 2) + 6; else p += ((xc++ - yc--)<<2) + 10; } }
/** * @brief Displays a circle. * @param Xpos: specifies the X position. * @param Ypos: specifies the Y position. * @param Radius: the radius size of the circle * @retval None */ void GL_LCD_DrawCircle(uint8_t Xpos, uint16_t Ypos, uint16_t Radius) { int32_t D;/* Decision Variable */ uint32_t CurX;/* Current X Value */ uint32_t CurY;/* Current Y Value */ D = 3 - (Radius << 1); CurX = 0; CurY = Radius; while (CurX <= CurY) { LCD_PutPixel(Xpos + CurX, Ypos + CurY, GL_TextColor); LCD_PutPixel(Xpos + CurX, Ypos - CurY, GL_TextColor); LCD_PutPixel(Xpos - CurX, Ypos + CurY, GL_TextColor); LCD_PutPixel(Xpos - CurX, Ypos - CurY, GL_TextColor); LCD_PutPixel(Xpos + CurY, Ypos + CurX, GL_TextColor); LCD_PutPixel(Xpos + CurY, Ypos - CurX, GL_TextColor); LCD_PutPixel(Xpos - CurY, Ypos + CurX, GL_TextColor); LCD_PutPixel(Xpos - CurY, Ypos - CurX, GL_TextColor); if (D < 0) { D += (CurX << 2) + 6; } else { D += ((CurX - CurY) << 2) + 10; CurY--; } CurX++; } }
/** * @brief Calibre l'écran tactile * @param mode: le mode de calibration (@ref TS_Calibration_mode_e) * @pre Cette fonction doit être appelée en boucle jusqu'à ce qu'elle renvoit TRUE (calibration terminée). * @post Lors de l'état INIT, l'appel à TS_Init() est réalisé. * @retval running_e END_OK si la calibration est terminée, IN_PROGRESS sinon. */ running_e TS_Calibration(bool_e ask_for_finish, TS_Calibration_mode_e mode) { typedef enum{ INIT=0, LEFT_CROSS_DISPLAY, WAIT_FIRST_PRESS, WAIT_FIRST_RELEASE, RIGHT_CROSS_DISPLAY, WAIT_SECOND_PRESS, WAIT_SECOND_RELEASE, COMPUTE, WAIT_PRESS_TO_EXIT, PLAY_TELECRAN, CLOSE }state_e; static state_e state = INIT; static TS_ADC first_cross_point, second_cross_point; static bool_e asked_for_finish = FALSE; TS_ADC trash; char* text[35]; running_e ret; ret = IN_PROGRESS; if(ask_for_finish) asked_for_finish = TRUE; switch(state) { case INIT: asked_for_finish = FALSE; TS_Init(); STM32f4_Discovery_LCD_Init(); LCD_Clear(LCD_COLOR_WHITE); LCD_SetFont(&Font12x12); if(mode == CALIBRATION_MODE_NO_CALIBRATION) state = CLOSE; else { printf("Calibration of Touchscreen (for display DM-LCD25RT)\n"); state = LEFT_CROSS_DISPLAY; } break; case LEFT_CROSS_DISPLAY: LCD_DrawUniLine(CROSS_MARGIN-CROSS_SIZE, CROSS_MARGIN, CROSS_MARGIN+CROSS_SIZE,CROSS_MARGIN, LCD_COLOR_BLUE); LCD_DrawUniLine(CROSS_MARGIN-CROSS_SIZE, CROSS_MARGIN-1, CROSS_MARGIN+CROSS_SIZE,CROSS_MARGIN-1, LCD_COLOR_BLUE); LCD_DrawUniLine(CROSS_MARGIN-CROSS_SIZE, CROSS_MARGIN+1, CROSS_MARGIN+CROSS_SIZE,CROSS_MARGIN+1, LCD_COLOR_BLUE); LCD_DrawUniLine(CROSS_MARGIN, CROSS_MARGIN-CROSS_SIZE,CROSS_MARGIN, CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE); LCD_DrawUniLine(CROSS_MARGIN-1, CROSS_MARGIN-CROSS_SIZE,CROSS_MARGIN-1, CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE); LCD_DrawUniLine(CROSS_MARGIN+1, CROSS_MARGIN-CROSS_SIZE,CROSS_MARGIN+1, CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE); state = WAIT_FIRST_PRESS; break; case WAIT_FIRST_PRESS: if(!t) { t = 100; TS_Get_Filtered_Touch(&first_cross_point); if(first_cross_point.touch_detected) state = WAIT_FIRST_RELEASE; } if(asked_for_finish) state = CLOSE; break; case WAIT_FIRST_RELEASE: if(!t) { t = 100; if(!TS_Get_Filtered_Touch(&trash)) state = RIGHT_CROSS_DISPLAY; } if(asked_for_finish) state = CLOSE; break; case RIGHT_CROSS_DISPLAY: LCD_Clear(LCD_COLOR_WHITE); LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-CROSS_SIZE, LCD_PIXEL_HEIGHT-CROSS_MARGIN, LCD_PIXEL_WIDTH-CROSS_MARGIN+CROSS_SIZE, LCD_PIXEL_HEIGHT-CROSS_MARGIN, LCD_COLOR_BLUE); LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-CROSS_SIZE, LCD_PIXEL_HEIGHT-CROSS_MARGIN-1, LCD_PIXEL_WIDTH-CROSS_MARGIN+CROSS_SIZE, LCD_PIXEL_HEIGHT-CROSS_MARGIN-1, LCD_COLOR_BLUE); LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-CROSS_SIZE, LCD_PIXEL_HEIGHT-CROSS_MARGIN+1, LCD_PIXEL_WIDTH-CROSS_MARGIN+CROSS_SIZE, LCD_PIXEL_HEIGHT-CROSS_MARGIN+1, LCD_COLOR_BLUE); LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN, LCD_PIXEL_HEIGHT-CROSS_MARGIN-CROSS_SIZE, LCD_PIXEL_WIDTH-CROSS_MARGIN, LCD_PIXEL_HEIGHT-CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE); LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-1, LCD_PIXEL_HEIGHT-CROSS_MARGIN-CROSS_SIZE, LCD_PIXEL_WIDTH-CROSS_MARGIN-1, LCD_PIXEL_HEIGHT-CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE); LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN+1, LCD_PIXEL_HEIGHT-CROSS_MARGIN-CROSS_SIZE, LCD_PIXEL_WIDTH-CROSS_MARGIN+1, LCD_PIXEL_HEIGHT-CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE); state = WAIT_SECOND_PRESS; break; case WAIT_SECOND_PRESS: if(!t) { t = 100; TS_Get_Filtered_Touch(&second_cross_point); if(second_cross_point.touch_detected) state = COMPUTE; } if(asked_for_finish) state = CLOSE; break; case COMPUTE: ts_coeff.scale_x = (float)((LCD_PIXEL_WIDTH-2*CROSS_MARGIN)) / ((float)second_cross_point.x-(float)first_cross_point.x); ts_coeff.scale_y = (float)((LCD_PIXEL_HEIGHT-2*CROSS_MARGIN)) / ((float)second_cross_point.y-(float)first_cross_point.y); ts_coeff.offset_x = (float)(CROSS_MARGIN-ts_coeff.scale_x*(float)first_cross_point.x); ts_coeff.offset_y = (float)(CROSS_MARGIN-ts_coeff.scale_y*(float)first_cross_point.y); if(mode >= CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE) { LCD_Clear(LCD_COLOR_WHITE); sprintf((char*)text,"First cross x = %d ", first_cross_point.x); LCD_DisplayStringLine(LINE(3),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); sprintf((char*)text,"Second cross x = %d ", second_cross_point.x); LCD_DisplayStringLine(LINE(5),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); sprintf((char*)text,"First cross y = %d ", first_cross_point.y); LCD_DisplayStringLine(LINE(4),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); sprintf((char*)text,"Second cross y = %d ", second_cross_point.y); LCD_DisplayStringLine(LINE(6),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); LCD_DisplayStringLine(LINE(8),COLUMN(0),(uint8_t *)"Toucher pour continuer !",LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); sprintf((char*)text,"Scale x = %f",ts_coeff.scale_x); //%ld.%03ld ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.scale_x*1000)-(1000*(int32_t)ts_coeff.scale_x)); LCD_DisplayStringLine(LINE(10),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); sprintf((char*)text,"Offset x = %f",ts_coeff.offset_x); // = %ld.%03ld ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.offset_x*1000)-(1000*(int32_t)ts_coeff.offset_x)); LCD_DisplayStringLine(LINE(11),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); sprintf((char*)text,"Scale y = %f",ts_coeff.scale_y); // = %ld.%03ld ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.scale_y*1000)-(1000*(int32_t)ts_coeff.scale_y)); LCD_DisplayStringLine(LINE(12),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); sprintf((char*)text,"Offset y = %f",ts_coeff.offset_y); // = %ld.%03ld ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.offset_y*1000)-(1000*(int32_t)ts_coeff.offset_y)); LCD_DisplayStringLine(LINE(13),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); if(mode == CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE_AND_PROVIDE_TELECRAN_GAME) { LCD_DisplayStringLine(LINE(15),COLUMN(0),(uint8_t *)"To quit the Telecran Game,",LCD_COLOR_RED, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); LCD_DisplayStringLine(LINE(16),COLUMN(0),(uint8_t *)"Just press the blue button",LCD_COLOR_RED, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART); } } state = WAIT_SECOND_RELEASE; break; case WAIT_SECOND_RELEASE: if(!t) { t = 100; if(!TS_Get_Filtered_Touch(&trash)) { switch(mode) { case CALIBRATION_MODE_JUST_CALIBRATE: state = CLOSE; break; case CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE: state = WAIT_PRESS_TO_EXIT; break; case CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE_AND_PROVIDE_TELECRAN_GAME: state = WAIT_PRESS_TO_EXIT; break; default: state = CLOSE; break; } } } if(asked_for_finish) state = CLOSE; break; case WAIT_PRESS_TO_EXIT: if(!t) { t = 100; if(TS_Get_Filtered_Touch(&trash)) { if(mode == CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE) { LCD_Clear(LCD_COLOR_WHITE); state = CLOSE; } else //CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE_AND_PROVIDE_TELECRAN_GAME { LCD_Clear(LCD_COLOR_BLACK); state = PLAY_TELECRAN; } } } if(asked_for_finish) state = CLOSE; break; case PLAY_TELECRAN:{ uint16_t x,y; char str[30]; if(!t) { t = 15; if(TS_Get_Touch(&x,&y)) { sprintf((char*)str,"x = %5d",x); LCD_DisplayStringLine(LINE(1),COLUMN(0),(uint8_t *)str, LCD_COLOR_WHITE, LCD_COLOR_BLACK,LCD_NO_DISPLAY_ON_UART); sprintf((char*)str,"y = %5d",y); LCD_DisplayStringLine(LINE(2),COLUMN(0),(uint8_t *)str, LCD_COLOR_WHITE, LCD_COLOR_BLACK,LCD_NO_DISPLAY_ON_UART); LCD_PutPixel(x, y, LCD_COLOR_YELLOW); } } if(asked_for_finish) state = CLOSE; break;} case CLOSE: LCD_Clear(LCD_COLOR_WHITE); state = INIT; ret = END_OK; break; default: break; } return ret; }
/******************************************************************************* * Function Name : LCD_Line * Description : Outputs line from (x1,y1) point to (x2,y2) point. * Input : õ1 - start point x-coordinate * : y1 - start point y-coordinate * : x2 - end point x-coordinate * : y2 - end point y-coordinate * Output : None * Return : None *******************************************************************************/ void LCD_Line(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2) { int32_t dx, dy, i1, i2, i, kx, ky; int32_t d; int32_t x, y; int32_t flag; dy = y2 - y1; dx = x2 - x1; if (dx == 0 && dy == 0) { LCD_PutPixel(x1, y1); return; } flag = kx = ky = 1; if (dx < 0) { dx = -dx; kx = -1; } else if (dx == 0) { kx = 0; } if (dy < 0) { dy = -dy; ky = -1; } if (dx < dy) { flag = 0; d = dx; dx = dy; dy = d; } i1 = dy + dy; d = i1 - dx; i2 = d - dx; x = x1; y = y1; for (i=0; ; i++) { LCD_PutPixel(x,y); if (i >= dx) { break; } if (flag) { x += kx; } else { y += ky; } if (d < 0) { d += i1; } else { d += i2; if (flag) { y += ky; } else { x += kx; } } } }