C8T6测电压-OLED显示
- #include "stdio.h"
- #include "delay.h"
- #include "sys.h"
- #include "oled.h"
- #include "adc.h"
- #include "stm32f10x_adc.h"
- int main(void)
- {
- u16 adcx;
- unsigned char chr[5];
- float temp ;
- delay_init(); //延时函数初始化
-
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
- OLED_Init();
- OLED_ColorTurn(0);
- OLED_DisplayTurn(0);
- OLED_Refresh();
- Adc_Init();
-
-
- while(1)
- {
- //OLED_ShowNum(0,0,67,8,16);
- OLED_ShowString(0,0,"2021/04/13",16);
-
- OLED_ShowString(0,16,"adcx= ",16);
- OLED_ShowNum(48,16,adcx,4,16);
-
- // OLED_ShowString(0,32,"voltage",16);
- OLED_ShowChinese(0,32,0,16);
- OLED_ShowChinese(16,32,1,16);
- OLED_ShowString(48,32," = ",16);
- adcx=Get_Adc_Average(ADC_Channel_1,10);
- temp=(float)adcx/4096*3.300;
- sprintf((char *)chr,"%.3f",temp);//将实际电压转为字符串输出
- OLED_ShowString(72,32,chr,16);
-
- OLED_ShowChinese(0,48,2,16);
- OLED_ShowChinese(16,48,3,16);
- OLED_ShowChinese(32,48,3,16);
- OLED_Refresh();
- delay_ms(100);
-
- }
-
- }
-
复制代码
|