请选择 进入手机版 | 继续访问电脑版

基于IIC的OLED数据显示

[复制链接]
陈雪霜 发表于 2020-12-31 20:29:46 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
这里写目录标题



下载取模软件

网址:
链接: link.

下载完成解压后打开:

设置成这样:

转换一下输出的进制:

这样就可以得到自己想要的子模啦!
通过OLED显示自己的姓名学号

用keil打开之前下载好的步调包:

编译步调,然后打开oledfont.h

将自己生成的子模按照它的格式粘贴上去:

main.c修改为:
  1. #include "delay.h"#include "sys.h"#include "oled.h"#include "bmp.h" int main(void) {        u8 t;                delay_init();                     //延时函数初始化                          NVIC_Configuration();          //设置NVIC中断分组2:2位抢占优先级,2位响应优先级         LED_Init();                             //LED端口初始化        //                delay_ms(8000);                OLED_Init();                        //初始化OLED                  OLED_Clear(0)          ;      t='  ';                        while(1)         {                                OLED_ShowCHinese(6,0,0);//马                OLED_ShowCHinese(26,0,1);//昕                OLED_ShowString(4,3,"631807030221",16);           t++;        }}
复制代码
编译:

然后将步调烧录进进去

结果:

通过OLED显示AHT20的温度和湿度

AHT20工程代码:
链接: link.
添加几个文件进去,详细文件参考之前的博客:
链接: link.
生成子模:
  1.     "温",0x00,0x00,0x23,0xF8,0x12,0x08,0x12,0x08,0x83,0xF8,0x42,0x08,0x42,0x08,0x13,0xF8,  0x10,0x00,0x27,0xFC,0xE4,0xA4,0x24,0xA4,0x24,0xA4,0x24,0xA4,0x2F,0xFE,0x00,0x00,/*"温",0*/        "度",0x01,0x00,0x00,0x80,0x3F,0xFE,0x22,0x20,0x22,0x20,0x3F,0xFC,0x22,0x20,0x22,0x20,  0x23,0xE0,0x20,0x00,0x2F,0xF0,0x24,0x10,0x42,0x20,0x41,0xC0,0x86,0x30,0x38,0x0E,/*"度",0*/        "湿",0x00,0x00,0x27,0xF8,0x14,0x08,0x14,0x08,0x87,0xF8,0x44,0x08,0x44,0x08,0x17,0xF8,  0x11,0x20,0x21,0x20,0xE9,0x24,0x25,0x28,0x23,0x30,0x21,0x20,0x2F,0xFE,0x00,0x00,/*"湿",0*/        "显",0x00,0x00,0x1F,0xF0,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x10,0x1F,0xF0,  0x04,0x40,0x44,0x44,0x24,0x44,0x14,0x48,0x14,0x50,0x04,0x40,0xFF,0xFE,0x00,0x00,/*"显",0*/        "示",0x00,0x00,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x01,0x00,  0x01,0x00,0x11,0x10,0x11,0x08,0x21,0x04,0x41,0x02,0x81,0x02,0x05,0x00,0x02,0x00,/*"示",0*/
复制代码
修改main函数:
  1. #include "delay.h"#include "usart.h"#include "bsp_i2c.h"#include "sys.h"#include "oled.h"#include "gui.h"#include "test.h"int main(void){                delay_init();                           //延时函数初始化                      uart_init(115200);                 IIC_Init();                          NVIC_Configuration();            //设置NVIC中断分组2:2位抢占优先级,2位响应优先级                 OLED_Init();                                 //初始化OLED          OLED_Clear(0);         while(1)        {                //printf("温度湿度显示");                read_AHT20_once();                OLED_Clear(0);                 delay_ms(1500);  }}
复制代码
烧录即可显示!
通过OLED显示上下或左右的滑动显示长字符

生成子模:

  1. 欢(0) 迎(1) 来(2) 到(3) 重(4) 庆(5) 交(6) 通(7) 大(8) 学(9){0x32,0x36,0x34,0x33,0x38,0x57,0x2,0x12,0x240,0x19,0x16,0x16,0x20,0x24,0x0,0x0},{0x8,0x16,0x96,0x128,0x65,0x50,0x4,0x24,0x96,0x128,0x96,0x24,0x4,0x2,0x1,0x0},/*"欢",0*/{0x2,0x2,0x66,0x51,0x0,0x0,0x63,0x32,0x64,0x0,0x63,0x32,0x32,0x63,0x0,0x0},{0x0,0x2,0x4,0x248,0x4,0x2,0x242,0x34,0x66,0x2,0x254,0x66,0x34,0x194,0x2,0x0},/*"迎",1*/{0x0,0x16,0x16,0x20,0x19,0x16,0x16,0x255,0x16,0x16,0x17,0x22,0x16,0x16,0x0,0x0},{0x132,0x132,0x136,0x136,0x144,0x160,0x192,0x255,0x192,0x160,0x144,0x136,0x136,0x132,0x132,0x0},/*"来",2*/{0x66,0x70,0x74,0x82,0x99,0x66,0x74,0x70,0x67,0x0,0x31,0x0,0x0,0x255,0x0,0x0},{0x2,0x35,0x34,0x34,0x254,0x36,0x36,0x36,0x4,0x0,0x240,0x2,0x1,0x254,0x0,0x0},/*"到",3*/{0x8,0x8,0x40,0x43,0x42,0x42,0x42,0x63,0x74,0x74,0x74,0x203,0x72,0x8,0x8,0x0},{0x2,0x2,0x10,0x234,0x170,0x170,0x170,0x254,0x170,0x170,0x170,0x234,0x10,0x2,0x2,0x0},/*"重",4*/{0x0,0x0,0x63,0x32,0x33,0x33,0x33,0x161,0x111,0x33,0x33,0x33,0x33,0x33,0x32,0x0},{0x2,0x12,0x240,0x1,0x2,0x4,0x24,0x96,0x128,0x96,0x24,0x4,0x2,0x1,0x1,0x0},/*"庆",5*/{0x16,0x16,0x17,0x22,0x16,0x16,0x144,0x112,0x16,0x16,0x17,0x20,0x18,0x17,0x16,0x0},{0x1,0x129,0x2,0x2,0x132,0x68,0x40,0x16,0x40,0x68,0x130,0x2,0x1,0x129,0x1,0x0},/*"交",6*/{0x2,0x66,0x51,0x0,0x0,0x71,0x68,0x84,0x84,0x79,0x84,0x100,0x68,0x7,0x0,0x0},{0x1,0x2,0x252,0x2,0x1,0x255,0x145,0x145,0x145,0x253,0x145,0x149,0x147,0x253,0x1,0x0},/*"通",7*/{0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x255,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0},{0x1,0x1,0x2,0x4,0x8,0x48,0x192,0x0,0x192,0x48,0x8,0x4,0x2,0x1,0x1,0x0},/*"大",8*/{0x2,0x12,0x136,0x105,0x9,0x9,0x137,0x105,0x9,0x9,0x25,0x40,0x200,0x10,0x12,0x0},{0x32,0x32,0x32,0x32,0x32,0x34,0x33,0x126,0x96,0x160,0x32,0x32,0x32,0x32,0x32,0x0},/*"学",9*/
复制代码
修改main.c函数:
  1. int main(void){                delay_init();                           //延时函数初始化                  NVIC_Configuration();            //设置NVIC中断分组2:2位抢占优先级,2位响应优先级                 OLED_Init();                                 //初始化OLED          OLED_Clear(0);             //清屏(全黑)        while(1)         {                        OLED_WR_Byte(0x2E,OLED_CMD);        //关闭滚动                OLED_WR_Byte(0x27,OLED_CMD);        //水平向左或者右滚动 26/27                OLED_WR_Byte(0x00,OLED_CMD);        //虚拟字节                OLED_WR_Byte(0x00,OLED_CMD);        //起始页 0                OLED_WR_Byte(0x07,OLED_CMD);        //滚动时间隔断                OLED_WR_Byte(0x01,OLED_CMD);        //终止页 1                OLED_WR_Byte(0x00,OLED_CMD);        //虚拟字节                OLED_WR_Byte(0xFF,OLED_CMD);        //虚拟字节                SHOW_name();                OLED_WR_Byte(0x2F,OLED_CMD);        //开启滚动                                delay_ms(1500);                        }}
复制代码
输出文字:

串口烧录:


总结

以上就是全部内容

来源:https://blog.csdn.net/weixin_51098062/article/details/111994387
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

发布主题

专注素材教程免费分享
全国免费热线电话

18768367769

周一至周日9:00-23:00

反馈建议

27428564@qq.com 在线QQ咨询

扫描二维码关注我们

Powered by Discuz! X3.4© 2001-2013 Comsenz Inc.( 蜀ICP备2021001884号-1 )