单片机的LCD屏幕供电电路好像坏了,导致LCD屏幕不能够使用。所以购置了一块OLED屏幕。店家给的代码是STM32F103C8T6的。PB6--SCL,PB6--SDA,使用硬件IIC控制。发现C8T6与RCT6与VET6的代码是兼容的。
调试过程中单片机的PB6,PB7引脚有问题,更换了单片机得到解决。但新的单片机键盘又有问题,,,所以很头痛。
原LCD画点与画线都没问题,但写字符时会出错,表现为一个随机黄色点的块,不清楚是写字符的函数坏了,还是底板的问题。待解决。
数字转字符串的函数:
// crt_sprintf.c
// compile with: /W3
// This program uses sprintf to format various
//data and place them in the string named buffer.
// 程序使用sprintf 将各种数据格式化后置于字符数组buffer中
#include <stdio.h>
int main( void )
{
char buffer[200], s[] = "computer", c = 'l';
int i = 35, j;
float fp = 1.7320534f;
// 格式化并打印各种数据到buffer
j = sprintf( buffer, " String: %s\n", s ); // C4996
j += sprintf( buffer + j, " Character: %c\n", c ); // C4996
j += sprintf( buffer + j, " Integer: %d\n", i ); // C4996
j += sprintf( buffer + j, " Real: %f\n", fp );// C4996
printf( "Output:\n%s\ncharacter count = %d\n", buffer, j );
return 0;
}
输出结果:
Output:
String: computer
Character: l
Integer: 35
Real: 1.732053
character count = 79