[原创]
基于GD32F450的图标式多功能应用系统设计(3)
接续上一贴
波形绘制函数如下:
- if(i==3)
- {
- LCD_Clear(WHITE);
- sp=95;
- POINT_COLOR=RED;
- LCD_DrawLine(10, 304, 230, 304);
- LCD_DrawLine(125, 10, 125, 304);
- POINT_COLOR=BLUE;
- for ( i = 0 ; i < 64; i++)
- {
- sj=values[i][0];
- sj<<=8;
- sj|=values[i][1];
- sj=sj/20;
- LCD_DrawLine(220-sp, 300-4*(i-1), 220-sj, 300-4*(i));
- sp=sj;
- }
- delay_1ms(1000);
- LCD_Clear(WHITE);
- rcu_config();
- /* GPIO configuration */
- gpio_config();
- /* SYSTICK configuration */
- systick_config();
- /* ADC configuration */
- adc_config();
- adc_resolution_config(ADC1,ADC_RESOLUTION_12B);
- adc_oversample_mode_config(ADC1,ADC_OVERSAMPLING_ALL_CONVERT,ADC_OVERSAMPLING_SHIFT_NONE,ADC_OVERSAMPLING_SHIFT_NONE);
- adc_oversample_mode_disable(ADC1);
- while(SET == gpio_input_bit_get(GPIOA,GPIO_PIN_0))
- {
- LCD_Clear(WHITE);
- sp=95;
- POINT_COLOR=RED;
- LCD_DrawLine(10, 304, 230, 304);
- LCD_DrawLine(125, 10, 125, 304);
- POINT_COLOR=BLUE;
- for ( i = 0 ; i < 64; i++)
- {
- adc_enable(ADC1);
- adc_software_trigger_enable(ADC1,ADC_REGULAR_CHANNEL);
- while(RESET == adc_flag_get(ADC1,ADC_FLAG_EOC));
- sj=ADC_RDATA(ADC1);
- sj=sj/10;
- LCD_DrawLine(320-sp, 300-4*(i-1), 320-sj, 300-4*(i));
- sp=sj;
- delay_1ms(20);
- }
- }
- goto loop;
- }
环境温湿度检测的程序如下:
- if(i==4)
- {
- i=0;
- LCD_Clear(WHITE);
- show_imageh(10,300,0);
- POINT_COLOR=RED;
- BACK_COLOR=WHITE;
- DHT11_Init();
- while(SET == gpio_input_bit_get(GPIOA,GPIO_PIN_0))
- {
- DHT11_Read_Data(&temp,&humi);
- LCD_ShowCharh(100,100,'T',1);
- LCD_ShowCharh(100,90,'e',1);
- LCD_ShowCharh(100,80,'m',1);
- LCD_ShowCharh(100,70,'p',1);
- LCD_ShowCharh(100,60,':',1);
- LCD_ShowCharh(100,50,temp/10+'0',0);
- LCD_ShowCharh(100,40,temp%10+'0',0);
- LCD_ShowCharh(120,100,'H',1);
- LCD_ShowCharh(120,90,'u',1);
- LCD_ShowCharh(120,80,'m',1);
- LCD_ShowCharh(120,70,'i',1);
- LCD_ShowCharh(120,60,':',1);
- LCD_ShowCharh(120,50,humi/10+'0',0);
- LCD_ShowCharh(120,40,humi%10+'0',0);
- delay_1ms(200);
- }
- while(SET == gpio_input_bit_get(GPIOA,GPIO_PIN_0));
- goto loop;
- }
多时段设置处理的程序如下:
- if(i==6)
- {
- LCD_Clear(WHITE);
- show_imageh(10,300,0);
- showhanzi16h(60,80,0,0);
- showhanzi16h(60,60,1,0);
- showhanzi16h(60,40,2,0);
- rtc_show_time();
- timer_channel_output_pulse_value_config(TIMER1,TIMER_CH_1,0);
- GPIO_BC(GPIOB) = GPIO_PIN_3;
- GPIO_BC(GPIOB) = GPIO_PIN_4;
- GPIO_BC(GPIOD) = GPIO_PIN_7;
- t=rtc_initpara.minute;
- LCD_ShowCharh(100,50,t/16+'0',0);
- LCD_ShowCharh(100,40,t%16+'0',0);
- LCD_ShowCharh(100,20,'S',0);
- LCD_ShowCharh(100,10,'T',0);
- LCD_ShowCharh(140,50,(t+1)/16+'0',0);
- LCD_ShowCharh(140,40,(t+1)%16+'0',0);
- LCD_ShowCharh(160,50,(t+2)/16+'0',0);
- LCD_ShowCharh(160,40,(t+2)%16+'0',0);
- LCD_ShowCharh(180,50,(t+3)/16+'0',0);
- LCD_ShowCharh(180,40,(t+3)%16+'0',0);
- c1=0;
- c2=0;
- c3=0;
- c4=0;
- while(SET == gpio_input_bit_get(GPIOA,GPIO_PIN_0))
- {
- rtc_show_time();
- i=rtc_initpara.minute;
- if((i==(t+0x01))&&(c1==0))
- {
- GPIO_BOP(GPIOB) = GPIO_PIN_4;
- LCD_ShowCharh(140,20,'O',0);
- LCD_ShowCharh(140,10,'N',0);
- c1=1;
- playn(1);
- for ( i = 0 ; i < 10; i++)
- {
- usart_data_transmit(USART1, cmd3[i]);// play ok
- delay_1ms(10);
- }
- }
- if((i==(t+0x02))&&(c2==0))
- {
- timer_channel_output_pulse_value_config(TIMER1,TIMER_CH_1,8000);
- LCD_ShowCharh(160,20,'O',0);
- LCD_ShowCharh(160,10,'N',0);
- c2=1;
- playn(2);
- for ( i = 0 ; i < 10; i++)
- {
- usart_data_transmit(USART1, cmd3[i]);
- delay_1ms(10);
- }
- }
- if((i==(t+0x03)) &&(c3==0))
- {
- GPIO_BOP(GPIOD) = GPIO_PIN_7;
- LCD_ShowCharh(180,20,'O',0);
- LCD_ShowCharh(180,10,'N',0);
- c3=1;
- playn(3);
- for ( i = 0 ; i < 10; i++)
- {
- usart_data_transmit(USART1, cmd3[i]);
- delay_1ms(10);
- }
- }
-
- if((i==(t+0x04))&&(c4==0))
- {
- GPIO_BC(GPIOB) = GPIO_PIN_4;
- timer_channel_output_pulse_value_config(TIMER1,TIMER_CH_1,0);
- GPIO_BC(GPIOD) = GPIO_PIN_7;
- LCD_ShowCharh(140,20,'O',0);
- LCD_ShowCharh(140,10,'F',0);
- LCD_ShowCharh(160,20,'O',0);
- LCD_ShowCharh(160,10,'F',0);
- LCD_ShowCharh(180,20,'O',0);
- LCD_ShowCharh(180,10,'F',0);
- c4=1;
- }
-
- }
- goto loop;
- }
未完待续。。。
此内容由EEWORLD论坛网友jinglixixi原创,如需转载或用于商业用途需征得作者同意并注明出处