1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| void UILogo(void) { static uint32_t tick = 0; if (0 == tick) tick = osKernelGetTickCount(); GUI_Clear(); GUI_DrawBitmap(&bmLOGO, (128 - bmLOGO.XSize) / 2, (64 - bmLOGO.YSize) / 2); GUI_Update(); if (osKernelGetTickCount() >= tick + 2000) { g_sta = GUI_MAIN; tick = 0; } } void UIMain(void) { GUI_Clear(); GUI_SetFont(&GUI_FontHZ_SimSun_16); GUI_DispStringHCenterAt("主菜单", 64, 0); if (GUI_LED == g_sta_select) { GUI_DispStringHCenterAt("* LED状态", 64, 20); GUI_DispStringHCenterAt("按键状态", 64, 40); } else { GUI_DispStringHCenterAt("LED状态", 64, 20); GUI_DispStringHCenterAt("* 按键状态", 64, 40); } GUI_Update(); } void UILeds(void) { GPIO_TypeDef* LED_Ports[8] = { L1_GPIO_Port, L2_GPIO_Port, L3_GPIO_Port, L4_GPIO_Port, L5_GPIO_Port, L6_GPIO_Port, L7_GPIO_Port, L8_GPIO_Port}; uint16_t LED_Pin[8] = {L1_Pin, L2_Pin, L3_Pin, L4_Pin, L5_Pin, L6_Pin, L7_Pin, L8_Pin}; GUI_Clear(); GUI_SetFont(&GUI_FontHZ_SimSun_16); GUI_DispStringHCenterAt("LED状态", 64, 0); int tx, ty; tx = ty = 12; for (int i = 0; i < 8; ++i) { GUI_DrawRect(16 * i + 1, 20, 16 * i + tx, 20 + ty); if (HAL_GPIO_ReadPin(LED_Ports[i], LED_Pin[i]) == GPIO_PIN_RESET) GUI_FillRect(16 * i + 1, 20, 16 * i + tx, 20 + ty); } GUI_Update(); } void UIKeys(void) { GUI_Clear(); GUI_SetFont(&GUI_FontHZ_SimSun_16); GUI_DispStringHCenterAt("按键状态", 64, 0); GPIO_PinState ps = HAL_GPIO_ReadPin(K1_GPIO_Port, K1_Pin); GUI_DispStringAt(GPIO_PIN_RESET == ps ? "●" : "○", 26, 20); ps = HAL_GPIO_ReadPin(K4_GPIO_Port, K4_Pin); GUI_DispStringAt(GPIO_PIN_RESET == ps ? "●" : "○", 26, 48); ps = HAL_GPIO_ReadPin(K2_GPIO_Port, K2_Pin); GUI_DispStringAt(GPIO_PIN_RESET == ps ? "●" : "○", 6, 34); ps = HAL_GPIO_ReadPin(K3_GPIO_Port, K3_Pin); GUI_DispStringAt(GPIO_PIN_RESET == ps ? "●" : "○", 46, 34); ps = HAL_GPIO_ReadPin(K5_GPIO_Port, K5_Pin); GUI_DispStringAt(GPIO_PIN_SET == ps ? "●" : "○", 86, 34); ps = HAL_GPIO_ReadPin(K6_GPIO_Port, K6_Pin); GUI_DispStringAt(GPIO_PIN_SET == ps ? "●" : "○", 106, 34); GUI_Update(); }
|