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

建设教育网站费用wordpress添加编辑器

建设教育网站费用,wordpress添加编辑器,科技词语,重庆网站优化公司怎么样一.题目分析 #xff08;1#xff09;.题目 #xff08;2#xff09;.题目分析 1.串口功能分析 a.串口接收车辆出入信息#xff1a;通过查询车库的车判断车辆是进入/出去 b.串口输出计费信息#xff1a;输出编号#xff0c;时长和费用 c.计算停车时长是难点#x…一.题目分析 1.题目 2.题目分析 1.串口功能分析 a.串口接收车辆出入信息通过查询车库的车判断车辆是进入/出去 b.串口输出计费信息输出编号时长和费用  c.计算停车时长是难点需要将年月日时分秒全部都转换成秒 d.当接收到的字符串格式不正确或者逻辑错误就输出Error e.数据库 22个字节构成一组最多有八组然后定义结构体变量该结构体的数据结构为车类型车编号时间的数据格式用该结构体变量创造一个数组 3.逻辑导图 二CubeMX配置 由于蓝桥杯使用的板子都是STM32G431RBT6配置都是相同的模板已经在第六届蓝桥杯嵌入式省赛程序设计题解析基于HAL库-CSDN博客配置完成大家可以前往学习 三相关代码实现 1MAIN 1.全局变量声明 #include main.h #include RCC\bsp_rcc.h #include KEY_LED\bsp_key_led.h #include LCD\bsp_lcd.h #include UART\bsp_uart.h #include TIM\bsp_tim.h #include string.h//***全局变量声明区 //*减速变量 __IO uint32_t uwTick_Key_Set_Point 0;//控制Key_Proc的执行速度 __IO uint32_t uwTick_Led_Set_Point 0;//控制Led_Proc的执行速度 __IO uint32_t uwTick_Lcd_Set_Point 0;//控制Lcd_Proc的执行速度 __IO uint32_t uwTick_Usart_Set_Point 0;//控制Usart_Proc的执行速度//*按键扫描专用变量 uint8_t ucKey_Val, unKey_Down, ucKey_Up, ucKey_Old;//*LED专用变量 uint8_t ucLed;//*LCD显示专用变量 uint8_t Lcd_Disp_String[21];//最多显示20个字符//*串口专用变量 uint16_t counter 0; uint8_t str_str[40]; uint8_t rx_buffer;//***子函数声明区 void Key_Proc(void); void Led_Proc(void); void Lcd_Proc(void); void Usart_Proc(void);//全局变量区 _Bool Disp_Num;//0-数据显示1-费率设置 _Bool PWM_Output_Num;//0-低电平1-PWMfloat VNBR_Price 2.00; float CNBR_Price 3.50;uint8_t VNBR_Use_Num; uint8_t CNBR_Use_Num; uint8_t No_Use_Num 8;uint8_t RX_BUF[200];//用于缓冲接收200个字节的数量 uint8_t Rx_Counter;//用于记录接收了多少个数据同时可以索引RX_BUF中的数据位置typedef struct {uint8_t type[5];uint8_t id[5];uint8_t year_in;uint8_t month_in;uint8_t day_in;uint8_t hour_in;uint8_t min_in;uint8_t sec_in;_Bool notEmpty; } Car_Data_Storage_Type;Car_Data_Storage_Type Car_Data_Storage[8];//数据库构建完毕用于存储8个进来的车的信息 2.系统主函数 int main(void) {/* Reset of all peripherals, Initializes the Flash interface and the Systick. */HAL_Init();/* Configure the system clock */SystemClock_Config();/*bsp资源的初始化*/KEY_LED_Init();LCD_Init();LCD_Clear(Black);LCD_SetBackColor(Black);LCD_SetTextColor(White); UART1_Init();PWM_OUTPUT_TIM17_Init();//*串口接收中断打开HAL_UART_Receive_IT(huart1, (uint8_t *)(rx_buffer), 1); __HAL_TIM_SET_COMPARE(htim17,TIM_CHANNEL_1, 0);//强制配置成低电平HAL_TIM_PWM_Start(htim17,TIM_CHANNEL_1); //PA7 while (1){Key_Proc();Led_Proc();Lcd_Proc();Usart_Proc();}} 3.按键扫描子函数 a. 逻辑框图 b. 程序源码 //***按键扫描子函数 void Key_Proc(void) {if((uwTick - uwTick_Key_Set_Point)50) return;//减速函数uwTick_Key_Set_Point uwTick;ucKey_Val Key_Scan();unKey_Down ucKey_Val (ucKey_Old ^ ucKey_Val); ucKey_Up ~ucKey_Val (ucKey_Old ^ ucKey_Val); ucKey_Old ucKey_Val;switch(unKey_Down){case 1://B1Disp_Num ^ 0x1;LCD_Clear(Black);break;case 2://B2if(Disp_Num 1)//费率设置界面{VNBR_Price 0.5;CNBR_Price 0.5; } break; case 3://B3if(Disp_Num 1)//费率设置界面{if((VNBR_Price - 0.5) 0){VNBR_Price - 0.5;CNBR_Price - 0.5; }} break; case 4://B4PWM_Output_Num ^ 0x1;if(PWM_Output_Num 0)//低电平{__HAL_TIM_SET_COMPARE(htim17,TIM_CHANNEL_1, 0);//强制配置成低电平}else//高电平 {__HAL_TIM_SET_COMPARE(htim17,TIM_CHANNEL_1, 100);//强制配置成PWM电平 }break; } } 4.LED扫描子函数 a. 逻辑框图 b.  程序源码 void Led_Proc(void) {if((uwTick - uwTick_Led_Set_Point)200) return;//减速函数uwTick_Led_Set_Point uwTick;if(No_Use_Num 0)//表示还有车位{ucLed | 0x1; }else//如果空闲{ucLed (~0x1); }if(PWM_Output_Num 0)//低电平{ucLed (~0x2); }else//PWM{ ucLed | 0x2; }LED_Disp(ucLed); } 5. LCD扫描 a. 程序框图 b. 程序源码 void Lcd_Proc(void) {if((uwTick - uwTick_Lcd_Set_Point)100) return;//减速函数uwTick_Lcd_Set_Point uwTick;//用户代码if(Disp_Num 0)//数据界面{sprintf((char *)Lcd_Disp_String, Data);LCD_DisplayStringLine(Line1, Lcd_Disp_String); sprintf((char *)Lcd_Disp_String, CNBR:%1d,(unsigned int)CNBR_Use_Num);LCD_DisplayStringLine(Line3, Lcd_Disp_String); sprintf((char *)Lcd_Disp_String, VNBR:%1d,(unsigned int)VNBR_Use_Num);LCD_DisplayStringLine(Line5, Lcd_Disp_String); sprintf((char *)Lcd_Disp_String, IDLE:%1d,(unsigned int)No_Use_Num);LCD_DisplayStringLine(Line7, Lcd_Disp_String); }else//参数界面{sprintf((char *)Lcd_Disp_String, Para);LCD_DisplayStringLine(Line1, Lcd_Disp_String); sprintf((char *)Lcd_Disp_String, CNBR:%4.2f,CNBR_Price);LCD_DisplayStringLine(Line3, Lcd_Disp_String); sprintf((char *)Lcd_Disp_String, VNBR:%4.2f,VNBR_Price);LCD_DisplayStringLine(Line5, Lcd_Disp_String); } } 6. 判别接收到22个字符是否合法函数 a. 逻辑框图 b. 程序源码 _Bool CheckCmd(uint8_t* str)//用于判别接受的22个字符是否合法 {if(Rx_Counter ! 22)return 0;//表示还不够22个数据if(((str[0]C)||(str[0]V))(str[1]N)(str[2]B)(str[3]R)(str[4]:)(str[9]:)){uint8_t i;for(i 10; i 22;i){if((str[i]9)||(str[i]0))return 0;}return 1;//表示接收到的数据没问题} }7. 从长字符串提取一段给短字符串函数 a. 逻辑分析 传入参数为数据的类型提取的位置从第几位开始提取提取的个数 b. 程序源码 void substr(uint8_t* d_str, uint8_t* s_str, uint8_t locate, uint8_t length)//从长字符串里边提取出一段给短字符串 { uint8_t i 0;for(i0; ilength; i){d_str[i] s_str[locate i];}d_str[length] \0; } .判别车是否在车库里面 逻辑分析 使用到了strcmp函数比较字符串是否相同相同就返回 【函数原型】    int strcmp(const char *s1, const char *s2);         【参数】s1, s2 为需要比较的两个字符串。         【返回值】若参数s1 和s2 字符串相同则返回0s1 若大于s2 则返回大于0 的值s1 若小于s2 则返回小于0 的值 程序源码 //判别车的id是否在库里边 uint8_t isExist(uint8_t* str) {uint8_t i 0; for(i0; i8; i){if((strcmp((const char*)str,(const char*)Car_Data_Storage[i].id)) 0)//表示字符串匹配有这个字符串 {return i;//如果该id在数据库存着返回这个id在数据库当中的位置}} return 0xFF;//如果没有返回oxff } .判断号哪个位置有空挡 逻辑分析 轮询数据库里面的空档标志位当标志位为说明没有被使用则返回第号位置 程序源码 uint8_t findLocate(void) {uint8_t i 0;for(i 0;i 7; i ){if(Car_Data_Storage[i].notEmpty 0)return i;//0-7号位}return 0XFF; } .串口扫描子函数 逻辑框图 程序源码 void Usart_Proc(void) {if((uwTick - uwTick_Usart_Set_Point)100) return;//减速函数uwTick_Usart_Set_Point uwTick; if(CheckCmd(RX_BUF))//粗糙的判断第一步判别数据个数以及数据格式是否合法{uint8_t car_id[5];uint8_t car_type[5]; uint8_t year_temp,month_temp,day_temp,hour_temp,min_temp,sec_temp;year_temp (((RX_BUF[10] - 0)*10) (RX_BUF[11] - 0)); month_temp (((RX_BUF[12] - 0)*10) (RX_BUF[13] - 0)); day_temp (((RX_BUF[14] - 0)*10) (RX_BUF[15] - 0)); hour_temp (((RX_BUF[16] - 0)*10) (RX_BUF[17] - 0)); min_temp (((RX_BUF[18] - 0)*10) (RX_BUF[19] - 0)); sec_temp (((RX_BUF[20] - 0)*10) (RX_BUF[21] - 0)); if((month_temp12)||(day_temp31)||(hour_temp23)||(min_temp59)||(sec_temp59))//验证日期和时间是否合法{goto SEND_ERROR;}substr(car_id, RX_BUF, 5, 4);//提取车的idsubstr(car_type, RX_BUF, 0, 4); //提取车的类型//**********************车还没有进入******if(isExist(car_id) 0xFF)//表示库里边没有这辆车的ID表示这个车还没进入{uint8_t locate findLocate();//找到哪个地方是空的if(locate 0xFF)//没有找到哪个地方是空的{goto SEND_ERROR;}//准备存储substr(Car_Data_Storage[locate].type, car_type, 0, 4);//把当前车的类型存入 substr(Car_Data_Storage[locate].id, car_id, 0, 4);//把当前车的id存入Car_Data_Storage[locate].year_in year_temp;Car_Data_Storage[locate].month_in month_temp; Car_Data_Storage[locate].day_in day_temp; Car_Data_Storage[locate].hour_in hour_temp; Car_Data_Storage[locate].min_in min_temp; Car_Data_Storage[locate].sec_in sec_temp; Car_Data_Storage[locate].notEmpty 1;if(Car_Data_Storage[locate].type[0] C)CNBR_Use_Num;else if(Car_Data_Storage[locate].type[0] V)VNBR_Use_Num;No_Use_Num--; }//**********************如果车已经进来了现在是出去****** else if(isExist(car_id) ! 0xFF)//表示数据库里有他的信息返回他在数据库的位置{int64_t Second_derta;//用于核算小时的差值 uint8_t in_locate isExist(car_id);//记住在数据库中的位置if(strcmp((const char*)car_type,(const char*)Car_Data_Storage[in_locate].type) ! 0)//说明不匹配{goto SEND_ERROR; }//2000 2001 2002 //1 2 3Second_derta (year_temp - Car_Data_Storage[in_locate].year_in)*365*24*60*60 (month_temp - Car_Data_Storage[in_locate].month_in)*30*24*60*60\(day_temp - Car_Data_Storage[in_locate].day_in)*24*60*60 (hour_temp - Car_Data_Storage[in_locate].hour_in)*60*60 \(min_temp - Car_Data_Storage[in_locate].min_in)*60 (sec_temp - Car_Data_Storage[in_locate].sec_in);if(Second_derta 0)//说明出去的时间超前进去的时间{goto SEND_ERROR; }Second_derta (Second_derta 3599)/3600; //小时数据已经核算出来sprintf(str_str, %s:%s:%d:%.2f\r\n,Car_Data_Storage[in_locate].type,Car_Data_Storage[in_locate].id,(unsigned int)Second_derta,(Second_derta*(Car_Data_Storage[in_locate].id[0]C?CNBR_Price:VNBR_Price)));HAL_UART_Transmit(huart1,(unsigned char *)str_str, strlen(str_str), 50); if(Car_Data_Storage[in_locate].type[0] C)CNBR_Use_Num--;else if(Car_Data_Storage[in_locate].type[0] V)VNBR_Use_Num--;No_Use_Num; memset(Car_Data_Storage[in_locate],0,sizeof(Car_Data_Storage[in_locate]));//清空该位置所有内容为0}goto CMD_YES;SEND_ERROR: sprintf(str_str, Error\r\n);HAL_UART_Transmit(huart1,(unsigned char *)str_str, strlen(str_str), 50);CMD_YES:memset(RX_BUF[0],0,sizeof(RX_BUF));//清空该位置所有内容为0Rx_Counter 0;} } 11.串口接收中断回调函数 a.逻辑分析 实现将字符数据保存到环形缓冲区里面 b. 程序源码 //串口接收中断回调函数 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {RX_BUF[Rx_Counter] rx_buffer;Rx_Counter;HAL_UART_Receive_IT(huart1, (uint8_t *)(rx_buffer), 1); } 2BSP 在第六届蓝桥杯嵌入式省赛程序设计题解析基于HAL库-CSDN博客里面有详细的讲解大家可前往此链接学习
http://www.w-s-a.com/news/27452/

相关文章:

  • 天津建设交培训中心网站做网站起名字
  • 黑河北京网站建设湛江市住房和城乡建设局网站
  • 网站建设拾金手指下拉十九企业查询官网
  • 邢台提供网站建设公司哪家好五合一建站
  • 京东网站设计代码驻马店做网站的公司
  • 织梦网站模板使用教程福州网站建设工作
  • 做网站要准备的需求asp 网站后台
  • 滨州网站开发公司中立建设集团有限公司网站
  • 泰安建设厅网站做网站为什么要建站点
  • 有什么好的手机推荐网站创建网站需要哪些工作
  • 网站能给企业带来什么上饶市网站建设公司
  • 学做网站卖东西去哪学南宁网站建设gxjzdrj
  • 欧美网站建设案例网站开发 男生
  • 网站正在开发中做电子元器件的网站
  • 做网站搭建的公司中国建设银行官网站u盾证书
  • 大连哪里有手机自适应网站建设公司网站介绍模板 html
  • 佛山模板建站宣传片制作公司电话
  • 文字网站居中能自己做网站接业务吗
  • 免备案自助建站网站广州珈瑶公司是哪一年注册的
  • ps做网站界面wordpress为图片添加圆角
  • seo优化推广业务员招聘seo顾问服务福建
  • 成都私人网站建设seo网站推广方案策划书
  • 广州网站建设工作室wordpress log
  • 网站后台添加wordpress h1标签优化
  • 自己做网站都需要什么高密 网站建设
  • 网站语言选择郑州本地做团购的网站
  • dw网页设计模板图片谷歌wordpress优化
  • 网站seo优化要怎么做礼品公司怎么做网站
  • 做网页网站需要钱吗提供常州微信网站建设
  • 网站建设文化效果广东网站建设哪家有