【掌控】mpython-5…用掌控做个性DF徽章
本帖最后由 rzyzzxw 于 2018-10-4 18:04 编辑我把这个帖子当做是一个复习课,
尝试解决大圣老师在上个帖子里提出的问题,
其实到现在,我还在掌控的边缘学习,不过这些代码已经把我搞得头大。
学习过程是艰辛的,不过也有乐趣,当后面回头再看,我陪micro:bit成长,又参与掌控的生态建设,还在论坛上啰嗦了这些也没有多少同事能看到能看懂的文字,也挺有意义。
这次做个DF个性徽章。
http://v.youku.com/v_show/id_XMzg0NjgwODEzNg==.html?spm=a2h3j.8428770.3416059.1
【复习内容】
1、准备图片,处理成64*64
2、用取模软件Img2Lcd工具。
3、保存数据,去头去尾,只要有用的。
4、写入数组
5、后面的程序还用上一个帖子中的改下。
from mpython import *
import framebuf
import time
#图片bitmap数组
bmp = bytearray([\
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X0C,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X1E,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X3F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X3F,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X1E,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X0C,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X0C,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X0C,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X0C,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X0C,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X3F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X7F,0XC0,0X00,0X00,0X00,
0X00,0X00,0X01,0XFF,0XE0,0X00,0X00,0X00,0X03,0X80,0X07,0XFF,0XF8,0X00,0X70,0X00,
0X07,0XC0,0X0F,0XFF,0XFE,0X00,0XF8,0X00,0X07,0XC0,0X3F,0XFF,0XFF,0X00,0XF8,0X00,
0X07,0XE0,0XFF,0XFF,0XFF,0XC1,0XF8,0X00,0X03,0XFB,0XFF,0XFF,0XFF,0XF7,0XF0,0X00,
0X00,0X3F,0XFF,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X0F,0XFF,0XFF,0XFF,0XFC,0X00,0X00,
0X00,0X07,0XFF,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X07,0XFF,0XFF,0XFF,0XFC,0X00,0X00,
0X00,0X07,0XFF,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X07,0XFF,0XFF,0XFF,0XFC,0X00,0X00,
0X00,0X07,0XFF,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X07,0XFF,0XFF,0XFF,0XFC,0X00,0X00,
0X00,0X07,0XFF,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X06,0XFF,0XFF,0XFF,0XDC,0X00,0X00,
0X00,0X07,0XFF,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X07,0X80,0X00,0X00,0X7C,0X00,0X00,
0X00,0X07,0X80,0X00,0X00,0X7C,0X00,0X00,0X00,0X07,0X80,0X00,0X00,0X7C,0X00,0X00,
0X00,0X06,0XE0,0X00,0X01,0XDC,0X00,0X00,0X00,0X06,0X7C,0X00,0X0F,0X9C,0X00,0X00,
0X00,0X07,0XCF,0X80,0X7C,0XFC,0X00,0X00,0X00,0X07,0XF9,0XF3,0XE7,0XFC,0X00,0X00,
0X00,0X07,0XFF,0X3F,0X3F,0XFC,0X00,0X00,0X00,0X07,0XFF,0XE1,0XFF,0XF8,0X00,0X00,
0X00,0X03,0XFF,0XFF,0XFF,0XF0,0X00,0X00,0X00,0X00,0XFF,0XFF,0XFF,0XC0,0X00,0X00,
0X00,0X00,0X3F,0XFF,0XFF,0X80,0X00,0X00,0X00,0X00,0X1F,0XFF,0XFE,0X00,0X00,0X00,
0X00,0X00,0X07,0XFF,0XF8,0X00,0X00,0X00,0X00,0X00,0X01,0XFF,0XF0,0X00,0X00,0X00,
0X00,0X00,0X00,0XFF,0XC0,0X00,0X00,0X00,0X00,0X00,0X00,0X3F,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X0C,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
])
fb1 = framebuf.FrameBuffer(bmp,64,60, framebuf.MONO_HLSB) #创建64x64大小帧缓存区储存图片帧,水平扫描
#display.invert(1) #bit反向
while True:
display.fill(0)
display.show()
time.sleep_ms(1000)
display.blit(fb1,32,0)#将fb1帧缓存送至oled显示,起始位(32,0)
display.show() #刷新显示屏
time.sleep_ms(2000)
display.fill(0)
display.show()
display.rect(0,0,128,64,1) #绘制起始坐标(0, 0),宽128,高64的矩形
display.hline(0,21,128,1)#画水平线,起始点坐标(16,0),线长128
display.hline(0,42,128,1)#画水平线,起始点坐标(32,0),线长128
display.vline(42,0,64,1)#画垂直线,起始点坐标(0,42),线长64
display.DispChar("学校",10,1) #字符显示
display.DispChar("汝州市一中",55,1) #字符显示
display.DispChar("姓名",10,24) #字符显示
display.DispChar("大圣老师",60,24) #字符显示
display.DispChar("部门",10,45) #字符显示
display.DispChar("创客空间",60,45) #字符显示
display.show()
time.sleep_ms(2000)
6、刷入掌控,运行
完成复习任务。
哈哈,这个帖子有点凑数的感觉。
欢迎拍砖。{:5_140:}
漂亮 求显示效果图呢。。。 R2D2 发表于 2018-10-4 17:30
求显示效果图呢。。。
视频一点,立马就现。{:5_132:} 666{:5_142:} 安卓机器人 发表于 2018-10-16 11:27
666
感谢{:5_156:} 学习一下,也做个试试 蓝色小星星 发表于 2018-11-5 12:10
学习一下,也做个试试
用mind+做,分分钟完成。{:5_132:}
页:
[1]