当前位置: 首页 > news >正文

南宁网络推广建站乐东黎族自治县住房建设局网站

南宁网络推广建站,乐东黎族自治县住房建设局网站,建站网站那个好,站内推广的主要目的是目录 一、页面切换内容详解 1.逻辑解释 2.代码详解 code.c#xff08;内含详细讲解#xff09; code.h main.c 3.效果图片展示 ​编辑 二、页面选项高亮内容详解 1.逻辑解释 2.读入数据 FIRST.第一种高亮类型 code.c#xff08;内含代码详解#xff09; code.… 目录 一、页面切换内容详解 1.逻辑解释 2.代码详解 code.c内含详细讲解 code.h main.c 3.效果图片展示 ​编辑 二、页面选项高亮内容详解 1.逻辑解释 2.读入数据 FIRST.第一种高亮类型 code.c内含代码详解 code.h main.c SECOND.第二种高亮类型 3.效果展示 开源代码 一、页面切换内容详解 1.逻辑解释 首先通过 LCD_Clear(White) 函数将 LCD 屏幕清除为白色。lcd_page 的值增加 1。然后进行判断如果 lcd_page 达到 3则将其重置为 0实现页面的循环切换。 当检测到按键一被按下Key_down1时 count 的值增加 1。 这样通过按键二可以切换页面通过按键一可以使 count 值增加。 举例来说 初始时lcd_page 为 0count 为 0。按下按键二一次lcd_page 变为 1。再按下按键二一次lcd_page 变为 2。接着按下按键二一次lcd_page 变为 0完成一次页面循环。同时在这个过程中每按下一次按键一count 值就增加 1。 2.代码详解 code.c内含详细讲解 #include headfile.hvoid led_show(uint8_t led,uint8_t mode) { HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_SET);if(mode) HAL_GPIO_WritePin(GPIOC,GPIO_PIN_8(led-1),GPIO_PIN_RESET);else HAL_GPIO_WritePin(GPIOC,GPIO_PIN_8(led -1),GPIO_PIN_RESET);HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_RESET);}uint8_t Key_Scan(void) {uint8_t Key_val0;if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_0)GPIO_PIN_RESET){Key_val1;}if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_1)GPIO_PIN_RESET){Key_val2;}if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_2)GPIO_PIN_RESET){Key_val3;}if(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0)GPIO_PIN_RESET){Key_val4;}return Key_val; } extern uint8_t key_rval; uint8_t Key_up,Key_down,key_old; uint8_t count; uint8_t lcd_page;//定义一个变量存储 void Key_Proc(void) {key_rvalKey_Scan();Key_downkey_rval(key_rval^key_old);Key_up~key_rval(key_rval^key_old);key_oldkey_rval;if(Key_down2)//按键二切换页面{ LCD_Clear(White);//清屏操作不然会有残影lcd_page;//页面加一if(lcd_page3) lcd_page0;//以为没有lcd_page3所以回到0}if(Key_down1)//按键一数值加一{count;//如果变量 Key_down 的值等于 1则将变量 count 的值增加 1。 //这是一个简单的条件判断和操作用于根据特定条件来改变某个变量的值。}}char buf[21]; void Lcd_proc(void) {if(lcd_page0){LCD_DisplayStringLine(Line1,(uint8_t*) jinke! );//这行代码是将字符串 jinke! 强制转换为指向 uint8_t 类型数据的指针。}if(lcd_page1){sprintf(buf, count:%d ,count);//count:%d 是格式字符串其中 %d 表示要插入一个整数变量 count 。//执行完这行代码后buf 中就会存储一个包含 count: 和 count 的具体数值的字符串。LCD_DisplayStringLine(Line4,(uint8_t*)buf);//“LCD_DisplayStringLine(Line4, (uint8_t*)buf)” 表示在特定的行Line4上显示字符串//其中字符串的内容来自于指向 uint8_t 类型的指针 buf 所指向的缓冲区。}if(lcd_page2){LCD_DisplayStringLine(Line4,(uint8_t*) BAYBAY! );} }code.h #ifndef _code_h #define _code_h #include stm32g4xx.h // Device headervoid led_show(uint8_t led,uint8_t mode); void key_scan(void); void Lcd_proc(void); void Key_Proc(void); #endifmain.c /* USER CODE BEGIN Header */ /********************************************************************************* file : main.c* brief : Main program body******************************************************************************* attention** Copyright (c) 2024 STMicroelectronics.* All rights reserved.** This software is licensed under terms that can be found in the LICENSE file* in the root directory of this software component.* If no LICENSE file comes with this software, it is provided AS-IS.********************************************************************************/ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include main.h #include gpio.h/* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include headfile.h /* USER CODE END Includes *//* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD *//* USER CODE END PTD *//* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD *//* USER CODE END PD *//* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM *//* USER CODE END PM *//* Private variables ---------------------------------------------------------*//* USER CODE BEGIN PV */uint8_t key_rval; /* USER CODE END PV *//* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); /* USER CODE BEGIN PFP *//* USER CODE END PFP *//* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 *//* USER CODE END 0 *//*** brief The application entry point.* retval int*/ 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();/* 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();/* USER CODE BEGIN 2 */LCD_Init();LCD_Clear(White);LCD_SetBackColor(White);LCD_SetTextColor(Black);/* USER CODE END 2 *//* Infinite loop *//* USER CODE BEGIN WHILE */while (1){ Key_Proc();Lcd_proc(); /* USER CODE END WHILE *//* USER CODE BEGIN 3 */}/* USER CODE END 3 */ }/*** brief System Clock Configuration* retval None*/ void SystemClock_Config(void) {RCC_OscInitTypeDef RCC_OscInitStruct {0};RCC_ClkInitTypeDef RCC_ClkInitStruct {0};/** Configure the main internal regulator output voltage*/HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);/** Initializes the RCC Oscillators according to the specified parameters* in the RCC_OscInitTypeDef structure.*/RCC_OscInitStruct.OscillatorType RCC_OSCILLATORTYPE_HSE;RCC_OscInitStruct.HSEState RCC_HSE_ON;RCC_OscInitStruct.PLL.PLLState RCC_PLL_ON;RCC_OscInitStruct.PLL.PLLSource RCC_PLLSOURCE_HSE;RCC_OscInitStruct.PLL.PLLM RCC_PLLM_DIV3;RCC_OscInitStruct.PLL.PLLN 20;RCC_OscInitStruct.PLL.PLLP RCC_PLLP_DIV2;RCC_OscInitStruct.PLL.PLLQ RCC_PLLQ_DIV2;RCC_OscInitStruct.PLL.PLLR RCC_PLLR_DIV2;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_DIV1;RCC_ClkInitStruct.APB2CLKDivider RCC_HCLK_DIV1;if (HAL_RCC_ClockConfig(RCC_ClkInitStruct, FLASH_LATENCY_2) ! HAL_OK){Error_Handler();} }/* USER CODE BEGIN 4 *//* USER CODE END 4 *//*** brief This function is executed in case of error occurrence.* retval None*/ void Error_Handler(void) {/* USER CODE BEGIN Error_Handler_Debug *//* User can add his own implementation to report the HAL error return state */__disable_irq();while (1){}/* USER CODE END Error_Handler_Debug */ }#ifdef USE_FULL_ASSERT /*** brief Reports the name of the source file and the source line number* where the assert_param error has occurred.* param file: pointer to the source file name* param line: assert_param error line source number* retval None*/ void assert_failed(uint8_t *file, uint32_t line) {/* USER CODE BEGIN 6 *//* User can add his own implementation to report the file name and line number,ex: printf(Wrong parameters value: file %s on line %d\r\n, file, line) *//* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */3.效果图片展示 二、页面选项高亮内容详解 1.逻辑解释 line_flag定义变量存储 当页面为 1 时根据 line_flag 的不同设置文本颜色并显示与 count1、count2、count3 相关的字符串。 2.读入数据 FIRST.第一种高亮类型 code.c内含代码详解 #include headfile.hvoid led_show(uint8_t led,uint8_t mode) { HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_SET);if(mode) HAL_GPIO_WritePin(GPIOC,GPIO_PIN_8(led-1),GPIO_PIN_RESET);else HAL_GPIO_WritePin(GPIOC,GPIO_PIN_8(led -1),GPIO_PIN_RESET);HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_RESET);} uint8_t Key_Scan(void) {uint8_t Key_val0;if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_0)GPIO_PIN_RESET){Key_val1;}if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_1)GPIO_PIN_RESET){Key_val2;}if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_2)GPIO_PIN_RESET){Key_val3;}if(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0)GPIO_PIN_RESET){Key_val4;}return Key_val; } extern uint8_t key_rval; uint8_t Key_up,Key_down,key_old; uint8_t count1,count2,count3; uint8_t lcd_page,line_flag;//定义一个变量存储 void Key_Proc(void) {key_rvalKey_Scan();Key_downkey_rval(key_rval^key_old);Key_up~key_rval(key_rval^key_old);key_oldkey_rval;if(Key_down1)//按键一切换页面{ LCD_Clear(White);//清屏操作不然会有残影LCD_SetBackColor(White);LCD_SetTextColor(Black);//需要加此函数lcd_page;//页面加一if(lcd_page3) lcd_page0;//以为没有lcd_page3所以回到0}if(Key_down2lcd_page1)//只在第二个页面起作用{line_flag; if(line_flag3)line_flag 0;//还可以写成if(line_flag3)line_flag 0; }if(Key_down3lcd_page1)//只在第二个页面起作用{if(line_flag0)count1; if(line_flag1)count2;if(line_flag2)count3;}if(Key_down4lcd_page1)//只在第二个页面起作用{if(line_flag0)count1--; if(line_flag1)count2--;if(line_flag2)count3--;} } char buf[21]; void Lcd_proc(void) {if(lcd_page0){LCD_DisplayStringLine(Line1,(uint8_t*) jinke! );//这行代码是将字符串 jinke! 强制转换为指向 uint8_t 类型数据的指针。}if(lcd_page1) { if(line_flag0) LCD_SetTextColor(Blue);//可替换成LCD_SetBackColor(Blue);else LCD_SetTextColor(Black);sprintf(buf, count1:%03d ,count1);//count:%d 是格式字符串其中 %d 表示要插入一个整数变量 count 。//执行完这行代码后buf 中就会存储一个包含 count: 和 count 的具体数值的字符串。LCD_DisplayStringLine(Line3,(uint8_t*)buf);//“LCD_DisplayStringLine(Line4, (uint8_t*)buf)” 表示在特定的行Line4上显示字符串//其中字符串的内容来自于指向 uint8_t 类型的指针 buf 所指向的缓冲区。if(line_flag1) LCD_SetTextColor(Blue);else LCD_SetTextColor(Black);sprintf(buf, count2:%03d ,count2);LCD_DisplayStringLine(Line4,(uint8_t*)buf);if(line_flag2) LCD_SetTextColor(Blue);else LCD_SetTextColor(Black);sprintf(buf, count3:%03d ,count3);LCD_DisplayStringLine(Line5,(uint8_t*)buf); }if(lcd_page2){LCD_DisplayStringLine(Line4,(uint8_t*) BAYBAY! );} }code.h #ifndef _code_h #define _code_h #include stm32g4xx.h // Device headervoid led_show(uint8_t led,uint8_t mode); void key_scan(void); void Lcd_proc(void); void Key_Proc(void); #endifmain.c /* USER CODE BEGIN Header */ /********************************************************************************* file : main.c* brief : Main program body******************************************************************************* attention** Copyright (c) 2024 STMicroelectronics.* All rights reserved.** This software is licensed under terms that can be found in the LICENSE file* in the root directory of this software component.* If no LICENSE file comes with this software, it is provided AS-IS.********************************************************************************/ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include main.h #include gpio.h/* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include headfile.h /* USER CODE END Includes *//* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD *//* USER CODE END PTD *//* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD *//* USER CODE END PD *//* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM *//* USER CODE END PM *//* Private variables ---------------------------------------------------------*//* USER CODE BEGIN PV */uint8_t key_rval; /* USER CODE END PV *//* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); /* USER CODE BEGIN PFP *//* USER CODE END PFP *//* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 *//* USER CODE END 0 *//*** brief The application entry point.* retval int*/ 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();/* 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();/* USER CODE BEGIN 2 */LCD_Init();LCD_Clear(White);LCD_SetBackColor(White);LCD_SetTextColor(Black);/* USER CODE END 2 *//* Infinite loop *//* USER CODE BEGIN WHILE */while (1){ Key_Proc();Lcd_proc(); /* USER CODE END WHILE *//* USER CODE BEGIN 3 */}/* USER CODE END 3 */ }/*** brief System Clock Configuration* retval None*/ void SystemClock_Config(void) {RCC_OscInitTypeDef RCC_OscInitStruct {0};RCC_ClkInitTypeDef RCC_ClkInitStruct {0};/** Configure the main internal regulator output voltage*/HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);/** Initializes the RCC Oscillators according to the specified parameters* in the RCC_OscInitTypeDef structure.*/RCC_OscInitStruct.OscillatorType RCC_OSCILLATORTYPE_HSE;RCC_OscInitStruct.HSEState RCC_HSE_ON;RCC_OscInitStruct.PLL.PLLState RCC_PLL_ON;RCC_OscInitStruct.PLL.PLLSource RCC_PLLSOURCE_HSE;RCC_OscInitStruct.PLL.PLLM RCC_PLLM_DIV3;RCC_OscInitStruct.PLL.PLLN 20;RCC_OscInitStruct.PLL.PLLP RCC_PLLP_DIV2;RCC_OscInitStruct.PLL.PLLQ RCC_PLLQ_DIV2;RCC_OscInitStruct.PLL.PLLR RCC_PLLR_DIV2;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_DIV1;RCC_ClkInitStruct.APB2CLKDivider RCC_HCLK_DIV1;if (HAL_RCC_ClockConfig(RCC_ClkInitStruct, FLASH_LATENCY_2) ! HAL_OK){Error_Handler();} }/* USER CODE BEGIN 4 *//* USER CODE END 4 *//*** brief This function is executed in case of error occurrence.* retval None*/ void Error_Handler(void) {/* USER CODE BEGIN Error_Handler_Debug *//* User can add his own implementation to report the HAL error return state */__disable_irq();while (1){}/* USER CODE END Error_Handler_Debug */ }#ifdef USE_FULL_ASSERT /*** brief Reports the name of the source file and the source line number* where the assert_param error has occurred.* param file: pointer to the source file name* param line: assert_param error line source number* retval None*/ void assert_failed(uint8_t *file, uint32_t line) {/* USER CODE BEGIN 6 *//* User can add his own implementation to report the file name and line number,ex: printf(Wrong parameters value: file %s on line %d\r\n, file, line) *//* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */SECOND.第二种高亮类型 只需要将LCD_SetTextColor(Blue)设置为LCD_SetBackColor 3.效果展示 key1换页 key2换行 key3加数 key4减数 演示 开源代码 通过网盘分享的文件新建文件夹.zip 链接: https://pan.baidu.com/s/159nyhzLd4xkYirNAKgf00w?pwd0820 提取码: 0820
http://www.dnsts.com.cn/news/98896.html

相关文章:

  • 雄安专业网站建设地产项目合作开发网
  • python可以做网站吗厦门网页设计招聘
  • 成都网站建设推广详简历网站免费
  • 中国轻工建设公司网站专业网站定制哪家好
  • 长沙网站制作品牌推荐5家
  • 建设机械网站机构辽宁建设工程信息网直接发包工程
  • 电脑做网站教学iis7.5发布网站教程
  • 深圳餐饮网站建设网站设计师工作室
  • 网站定制怎么收费wordpress员工管理系统
  • 做机网站云南网站设计联系方式
  • 做网站需要撑握哪些技术wordpress入门视频教程
  • 免费字体设计 常见网站响应式网站模板下载
  • 河南网站设计网站建设微信端
  • 5173网站源码厦门外贸网站建设公司
  • 个人备案网站做淘宝客可以用吗怎么做百度网页
  • 建设公司网站开发方案linux如何架设网站
  • 网站怎么做付费项目十堰网站建设报价
  • 网站建设推荐华网天下项目经理查询系统
  • 网站建设优化需要懂那些知识网络系统集成结课论文
  • 南京江宁网站建设在线设计名片
  • 杭州市社区建设网站做一个网站一般费用
  • 销售型企业网站建设应遵守的原则凡科互动官网登录入口官方
  • 有网站前端如何做后台做网站的文案
  • 网站列表页怎么做的wordpress 免插件 cdn
  • 网站主题模板下载安装购物电商型网站怎么做
  • 徐州网站平台漳州正规网站建设公司
  • 学院网站建设管理山东省建设教育集团网站
  • 全国二级建造师查询网站外包加工网是不是骗钱的
  • wordpress更改主站点网站建设与管理考题
  • 云南制作网站的公司建设网站的公司兴田德润怎么联系