赞
踩
此电路由STM32F103ZET6最小系统板、7针1.3寸TFT-LCD(240×240)显示屏和ESP8266WiFi模块组成。
- int main(void)
- {
- /* USER CODE BEGIN 1 */
- uint8_t cnt = 0;
- temp = 1;
- int humidity = 0;
- int value = 0;
- /* USER CODE END 1 */
-
- /* MCU Configuration--------------------------------------------------------*/
-
- /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
- HAL_Init();
-
- /* USER CODE BEGIN Init */
-
- /* USER CODE END Init */
-
- /* Configure the system clock */
- SystemClock_Config();
-
- /* USER CODE BEGIN SysInit */
-
- /* USER CODE END SysInit */
-
- /* Initialize all configured peripherals */
- MX_GPIO_Init();
- MX_USART1_UART_Init();
- MX_USART3_UART_Init();
- MX_RTC_Init();
- /* USER CODE BEGIN 2 */
- Lcd_Init(); //³õʼ»¯TFT
- LCD_Clear(WHITE); //ÇåÆÁ
-
- picture();
-
- HAL_UART_Receive_IT(&huart1, (uint8_t *)&aRxBuffer_rx1, 1);
- HAL_UART_Receive_IT(&huart3, (uint8_t *)&aRxBuffer_rx3, 1); //¿ªÆô´®¿ÚÖжÏ
- esp8266_config();
- LCD_Clear(WHITE); //ÇåÆÁ
- Han();
- /* USER CODE END 2 */
-
- /* Infinite loop */
- /* USER CODE BEGIN WHILE */
- while (1)
- {
- /* USER CODE END WHILE */
-
- /* USER CODE BEGIN 3 */
-
-
-
- for(int a=0;a<11;a++)
- {
- showimage4(gImage_1[a]); //ÏÔʾ¶¯Ì¬
- RTC_display();
- if(a == 10)a=0;
-
-
- char *p;
- p = strstr(Data_buff,"text_day"); //²éÕÒÌìÆø
- sscanf(p+11,"%[^\"]",weather);
- // LCD_ShowString(40,80,(uint8_t*)weather);
- p = strstr(Data_buff,"high"); //²éÕÒÆøÎÂ
- temperature[0]=atoi(p+7);
- p = strstr(Data_buff,"low");
- temperature[1]=atoi(p+6);
- // LCD_ShowxNum2(45,40,temperature[1],2,24,0);
- LCD_ShowxNum2(160,207,temperature[0],2,24,0);
-
- //ζÈ
- value = (temperature[1]+temperature[0])/2;
- LCD_ShowxNum2(52,160,value,2,24,0);
-
- //ʪ¶È
- p = strstr(Data_buff,"humidity");
- humidity=atoi(p+11);
- LCD_ShowxNum2(132,160,humidity,2,24,0);
- LCD_ShowNew(161,160,'%',24,0);
-
- //ÏÔʾ¶ÔÓ¦ÌìÆøUI Èç¹û·¢ÏÖδÏÔʾÌìÆøͼ±ê£¬ÔÒòΪ֪ÐÄÌìÆøµÄUIÅж¨×Ö·û´®´óСд²»Ò»Ñù£¬Í¨¹ý´®¿Ú¸ÄһϴóСд¾Í¿ÉÒÔÁË
- if((strstr(weather,"Overcast")) || (strstr(weather,"Mostly Cloudy")) || (strstr(weather,"Partly Cloudy")) || strstr(weather,"Cloudy")) //¶àÔÆ
- {
- Overcast();
- }
- if((strstr(weather,"Sunny")) || (strstr(weather,"Clear")) || (strstr(weather,"Fair"))) //ÇçÌì
- {
- Sunny();
- }
- if((strstr(weather,"Shower"))) //ÕóÓê
- {
- Shower();
- }
- if((strstr(weather,"Thundershower")) || (strstr(weather,"Thundershower with Hail"))) //À×Óê
- {
- Thundershower();
- }
- if((strstr(weather,"Light rain")) || (strstr(weather,"Moderate Rain"))) //ÓêÌì
- {
- smallrain();
- }
- if((strstr(weather,"Heavy Rain")) || (strstr(weather,"Storm")) || (strstr(weather,"Heavy Storm")) || (strstr(weather,"Severe Storm"))) //±©Óê
- {
- Bigrain();
- }
- if((strstr(weather,"Ice Rain")) || (strstr(weather,"Sleet")) || (strstr(weather,"Snow Flurry")) || (strstr(weather,"Light Snow")) || (strstr(weather,"Moderate Snow")) || (strstr(weather,"Heavy Snow")) || (strstr(weather,"Snowstorm"))) //Ñ©Ìì
- {
- snow();
- }
-
- }
-
- // cnt++;
- // if(cnt > 50)
- // {
- // SendATCmd(get, 2000);
- // cnt = 0;
- // }
-
- }
- /* USER CODE END 3 */
- }
-
- /**
- * @brief System Clock Configuration
- * @retval None
- */
- void SystemClock_Config(void)
- {
- RCC_OscInitTypeDef RCC_OscInitStruct = {0};
- RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
- RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
-
- /** Initializes the RCC Oscillators according to the specified parameters
- * in the RCC_OscInitTypeDef structure.
- */
- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
- RCC_OscInitStruct.HSEState = RCC_HSE_ON;
- RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
- RCC_OscInitStruct.HSIState = RCC_HSI_ON;
- RCC_OscInitStruct.LSIState = RCC_LSI_ON;
- RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
- RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
- RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
- if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
- {
- Error_Handler();
- }
- /** Initializes the CPU, AHB and APB buses clocks
- */
- RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
- |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
- RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
- RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
- RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
- RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
-
- if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
- {
- Error_Handler();
- }
- PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;
- PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
- if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
- {
- Error_Handler();
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。