#include "led.h" #include "delay.h" #include "key.h" #include "sys.h" //#include "oled.h" #include "24cxx.h" #include "OLED4PINiic.h"const u8 TEXT_Buffer[]={"Explorer STM32F4 IIC TEST"}; #define SIZE sizeof(TEXT_Buffer) int main(void) { const unsigned char *point; u16 i=0; delay_init(); //ÑÓʱº¯Êý³õʼ»¯ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//ÉèÖÃÖжÏÓÅÏȼ¶·Ö×éΪ×é2£º2λÇÀÕ¼ÓÅÏȼ¶£¬2λÏìÓ¦ÓÅÏȼ¶ // uart_init(115200); //´®¿Ú³õʼ»¯Îª115200 LED_Init(); //³õʼ»¯ÓëLEDÁ¬½ÓµÄÓ²¼þ½Ó¿Ú // KEY_Init(); //°´¼ü³õʼ»¯ AT24CXX_Init(); //IIC³õʼ»¯ OLED_init(); point= &picture_tab[0]; while(1) { OLED_ShowString(0,30,"21221054",16); OLED_ShowString(0,15,"2023/5/18",16); OLED_ShowChinese(0,0,0,16,1); OLED_ShowChinese(16,0,1,16,1); OLED_ShowChinese(32,0,2,16,1); OLED_Refresh_Gram(); //¸üÐÂÏÔʾµ½OLED delay_ms(100); if(++i > 3) { LED1=!LED1;//ÌáʾϵͳÕýÔÚÔËÐÐ i=0; } } }请在此函数的基础上,编写程序使得字体从左到右滚动显示
时间: 2024-01-10 20:05:07 浏览: 75
#include_iostream.h_
4星 · 用户满意度95%
#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
//#include "oled.h"
#include "24cxx.h"
#include "OLED4PINiic.h"
const u8 TEXT_Buffer[]={"Explorer STM32F4 IIC TEST"};
#define SIZE sizeof(TEXT_Buffer)
int main(void) {
const unsigned char *point;
u16 i=0;
delay_init();
//ÑÓʱº¯Êý³õʼ»¯
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
//ÉèÖÃÖжÏÓÅÏȼ¶·Ö×éΪ×é2£º2λÇÀÕ¼ÓÅÏȼ¶£¬2λÏìÓ¦ÓÅÏȼ¶
//uart_init(115200);
//´®¿Ú³õʼ»¯Îª115200
LED_Init();
//³õʼ»¯ÓëLEDÁ¬½ÓµÄÓ²¼þ½Ó¿Ú
// KEY_Init();
//°´¼ü³õʼ»¯
AT24CXX_Init();
//IIC³õʼ»¯
OLED_init();
point= &picture_tab[0];
while(1)
{
for(u8 j=0;j<SIZE;j++)
{
OLED_Clear();
OLED_ShowString(j*16,30,&TEXT_Buffer[j],16);
OLED_Refresh_Gram(); //¸üÐÂÏÔʾµ½OLED
delay_ms(100);
}
if(++i > 3)
{
LED1=!LED1;//ÌáʾϵͳÕýÔÚÔËÐÐ
i=0;
}
}
}
在while循环中,添加一个for循环,用于控制字体从左到右滚动。首先需要清屏,然后通过OLED_ShowString()函数控制字体显示位置,最后通过OLED_Refresh_Gram()函数刷新OLED。循环次数为字符串长度,每次循环将字符串向右移动一个字符的长度。
阅读全文