OLED显示一张图片

1.思路:

        void Oled_Show_Image(unsigned char *image) //
{
    unsigned char i;     //-128  ~  127位
    unsigned int j;     //j要重新定义,因为要到达图片的最后一位
                                        //行 i没有问题,j有问题  i为1时,j要从128开始这样子才会刷屏
    for(i=0;i<8;i++) 
    {
        Oled_Write_Cmd(0xB0 + i);    //page0 -- page7
        
        //每个page从第0列开始
        Oled_Write_Cmd(0x00);
        Oled_Write_Cmd(0x10);
        
        //每个page从0列到127列,依次写入0,每写入数据,列地址自动偏移
        for(j = 128*i;j<(128*(i+1));j++) //列 i等于0的时候 ,j<128  //i到7的时候 i+1=8, 其实就是j<8(i+1)最后j要<128*8                         
        {
            Oled_Write_Data(image[j]);
        }
    }
        
}
 

bug: 

        code unsigned char bmpImager[]={};数组后面要加分号

效果演示:

代码:

#include "reg52.h"
#include "intrins.h"sbit scl = P0^1;
sbit sda = P0^3;void IIC_Start()
{scl = 0; //防止雪花sda = 1;scl = 1;_nop_(); //耗时5个微妙sda = 0;_nop_();
}void IIC_Stop()
{scl = 0; //防止雪花sda = 0;scl = 1;_nop_(); //耗时5个微妙sda = 1;_nop_();
}char IIC_ACK()
{char flag;sda = 1;   //就在时钟脉冲9期间释放数据线_nop_();scl = 1;_nop_();flag = sda;_nop_();scl = 0;_nop_();return flag;}void IIC_Send_Byte(char dataSend) //发送一个字节
{int i;for(i = 0 ;i<8;i++){scl = 0;//scl 拉低,让sda做好数据准备sda = dataSend & 0x80;       // 1000 0000 获得datasend的最高位_nop_(); //发送数据建立的时间scl = 1;//scl拉高开始发送_nop_(); //数据发送时间scl = 0; // 发送完毕拉低_nop_();//dataSend = dataSend <<1;}
}void Oled_Write_Cmd(char dataCmd)
{//1.start()IIC_Start();//2.写入从机地址 b0111 1000 0x78IIC_Send_Byte(0x78);//3.ACKIIC_ACK();//4.cotrol byte : (0)(0) 000000 写入命令 (0)(1) 000000写入数据IIC_Send_Byte(0x00);//5.ACKIIC_ACK();//6.写入指令/数据IIC_Send_Byte(dataCmd);//7.ACKIIC_ACK();//8.STOPIIC_Stop();
}void Oled_Write_Data(char dataData)
{//1.start()IIC_Start();//2.写入从机地址 b0111 1000 0x78IIC_Send_Byte(0x78);//3.ACKIIC_ACK();//4.cotrol byte : (0)(0) 000000 写入命令 (0)(1) 000000写入数据IIC_Send_Byte(0x40);//5.ACKIIC_Stop();//6.写入指令/数据IIC_Send_Byte(dataData);//7.ACKIIC_ACK();//8.STOPIIC_Stop();
}void Oled_Init(void){Oled_Write_Cmd(0xAE);//--display offOled_Write_Cmd(0x00);//---set low column addressOled_Write_Cmd(0x10);//---set high column addressOled_Write_Cmd(0x40);//--set start line addressOled_Write_Cmd(0xB0);//--set page addressOled_Write_Cmd(0x81); // contract controlOled_Write_Cmd(0xFF);//--128Oled_Write_Cmd(0xA1);//set segment remapOled_Write_Cmd(0xA6);//--normal / reverseOled_Write_Cmd(0xA8);//--set multiplex ratio(1 to 64)Oled_Write_Cmd(0x3F);//--1/32 dutyOled_Write_Cmd(0xC8);//Com scan directionOled_Write_Cmd(0xD3);//-set display offsetOled_Write_Cmd(0x00);//Oled_Write_Cmd(0xD5);//set osc divisionOled_Write_Cmd(0x80);//Oled_Write_Cmd(0xD8);//set area color mode offOled_Write_Cmd(0x05);//Oled_Write_Cmd(0xD9);//Set Pre-Charge PeriodOled_Write_Cmd(0xF1);//Oled_Write_Cmd(0xDA);//set com pin configuartionOled_Write_Cmd(0x12);//Oled_Write_Cmd(0xDB);//set VcomhOled_Write_Cmd(0x30);//Oled_Write_Cmd(0x8D);//set charge pump enableOled_Write_Cmd(0x14);//Oled_Write_Cmd(0xAF);//--turn on oled panel
}void Oled_Clear()
{unsigned char i,j;for(i = 0;i<8;i++){Oled_Write_Cmd(0xB0 + i);	//page0 -- page7//每个page从第0列开始Oled_Write_Cmd(0x00);Oled_Write_Cmd(0x10);//每个page从0列到127列,依次写入0,每写入数据,列地址自动偏移for(j = 0;j<128;j++){Oled_Write_Data(0);}}}code unsigned char bmpImager[]={/*--  调入了一幅图像:C:\Users\r7000p\Desktop\路飞.bmp  --*/
/*--  宽度x高度=128x64    128*8*8--*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0x00,0xC0,0x20,0x00,0x10,0x10,0x08,0x00,0x80,0x10,0x14,0x00,0x00,0x88,0x8C,0x8C,
0xCC,0x4C,0x2C,0x1C,0x1C,0x18,0x9C,0x98,0x10,0x20,0x00,0x04,0x40,0x10,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x90,0x10,0x10,
0xF0,0x80,0xC0,0xF0,0xB0,0x20,0x20,0xE0,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x20,0xE0,0x00,0x80,0xC0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x20,0x80,0x00,0x50,0xF0,
0x60,0xF0,0xF9,0xFB,0xFB,0x3F,0x1F,0x0E,0x06,0x0E,0x7E,0x87,0x0F,0x0F,0x3F,0x7F,
0xFF,0xDF,0x3F,0x7F,0x3F,0x7F,0xFE,0xFE,0xFE,0xFE,0xF4,0xF4,0xB0,0x60,0x20,0x21,
0x20,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF9,0x81,0x81,0xFF,
0x89,0x00,0x08,0x34,0x17,0x13,0x13,0x14,0xFC,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0xC3,0x04,0x04,0x0C,0x88,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x00,0x28,0xC0,0x90,0x98,0x18,0x9C,0xFE,
0xFF,0x1F,0x03,0x07,0x00,0x00,0x42,0x42,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
0x00,0x03,0x04,0x03,0x41,0x40,0x01,0x13,0x0F,0x1F,0x7F,0x7F,0x7F,0x6E,0x98,0x30,
0xB8,0x28,0x60,0x80,0x02,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,
0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,
0x00,0x00,0x20,0x00,0x00,0x00,0x80,0x84,0x80,0x83,0x83,0x87,0x03,0x0A,0xE0,0x00,
0x13,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x09,0x08,0x08,0x02,0x08,0x08,0x0A,0x08,
0x08,0x09,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x88,0xF0,0x88,0x01,0x00,
0x01,0x23,0x22,0x63,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x02,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x11,0x80,0x10,0x08,0x01,0x03,0x07,
0x08,0x00,0x04,0x00,0x00,0x00,0xA0,0x02,0x02,0x02,0x02,0x00,0x00,0x40,0x00,0x00,
0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x44,0x0F,0x07,0x13,0x01,0x14,
0x02,0x11,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x08,0x08,0x08,
0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x40,0x40,
0xC0,0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x00,0x02,0x06,0x0E,0x0E,0x1E,0x3E,0x7E,
0x7E,0x7E,0xEE,0x80,0x80,0xC0,0xC0,0x80,0x80,0xC0,0xC0,0xE0,0x00,0x20,0x40,0x60,
0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x04,0x00,0x00,
0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0xE0,0xE0,
0xFF,0x80,0xFF,0xFF,0xF0,0xEC,0xDD,0xF2,0xC8,0x90,0xC0,0x80,0x80,0x00,0x80,0xC0,
0xE1,0x31,0xBC,0xDF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xC0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x04,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x38,0x3F,0x3F,0x3F,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x39,0x26,0x27,0x27,0x3F,
0x3E,0x3F,0x3F,0x3F,0x3F,0x3F,0x37,0x3F,0x3B,0x3F,0x3F,0x3F,0x3F,0x3F,0x3E,0x3A,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};void Oled_Show_Image(unsigned char *image)
{unsigned char i;unsigned int j;for(i =0;i<8;i++){Oled_Write_Cmd(0xB0 + i);	//page0 -- page7//每个page从第0列开始Oled_Write_Cmd(0x00);Oled_Write_Cmd(0x10);//每个page从0列到127列,依次写入0,每写入数据,列地址自动偏移for(j = 128*i;j<(128*(i+1));j++){Oled_Write_Data(image[j]);}}}void main()
{//1.Oled初始化Oled_Init();//2.选择一个位置//2.1选择页寻址模式Oled_Write_Cmd(0x20);Oled_Write_Cmd(0x02);Oled_Clear();Oled_Show_Image(bmpImager);while(1); //程序不能退出
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/335395.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

JAVA云HIS医院管理系统源码 云HIS系统源码 云HIS的优势 云HIS的发展

JAVA云HIS医院管理系统源码 云HIS系统源码 云HIS的优势 云HIS的发展 HIS系统&#xff0c;即医院信息系统&#xff08;Hospital Information System&#xff09;&#xff0c;在医院的运营和管理中扮演着至关重要的角色。关于HIS系统的溯源&#xff0c;简单从以下几个方面进行讲…

应用上架后的关键!苹果商店(AppStore)运营策略与技巧指南

1、运营期&#xff1a;怎么能活得好&#xff1f; ▍封号和下架问题 14天 在收到苹果封号通知&#xff08;我们将会在14天后封你的账号&#xff09;如果觉得冤枉可以在14天内进行申诉。14天并不是一个严格准确的时间&#xff0c;有可能会在第15天或者在第20天&#xff0c;甚至…

故障诊断 | 基于KAN故障诊断模型

效果一览 文章概述 故障诊断 | 基于 KAN故障诊断模型。KAN是一种全新的神经网络架构&#xff0c;它与传统的MLP架构不同&#xff0c;能够用更少的参数量在Science领域取得惊人的表现&#xff0c;并且具备可解释性&#xff0c;有望成为深度学习模型发展的一个重要方向。运用KAN&…

探索数组处理:奇数的筛选与替换

新书上架~&#x1f447;全国包邮奥~ python实用小工具开发教程http://pythontoolsteach.com/3 欢迎关注我&#x1f446;&#xff0c;收藏下次不迷路┗|&#xff40;O′|┛ 嗷~~ 目录 一、数组中的奇数筛选 二、将奇数替换为负一 总结 一、数组中的奇数筛选 在处理数组数据时…

Redis 中 Set 数据结构详解

用法 Redis 中的 Set 是一个无序&#xff0c;不重复集合&#xff08;里面的元素为字符串&#xff09;&#xff0c;支持常用的集合操作。 常见命令 1. 增 添加一个或多个元素到 set 中 SADD key member [ member ... ] 返回值&#xff1a; 添加成功的元素个数 将一个元素移到…

Plesk面板上网站无法访问如何查看日志

近期我的网站出现无法访问的问题&#xff0c;这边想要查询为什么出现无法访问的原因&#xff0c;但不知道如何在主机上面进行检查&#xff0c;由于我使用的Hostease的Windows虚拟主机产品默认带普通用户权限的Plesk面板&#xff0c;因此联系Hostease的咨询了Hostease技术支持&a…

Gartner发布评估威胁情报计划有效性指南:评估威胁情报有效性的四个步骤

许多组织都在努力实施 TI 并评估其价值。安全和风险管理领导者必须使用优先情报要求来评估其 TI 计划的有效性&#xff0c;并根据其组织战略完善该计划。 主要发现 尽管许多组织已将威胁情报 (TI) 纳入其安全计划&#xff0c;但他们很难评估其性能、成熟度以及在相关产品和服务…

1比1万地形图符号库分享

我们在《1:2.5万、1:5万、1:10万军用地形图图式》一文中&#xff0c;为大家分享过军用地形图式。 还在《超实用三调符号库分享下载》一文中&#xff0c;为大家分享过三调符号库。 现在再为你分享一个&#xff11;比&#xff11;万的地形图符号库&#xff0c;请在文末查看符号…

2023年西安交通大学校赛(E-雪中楼)

E.雪中楼 如果算出按南北的序列&#xff0c;再转成从低到高的编号序列&#xff0c;岂不是太麻烦了&#xff0c;幸好&#xff0c;没有在这方面费长时间&#xff0c;而是意识到&#xff0c;本质就是要从低到高的编号序列&#xff0c;所以我就按样例模拟了一下&#xff0c;当a[i]0…

AI生成四季变化解决方案,四季之美,一图尽揽

随着AI技术已经渗透到我们生活的方方面面&#xff0c;在这个充满变化的时代&#xff0c;美摄科技以其前沿的AI生成技术&#xff0c;为企业带来了全新的视觉体验——AI生成四季变化解决方案。这一方案不仅能够让车辆实拍的照片焕发不同季节的风采&#xff0c;更能在不改变原图构…

中国企业出海,哪些业务需要负载均衡?

国内企业出海的进程正在加速。中国的出海企业剑指跨境电商、社交、游戏、短剧等市场&#xff0c;其中尤其以跨境电商的数据最为突出。据官方数据&#xff0c;2023年我国跨境电商进出口总额达到2.38万亿元&#xff0c;比2016年增长近50倍&#xff0c;占货物贸易总规模的5.7%。 …

一行命令将已克隆的本地Git仓库推送到内网服务器

一、需求背景 我们公司用gitea搭建了一个git服务器&#xff0c;其中支持win7的最高版本是v1.20.6。 我们公司的电脑在任何时候都不能连接外网&#xff0c;但是希望将一些开源的仓库移植到内网的服务器来。一是有相关代码使用的需求&#xff0c;二是可以建设一个内网能够查阅的…

【Java】HOT100+代码随想录:动态规划(下)

目录 三、打家劫舍 LeetCode198&#xff1a;打家劫舍 LeetCode213&#xff1a;打家劫舍ii LeetCode337&#xff1a;打家劫舍iii&#xff08;树形&#xff09; 四、股票问题 时间不多了&#xff0c;其他的先不写了 LeetCode121&#xff1a;买卖股票的最佳时机 五、子序列…

【Python】 如何在Python中表示枚举类型(Enum)

枚举&#xff08;Enum&#xff09;是一种特殊的数据类型&#xff0c;它允许我们为一组固定的常量赋予更易读的名字。在Python中&#xff0c;枚举类型可以通过enum模块来实现&#xff0c;这个模块在Python 3.4及以后的版本中被引入。枚举类型不仅可以使代码更加清晰&#xff0c;…

汇编原理(三)编程

源程序&#xff1a; 汇编指令&#xff1a;有对应的机器码与其对应 伪指令&#xff1a;无对应的机器码&#xff0c;是由编译器来执行的指令&#xff0c;编译器根据伪指令来进行相关的编译工作。 ex1:XXX segment、XXX ends这两个是一对成对使用的伪指令&#xff0c;且必须会被用…

蓝桥杯Web开发【大学组:国赛】2022年真题

1.分一分 如果给你一个数组&#xff0c;你能很快将它分割成指定长度的若干份吗&#xff1f; 1.1 题目问题 请在 js/index.js 文件中补全函数 splitArray 中的代码&#xff0c;最终返回按指定长度分割的数组。 具体要求如下&#xff1a; 将待分割的&#xff08;一维&#x…

香橙派AIpro快速上线——纯小白体验版本!!!

目录 前言 一、快速上线 官网的样例测试 ​编辑解决模型转换问题的步骤 如果系统卡死 二、usb摄像头测试 三、总结 模型转换 小结 前言 香橙派AIproubuntu系统32G sd卡 香橙派AIpro开发板采用昇腾AI技术路线&#xff0c;接口丰富且具有强大的可扩展性&#xff0c;提…

Redis面试题深度解析

1、我看你做的项目中&#xff0c;都用到了redis&#xff0c;你在最近的项目中哪些场景使用了redis呢? 2、缓存穿透 布隆过滤器的误判现象 Redisson和Guava都对布隆过滤器进行了实现 3、缓存击穿 互斥锁&#xff0c;就是一个线程来修改&#xff0c;并占据了锁&#xff0c;另外其…

FreeRTOS【8】二值信号量使用

1.开发背景 FreeRTOS 提供了队列可以在线程间快速交换信息&#xff0c;那么还有没有其他交互渠道&#xff1f;答案是有的&#xff0c;相对于队列传递信息&#xff0c;还有更轻量级的线程唤醒操作&#xff0c;那就是信号量&#xff0c;而二值信号量就是最简单的一种。 二值信号量…

SQL开窗函数

文章目录 概念&#xff1a;语法&#xff1a;常用的窗口函数及示例&#xff1a;求平均值&#xff1a;AVG() &#xff1a;求和&#xff1a;SUM():求排名&#xff1a;移动平均计数COUNT():求最大MXA()/小MIN()值求分区内的最大/最小值求当前行的前/后一个值 概念&#xff1a; 开窗…