这个不知道是我的oled硬件的问题,还是说可以oled设置的问题,请各位大佬能够指正并赐教!
几个星期前看了 奈何col 的用 MINI12864显示熊猫表情包的帖子觉得很cool
https://www.arduino.cn/thread-42174-1-1.html
然后点击链接上某宝的时候发现《Arduino程序设计基础》上面所说u8glib库完全兼容的两块板子都没得卖了,于是自己买了块7针的0.96寸的oled。
本人是计算机学院的大一学生,对于硬件完全一点基础都没有,纯粹是感兴趣。
搜了很多帖子,怀着试探地生怕不兼容的心情用了以下帖子的方法:
https://blog.csdn.net/chenchen2360060/article/details/85220115
我的oled12864显示屏是默认的是四线spi,按照这个帖子接了线,成功地打出了hello world。
于是,乘胜追击,想把熊猫表情的显示做出来,下载了熊猫表情,然后右键编辑把分辨率调成小于oled的分辨率大小,在ADsee官方免费版
打开图片 ->工具 ->修改->更改色深->黑白, 然后另存为将图片改为了黑白的单色图片。(我的oled是单白色显示的)
用奈何col的工具集,位图取模之后编写程序,然后烧录......可怕的事情发生了。
熊猫的图片显示错乱,但是还是有层次感的....为了弄清楚是哪错了,我先从最简单的‘北’字入手。结果又让我大跌眼镜....
这这这....怎么肥事?!
为了继续探究根源,我先去了解了那些取模后的数字到底表示什么,这样子才好确定到底哪出了问题。
https://blog.csdn.net/e_wsq/article/details/70885668
‘北’字是16X16的点阵构成的,而每一行的16个点分成了两个十六进制数代表显示的位置,然后我仔细用 字模提取v2.2 这个软件仔细对比点阵之后发现:每一个十六进制数代表的八个点阵的亮暗在oled上是从右往左显示的! 比如Ox7c, 从左往右是 暗亮亮亮 亮亮暗暗(0111 1100) 但是在屏幕上显示了 暗暗亮亮 亮亮亮暗(从右往左反了)!
研究出规律,我自己用c++写了个程序,把那些数字按规律转换了一下(将每个十六进制数表示的亮暗倒过来),然后再将新的数字复制黏贴到数组上,编写程序后烧录。
[mw_shl_code=arduino,true]#include<U8glib.h>
U8GLIB_SSD1306_128X64 oled(13, 11, 10, 9); //SW SPI Com: SCK(D0) = 13, MOSI(D1) = 11, CS = 10, A0(DC) = 9
//转换后的数字数字
const unsigned char col[] U8G_PROGMEM= {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfb,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfb,0xff,0xdf,0xff,
0xff,0xff,0xff,0xff,0xff,0x7f,0xc0,0xff,0x03,0xfe,0x17,0xe2,0xff,0xff,0xff,0x3f,0x80,0x7f,0x00,0x5c,0xfe,0x5f,0xfc,0xdb,0xff,0x1f,0x00,
0x1f,0x00,0xf0,0xff,0xff,0xef,0x80,0xff,0x0f,0x80,0x0f,0x00,0xf8,0xff,0xff,0x1f,0x00,0xfc,0x0f,0x00,0x1f,0x00,0xf8,0xff,0xff,0x1f,0x00,
0xf8,0x0f,0x00,0x0f,0x00,0xfc,0xff,0xff,0x3f,0x00,0xf8,0x07,0x80,0x0f,0x00,0xfe,0xff,0xff,0xff,0x00,0xf0,0x03,0x80,0x0f,0x80,0xff,0xff,
0xff,0xff,0x00,0xf0,0x07,0x80,0x0f,0x80,0xff,0xff,0xff,0xff,0x01,0xf0,0x03,0xc0,0x0f,0x80,0xff,0xff,0xff,0xff,0x01,0xf0,0x01,0x80,0x0b,
0xc0,0xff,0x0f,0xfc,0xfb,0x03,0xf0,0x01,0x00,0x00,0xe0,0xff,0x01,0xfc,0xc5,0x07,0xf0,0x01,0x00,0x40,0xe0,0xff,0x7f,0x75,0xaa,0x0f,0xf0,
0x00,0x00,0x60,0xf0,0xff,0xff,0x78,0xbe,0x0f,0xf0,0x01,0x00,0xf0,0xf1,0xff,0xbf,0xbb,0xff,0x1f,0xf8,0x01,0x00,0xfc,0xfb,0xff,0x81,0xff,
0xf9,0x1f,0xfc,0x01,0x00,0xfc,0xfb,0xff,0x81,0xff,0xf9,0x1f,0xfc,0x01,0x80,0xff,0xfb,0xff,0xdf,0xff,0xe7,0xdf,0xff,0x01,0x80,0xff,0xfd,
0xff,0xff,0xff,0xf7,0xff,0xff,0x03,0xc0,0xff,0xff,0xff,0xff,0xff,0xf7,0xdf,0xff,0x01,0xc0,0xff,0xfd,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
0xe0,0xff,0xfd,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xf0,0x7f,0xfe,0xff,0xbf,0xff,0xff,
0xbf,0xff,0x01,0xf0,0x7f,0xfe,0xff,0xdf,0xff,0xff,0xff,0xff,0x03,0xe0,0x7f,0xfe,0xff,0xdf,0xeb,0xe9,0xbf,0xff,0x01,0xe0,0x87,0xff,0xff,
0xe3,0x03,0xee,0xbf,0xff,0x03,0x80,0x80,0xff,0xff,0xf7,0x9f,0xff,0x3f,0xfc,0x01,0x00,0x80,0xff,0xff,0xfb,0xff,0xff,0x3f,0xfc,0x07,0x00,
0x80,0xff,0xff,0xff,0xff,0xff,0x7f,0xf8,0x03,0x00,0x80,0xff,0xff,0x5f,0xab,0xfd,0x3f,0xf8,0x07,0x00,0x00,0xfe,0xff,0x5f,0x29,0xf8,0x3f,
0xf0,0x07,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x3f,0xf0,0x07,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x3f,0xe0,0x0f,0x00,0x00,0xfc,0xff,0xff,
0xfd,0xff,0x1f,0xe0,0x1f,0x00,0x00,0xf8,0xff,0xff,0x07,0xfe,0x0f,0x80,0x1f,0x00,0x00,0xf8,0xff,0xff,0x07,0xfe,0x0f,0x80,0x1f,0x00,0x00,
0xe0,0xff,0xff,0x8f,0xff,0x03,0xc0,0x3f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x01,0x80,0x3f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x01,0x80,
0xff,0x01,0x00,0x00,0xfe,0xff,0xff,0x3f,0x00,0x00,0xff,0x01,0x00,0x00,0xf8,0xff,0xff,0x0f,0x00,0x00,0xff,0x03,0x00,0x00,0x00,0xfe,0x6f,
0x00,0x00,0x00,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x3f,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00
};
void setup() {
oled.begin();
}
void loop() {
oled.firstPage();
do{
oled.drawXBMP(0,0,80,60,col);
}while(oled.nextPage());
delay(500);
}[/mw_shl_code]
然后成功了:
但是每次取完模之后还要来一次转换,感觉十分麻烦。
希望各位用过类似的oled的朋友能告诉我是硬件的问题还是设置的问题,小白在此谢过啦。
|