while(1)OLED_Clear();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);for(j=0;j<8;j++){ OLED_ShowChinese(64 + j * 16, 0, point[scroll_pos + j], 16, 1);}OLED_Refresh_Gram();delay_ms(SCROLL_SPEED);if (scroll_dir == 0){ scroll_pos++; if (scroll_pos + 8 >= SIZE) { scroll_dir = 1; scroll_pos = SIZE - 8; }}else{ scroll_pos--; if (scroll_pos == 0) { scroll_dir = 0; scroll_pos = 0; }}目前这段代码实现了字体从下往上滚动显示,请修改代码使其从左到右滚动显示
时间: 2024-01-03 15:03:49 浏览: 76
oled_ssd1306_单片机_oled_0.96OLED_uno_unossd1306_
以下是修改后的代码:
```
while(1) {
OLED_Clear();
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);
for(j=0;j<8;j++) {
OLED_ShowChinese(j * 16, 0, point[scroll_pos + j], 16, 1);
}
OLED_Refresh_Gram();
delay_ms(SCROLL_SPEED);
if (scroll_dir == 0){
scroll_pos++;
if (scroll_pos + 8 >= SIZE) {
scroll_dir = 1;
scroll_pos = SIZE - 8;
}
}else{
scroll_pos--;
if (scroll_pos == 0) {
scroll_dir = 0;
scroll_pos = 0;
}
}
}
```
主要修改如下:
- 在for循环中,将横坐标从 `64 + j * 16` 改为 `j * 16`,使其从左往右滚动。
- 在每次滚动时,将字体的横坐标改为 `j * 16`,使其从左往右滚动。
注意,修改后的代码可能需要根据具体情况进行调试和修改。
阅读全文