void If_PrintOilPressure(uint16_t pressure) { uint16_t color; uint8_t a, b; a = 3; b = 1; if (pressure < GREEN_THRESHOLD) color = Yellow; if ((pressure >= GREEN_THRESHOLD) && (pressure < RED_THRESHOLD)) color = Green; if (pressure >= RED_THRESHOLD) color = Red; LCD_setColor(color); LCD_Rectangle(5 + a * 80, 5 + b * 80, 75 + a * 80, 29 + b * 80); LCD_Rectangle(5 + a * 80, 30 + b * 80, 14 + a * 80, 45 + b * 80); LCD_Rectangle(63 + a * 80, 30 + b * 80, 75 + a * 80, 45 + b * 80); LCD_Rectangle(5 + a * 80, 46 + b * 80, 29 + a * 80, 61 + b * 80); LCD_Rectangle(46 + a * 80, 46 + b * 80, 75 + a * 80, 61 + b * 80); LCD_Rectangle(5 + a * 80, 62 + b * 80, 75 + a * 80, 75 + b * 80); LCD_setColor(0x0000); LCD_setBackColor(color); DBG_PrintDEC_XXXgrad(pressure / 10, a * 80 + 15, b * 80 + 30); LCD_printXY("p", a * 80 + 30, b * 80 + 46); }
void If_PrintCylCell(uint8_t N, uint16_t temp) { uint16_t color; uint8_t a, b; if (N > 8) return; a = N % 3; b = N / 3; if (temp < GREEN_THRESHOLD) color = Yellow; if ((temp >= GREEN_THRESHOLD) && (temp < RED_THRESHOLD)) color = Green; if (temp >= RED_THRESHOLD) color = Red; LCD_setColor(color); LCD_Rectangle(5 + a * 80, 5 + b * 80, 75 + a * 80, 29 + b * 80); LCD_Rectangle(5 + a * 80, 46 + b * 80, 75 + a * 80, 75 + b * 80); LCD_Rectangle(5 + a * 80, 30 + b * 80, 14 + a * 80, 45 + b * 80); LCD_Rectangle(63 + a * 80, 30 + b * 80, 75 + a * 80, 45 + b * 80); LCD_setColor(0x0000); LCD_setBackColor(color); DBG_PrintDEC_XXXgrad(temp / 10, a * 80 + 15, b * 80 + 30); }
void If_PrintOilTemp(uint16_t temp) { uint16_t color; uint8_t a, b; a = 3; b = 0; if (temp < GREEN_THRESHOLD) color = Yellow; if ((temp >= GREEN_THRESHOLD) && (temp < RED_THRESHOLD)) color = Green; if (temp >= RED_THRESHOLD) color = Red; LCD_setColor(color); LCD_Rectangle(5 + a * 80, 5 + b * 80, 75 + a * 80, 29 + b * 80); LCD_Rectangle(5 + a * 80, 30 + b * 80, 14 + a * 80, 45 + b * 80); LCD_Rectangle(63 + a * 80, 30 + b * 80, 75 + a * 80, 45 + b * 80); LCD_Rectangle(5 + a * 80, 46 + b * 80, 29 + a * 80, 61 + b * 80); LCD_Rectangle(46 + a * 80, 46 + b * 80, 75 + a * 80, 61 + b * 80); LCD_Rectangle(5 + a * 80, 62 + b * 80, 75 + a * 80, 75 + b * 80); LCD_setColor(0x0000); LCD_setBackColor(color); DBG_PrintDEC_XXXgrad(temp / 10, a * 80 + 15, b * 80 + 30); LCD_printXY("t", a * 80 + 30, b * 80 + 46); }
void If_PrintMetal(uint16_t met) { uint16_t color; uint8_t a, b; a = 3; b = 2; if (met) color = Red; else color = Green; LCD_setColor(color); LCD_Rectangle(5 + a * 80, 5 + b * 80, 75 + a * 80, 45 + b * 80); LCD_Rectangle(5 + a * 80, 46 + b * 80, 29 + a * 80, 61 + b * 80); LCD_Rectangle(46 + a * 80, 46 + b * 80, 75 + a * 80, 61 + b * 80); LCD_Rectangle(5 + a * 80, 62 + b * 80, 75 + a * 80, 75 + b * 80); LCD_setColor(0x0000); LCD_setBackColor(color); LCD_printXY("m", a * 80 + 30, b * 80 + 46); }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_FSMC_Init(); MX_SPI1_Init(); MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ LCD_Init(LCD_ORIENTATION_PORTRAIT); LCD_setFont(SmallFont); LCD_setBackColor(VGA_BLACK); LCD_fillScr(VGA_BLACK); TSC2046_Init(); TSC2046_Calibration(); LCD_fillScr(VGA_BLACK); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ char buf[100]; int16_t xpos, ypos; while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ LCD_setColor(VGA_BLUE); LCD_drawRect(0, 0, 10, 10); while(!Is_Touhcing()); while (Is_Touhcing()) { // read xpos = TSC2046_Get_Position_X(); ypos = TSC2046_Get_Position_Y(); // clear if (xpos > LCD_WIDTH - 20 && ypos > LCD_HEIGHT - 20) { LCD_fillScr(VGA_BLACK); } // print sprintf(buf, "(x,y)=(%04d, %04d)", xpos, ypos); LCD_setColor(VGA_RED); LCD_setBackColor(VGA_BLACK); LCD_print(buf, 20, 300, 0); // draw pen LCD_setColor(rand() | 0b0111101111101111); LCD_fillCircle(xpos, ypos, 3); // clear button LCD_setColor(VGA_WHITE); LCD_fillRect(LCD_WIDTH - 20, LCD_HEIGHT - 20, LCD_WIDTH - 1, LCD_HEIGHT - 1); // pen indicator LCD_setColor(VGA_GREEN); LCD_drawRect(0, 0, 10, 10); } } /* USER CODE END 3 */ }