划句顾 发表于 2021-10-6 22:06:59

ESP8266:OLED_显示图片

本帖最后由 划句顾 于 2022-5-2 17:23 编辑

嘿嘿,明天要去学校了,最后滴放纵{:5_109:}

图片取模工具

话不多说,贴出照片:


static/image/hrline/5.gif



/*
* author:LaoGu
* time:2021/10/6
* purpose:让OLED 屏幕显示个图片
*/
#include<Arduino.h>
#include<U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include<SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include<Wire.h>
#endif

U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,SCL,SDA,U8X8_PIN_NONE);//对应 OLED 的驱动协议、像素大小以及接线方式

//图片取模
// width: 66, height: 55
const unsigned char col[]U8X8_PROGMEM = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xff,0xff,
0xff,0xff,0xff,0xff,0xef,0xff,0x03,0xff,0xff,0xff,0x8f,0xff,0xff,0x03,0xff,0x03,0xff,0xff,0x3f,0x00,
0x80,0xff,0x00,0xfe,0x03,0xff,0xff,0x03,0x00,0x00,0x7c,0x78,0xfc,0x03,0xff,0xff,0xc0,0xff,0x1f,0x38,
0x7e,0xfc,0x03,0xff,0x3f,0xf8,0xff,0xff,0x01,0xff,0xf8,0x03,0xff,0x1f,0xff,0xff,0xff,0x07,0xff,0xfc,
0x03,0xff,0x87,0xff,0xff,0xff,0x0f,0xff,0xf8,0x03,0xff,0x03,0xfe,0xff,0xff,0x3f,0xfe,0xf8,0x03,0xff,
0xc1,0xfc,0xff,0xff,0x7f,0xf8,0xfc,0x03,0xff,0xc0,0xfd,0xff,0xff,0xff,0x70,0xf8,0x03,0xff,0x80,0xfd,
0xff,0xff,0xff,0x71,0xf0,0x03,0x7f,0x80,0xfd,0x7f,0xe0,0xff,0xe3,0xe0,0x03,0x7f,0x80,0xfd,0x3f,0xe4,
0xff,0xc7,0xe3,0x03,0x3f,0xc0,0xfd,0x1f,0xc8,0xff,0x8f,0xc7,0x03,0x3f,0xc0,0xfd,0x0f,0xd8,0xff,0x0f,
0xcf,0x03,0x1f,0xc0,0xfc,0x07,0x98,0xff,0x1f,0x8f,0x03,0x1f,0xe0,0xfc,0x03,0x98,0xff,0x3f,0xce,0x03,
0x0f,0xe0,0xfe,0x03,0x98,0xff,0x7f,0xc0,0x03,0x8d,0x01,0xfe,0x01,0x98,0xff,0x7f,0xe0,0x03,0xce,0x1f,
0xff,0x01,0x9c,0xff,0xff,0xf8,0x03,0xc6,0xff,0xff,0x01,0xdc,0xff,0xff,0xf8,0x03,0xc7,0xff,0xff,0x01,
0xde,0xff,0xff,0xf1,0x03,0xe7,0xff,0xff,0x1f,0xcc,0xff,0xff,0xe3,0x03,0xe7,0xff,0xff,0xff,0xe1,0xff,
0xff,0xe3,0x03,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xc7,0x03,0xe7,0xff,0xff,0xff,0xee,0xff,0xff,0xcf,
0x02,0xe7,0xff,0xff,0x7f,0x77,0xff,0xff,0x8f,0x02,0xe7,0x07,0xff,0xff,0xbf,0xfb,0xff,0x1f,0x02,0x07,
0x20,0xfe,0xff,0xff,0xfb,0xff,0x1f,0x02,0x87,0x79,0xfe,0xff,0xcf,0xff,0xff,0x3f,0x02,0x87,0x79,0xfc,
0xff,0xcf,0xff,0xff,0x3f,0x02,0x07,0xf9,0xe0,0xff,0x9f,0xff,0xff,0x3f,0x02,0x3f,0xf8,0x01,0xff,0xcf,
0xff,0xff,0x7f,0x02,0xff,0xf0,0x39,0xe0,0xe0,0xff,0xff,0x7f,0x02,0xff,0xf1,0xfb,0x03,0xf8,0xff,0xff,
0xff,0x02,0xff,0xfb,0xf3,0xff,0xff,0xff,0xff,0xff,0x02,0xff,0xf3,0xc7,0xff,0xff,0xff,0xff,0xff,0x02,
0xff,0xf7,0x1f,0xfe,0xff,0xff,0xff,0xff,0x03,0xff,0xe7,0x7f,0xc0,0xff,0xff,0xff,0xff,0x03,0xff,0xef,
0xff,0x07,0xff,0xff,0x7f,0xf8,0x03,0xff,0xcf,0xff,0x0f,0xff,0xff,0x1f,0xe0,0x03,0xff,0x9f,0xff,0xcf,
0xff,0xff,0xff,0xc7,0x03,0xff,0x1f,0xff,0xcf,0xff,0xff,0xff,0x8f,0x03,0xff,0x3f,0xff,0xcf,0xff,0xff,
0xff,0x9f,0x03,0xff,0x7f,0xfe,0xcf,0xff,0xff,0xff,0x3f,0x03,0xff,0xff,0xf8,0xcf,0xff,0xff,0xff,0x3f,
0x03,0xff,0xff,0xf1,0xe7,0xff,0xff,0xff,0x7f,0x03,0xff,0xff,0x87,0xe7,0xff,0xff,0x3f,0x7f,0x02,0xff,
0xff,0x1f,0xe4,0xff,0xff,0x7f,0x7f,0x02,0xff,0xff,0xff,0xe0,0xff,0xff,0x7f,0xfe,0x02,0xff,0xff,0xff,
0xe7,0xff,0xff,0x7f,0xfe,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x00 };

void setup(){
u8g2.begin();
}

void loop(){
   u8g2.firstPage();
   do{
   u8g2.clearBuffer();
   u8g2.drawXBMP(0,0,66,55,col);//col就是bitmap
   u8g2.sendBuffer();
   }while(u8g2.nextPage());
    delay(2500);
}


static/image/hrline/5.gif
知识点:
u8g2.drawXBM()/drawXBMP() —— 绘制图像
* 绘制图像
* @param x 左上角坐标x
* @param y 左上角坐标y
* @param w 图形宽度
* @param h 图形高度
* @param bitmap 图形内容
举个栗子:
       u8g2.drawXBM(x ,y,w , h , bitmap)
   或者u8g2.drawXBMP(x ,y,w , h , bitmap)


static/image/hrline/5.gif
再在oled里面加个进度条


图片如下:


代码:
/*
* author:LaoGu
* time:2021/10/6
* purpose:让OLED 屏幕加载个图片和进度条
*/
#include<Arduino.h>
#include<U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include<SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include<Wire.h>
#endif

U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,SCL,SDA,U8X8_PIN_NONE);//对应 OLED 的驱动协议、像素大小以及接线方式

int H =72;

//图片取模
// width: 66, height: 55
const unsigned char col[] U8X8_PROGMEM = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xff,0xff,
0xff,0xff,0xff,0xff,0xef,0xff,0x03,0xff,0xff,0xff,0x8f,0xff,0xff,0x03,0xff,0x03,0xff,0xff,0x3f,0x00,
0x80,0xff,0x00,0xfe,0x03,0xff,0xff,0x03,0x00,0x00,0x7c,0x78,0xfc,0x03,0xff,0xff,0xc0,0xff,0x1f,0x38,
0x7e,0xfc,0x03,0xff,0x3f,0xf8,0xff,0xff,0x01,0xff,0xf8,0x03,0xff,0x1f,0xff,0xff,0xff,0x07,0xff,0xfc,
0x03,0xff,0x87,0xff,0xff,0xff,0x0f,0xff,0xf8,0x03,0xff,0x03,0xfe,0xff,0xff,0x3f,0xfe,0xf8,0x03,0xff,
0xc1,0xfc,0xff,0xff,0x7f,0xf8,0xfc,0x03,0xff,0xc0,0xfd,0xff,0xff,0xff,0x70,0xf8,0x03,0xff,0x80,0xfd,
0xff,0xff,0xff,0x71,0xf0,0x03,0x7f,0x80,0xfd,0x7f,0xe0,0xff,0xe3,0xe0,0x03,0x7f,0x80,0xfd,0x3f,0xe4,
0xff,0xc7,0xe3,0x03,0x3f,0xc0,0xfd,0x1f,0xc8,0xff,0x8f,0xc7,0x03,0x3f,0xc0,0xfd,0x0f,0xd8,0xff,0x0f,
0xcf,0x03,0x1f,0xc0,0xfc,0x07,0x98,0xff,0x1f,0x8f,0x03,0x1f,0xe0,0xfc,0x03,0x98,0xff,0x3f,0xce,0x03,
0x0f,0xe0,0xfe,0x03,0x98,0xff,0x7f,0xc0,0x03,0x8d,0x01,0xfe,0x01,0x98,0xff,0x7f,0xe0,0x03,0xce,0x1f,
0xff,0x01,0x9c,0xff,0xff,0xf8,0x03,0xc6,0xff,0xff,0x01,0xdc,0xff,0xff,0xf8,0x03,0xc7,0xff,0xff,0x01,
0xde,0xff,0xff,0xf1,0x03,0xe7,0xff,0xff,0x1f,0xcc,0xff,0xff,0xe3,0x03,0xe7,0xff,0xff,0xff,0xe1,0xff,
0xff,0xe3,0x03,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xc7,0x03,0xe7,0xff,0xff,0xff,0xee,0xff,0xff,0xcf,
0x02,0xe7,0xff,0xff,0x7f,0x77,0xff,0xff,0x8f,0x02,0xe7,0x07,0xff,0xff,0xbf,0xfb,0xff,0x1f,0x02,0x07,
0x20,0xfe,0xff,0xff,0xfb,0xff,0x1f,0x02,0x87,0x79,0xfe,0xff,0xcf,0xff,0xff,0x3f,0x02,0x87,0x79,0xfc,
0xff,0xcf,0xff,0xff,0x3f,0x02,0x07,0xf9,0xe0,0xff,0x9f,0xff,0xff,0x3f,0x02,0x3f,0xf8,0x01,0xff,0xcf,
0xff,0xff,0x7f,0x02,0xff,0xf0,0x39,0xe0,0xe0,0xff,0xff,0x7f,0x02,0xff,0xf1,0xfb,0x03,0xf8,0xff,0xff,
0xff,0x02,0xff,0xfb,0xf3,0xff,0xff,0xff,0xff,0xff,0x02,0xff,0xf3,0xc7,0xff,0xff,0xff,0xff,0xff,0x02,
0xff,0xf7,0x1f,0xfe,0xff,0xff,0xff,0xff,0x03,0xff,0xe7,0x7f,0xc0,0xff,0xff,0xff,0xff,0x03,0xff,0xef,
0xff,0x07,0xff,0xff,0x7f,0xf8,0x03,0xff,0xcf,0xff,0x0f,0xff,0xff,0x1f,0xe0,0x03,0xff,0x9f,0xff,0xcf,
0xff,0xff,0xff,0xc7,0x03,0xff,0x1f,0xff,0xcf,0xff,0xff,0xff,0x8f,0x03,0xff,0x3f,0xff,0xcf,0xff,0xff,
0xff,0x9f,0x03,0xff,0x7f,0xfe,0xcf,0xff,0xff,0xff,0x3f,0x03,0xff,0xff,0xf8,0xcf,0xff,0xff,0xff,0x3f,
0x03,0xff,0xff,0xf1,0xe7,0xff,0xff,0xff,0x7f,0x03,0xff,0xff,0x87,0xe7,0xff,0xff,0x3f,0x7f,0x02,0xff,
0xff,0x1f,0xe4,0xff,0xff,0x7f,0x7f,0x02,0xff,0xff,0xff,0xe0,0xff,0xff,0x7f,0xfe,0x02,0xff,0xff,0xff,
0xe7,0xff,0xff,0x7f,0xfe,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x00 };

void setup(){
u8g2.begin();
}

void loop(){
   u8g2.setFont(u8g2_font_unifont_t_chinese2); //设置字体
   
   u8g2.firstPage();
   do{
   u8g2.clearBuffer();
   u8g2.drawStr(70,20,"Loading");
   u8g2.drawXBMP(0,0,66,55,col);
   u8g2.sendBuffer();
   //画一个空心方形
       u8g2.drawFrame(70,30,41,6);
      
      //下面两条line组成进度条
       u8g2.drawLine(72,32,H,32);   //进度条1
       u8g2.drawLine(72,33,H,33);   //进度条2
   
   //这个让进度条动起来
       if(H<105)
          H += 5;
       else
          H = 72;
   }while(u8g2.nextPage());
    delay(2500);
}


static/image/hrline/5.gif
{:10_254:} {:10_254:} {:10_254:} 点赞球球了


演示视频在这里

划句顾 发表于 2021-10-7 21:48:42

本帖最后由 划句顾 于 2021-10-7 22:06 编辑

回复可以百分百拿到币{:10_256:}

可不可以顺便去B站帮我的视频点赞呐{:10_254:}{:10_254:}{:10_254:}

https://www.bilibili.com/video/BV1LT4y1f79C?spm_id_from=333.999.0.0

嘉岳呀 发表于 2021-10-8 20:05:04

{:10_275:}

hornwong 发表于 2021-10-9 10:56:14

感谢分享!

sunyt 发表于 2021-10-9 11:11:14

厉害

1molHF 发表于 2021-10-9 11:12:08

村里小黑 发表于 2021-10-9 11:20:07

{:10_295:}

三刀流.索隆 发表于 2021-10-9 15:37:14

番杰 发表于 2021-10-9 16:35:41

水鱼币

myqf123 发表于 2021-10-9 21:05:40

牛掰

hornwong 发表于 2021-10-10 11:12:51

{:5_95:}

noah-py 发表于 2021-10-10 12:54:37

{:10_275:}

tianlai7266 发表于 2021-10-10 13:20:21

三连了

python0729 发表于 2021-10-10 20:58:25

厉害

AdiosSpike 发表于 2021-10-10 21:05:51

谢谢你的鱼币

python0729 发表于 2021-10-10 21:16:24

玩具鱼 发表于 2021-10-11 08:55:19

{:10_275:}

帅昊昊昊 发表于 2021-10-11 11:10:41

鸬鹚鸟 发表于 2021-10-12 21:31:36

666

喵喵不咪 发表于 2021-10-13 11:54:29

cy
页: [1] 2 3 4 5 6
查看完整版本: ESP8266:OLED_显示图片