新手入门
- 积分
- 25
- 金钱
- 25
- 注册时间
- 2014-11-15
- 在线时间
- 0 小时
|
5金钱
#include "stm32f10x.h"
#include "bsp_usart1.h"
#include "bsp_ili9341_lcd.h"
#include "bsp_sdfs_app.h"
#include "bsp_adc.h"
extern __IO uint16_t ADC_ConvertedValue;
float ADC_ConvertedValueLocal;
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
uint8_t q;uint8_t w;uint8_t e;uint8_t r;float d;
int main(void)
{
USART1_Config();
ADC1_Init();
while (1)
{
ADC_ConvertedValueLocal =(float) ADC_ConvertedValue/4096*3.3;
d=ADC_ConvertedValueLocal*100;
q=(uint8_t)d/1000+48;w=((uint8_t)d-q*1000)/100+48;e=((uint8_t)d-q*1000-w*100)/10+48;r=(uint8_t)d-q*1000-w*100-e*10+48;
printf("\r\n The current AD value = 0x%04X \r\n", ADC_ConvertedValue);
printf("\r\n The current AD value = %f V \r\n",ADC_ConvertedValueLocal);
LCD_Init();
LCD_Clear(0, 0, 240, 320, BACKGROUND);
Sd_fs_init();
LCD_DispEnCh(5, 25, (uint8_t *)"输出的电压为", RED);
LCD_DispStr(5, 55, (uint8_t *)q, RED);
LCD_DispStr(55, 55, (uint8_t *)w, RED);
LCD_DispStr(105, 55, (uint8_t *)e, RED);
LCD_DispStr(155, 55, (uint8_t *)r, RED);
Delay(0xffffee);
}
LCD上显示的“输出电压为”是正常的,但q,w,e,r为乱码,求有什么办法可以把ADC_ConvertedValueLocal变量输出到LCD屏幕上?
|
|