Micropython学习交流群 学习QQ群:786510434 提供多种固件下载和学习交流。

Micropython-扇贝物联 QQ群:31324057 扇贝物联是一个让你与智能设备沟通更方便的物联网云平台

Micropython学习交流群 学习QQ群:468985481 学习交流ESP8266、ESP32、ESP8285、wifi模块开发交流、物联网。

Micropython老哥俩的IT农场分享QQ群:929132891 为喜欢科创制作的小白们分享一些自制的计算机软硬件免费公益课程,由两位多年从事IT研发的中年大叔发起。

Micropython ESP频道

ESP32(MicroPython)ssd1306 几个动画


ESP32(MicroPython) 几个动画

本次发布的动画程序如下


矩形缩放


'''

接线:OLED(IIC)

       SCL-->(18)

       SDA-->(23)         

'''

 

#导入Pin模块

from machine import Pin

import time

from machine import SoftI2C

from ssd1306 import SSD1306_I2C  #I2C的oled选该方法

import random

 

#创建硬件I2C对象

#i2c=I2C(0,sda=Pin(19), scl=Pin(18), freq=400000)

 

#创建软件I2C对象

i2c = SoftI2C(sda=Pin(23), scl=Pin(18))

#创建OLED对象,OLED分辨率、I2C接口

oled = SSD1306_I2C(128, 64, i2c)

 

#程序入口

if __name__=="__main__":

 while True:

    a=60

    b=30

    c=8

    d=4 

    oled.rect(a,b,c,d,1)  #画矩形

    oled.show()  #执行显示

    while a>2 :

        oled.fill(0)  #清空屏幕

        a-=2

        b-=1

        c+=4

        d+=2

        oled.rect(a,b,c,d,1)  #画矩形

        oled.show()  #执行显示

    while a<60 :

        oled.fill(1)  #清空屏幕

        a+=2

        b+=1

        c-=4

        d-=2

        oled.fill_rect(a,b,c,d,0)  #画矩形

        oled.show()  #执行显示

矩形下落(改版)


'''

接线:OLED(IIC)

       SCL-->(18)

       SDA-->(23)         

'''

 

#导入Pin模块

from machine import Pin

import time

from machine import SoftI2C

from ssd1306 import SSD1306_I2C  #I2C的oled选该方法

import random

 

#创建硬件I2C对象

#i2c=I2C(0,sda=Pin(19), scl=Pin(18), freq=400000)

 

#创建软件I2C对象

i2c = SoftI2C(sda=Pin(23), scl=Pin(18))

#创建OLED对象,OLED分辨率、I2C接口

oled = SSD1306_I2C(128, 64, i2c)

 

#程序入口

if __name__=="__main__":

   while True:

            a=random.randint(2,110)

            b=random.randint(5,25)

            c=random.randint(5,20)

            d=random.randint(2,10)

            oled.rect(a,1,b,c,1)  #画矩形

            oled.show()  #执行显示

            oled.hline(0,0,128,0)  #清除移动前显示区

            oled.scroll(0,1)  #指定像素X轴移动

            time.sleep_ms(2)

矩形移动


'''

接线:OLED(IIC)

       SCL-->(18)

       SDA-->(23)         

'''

 

#导入Pin模块

from machine import Pin

import time

from machine import SoftI2C

from ssd1306 import SSD1306_I2C  #I2C的oled选该方法

import random

 

#创建硬件I2C对象

#i2c=I2C(0,sda=Pin(19), scl=Pin(18), freq=400000)

 

#创建软件I2C对象

i2c = SoftI2C(sda=Pin(23), scl=Pin(18))

#创建OLED对象,OLED分辨率、I2C接口

oled = SSD1306_I2C(128, 64, i2c)

 

#程序入口

if __name__=="__main__":

 while True:

    a=random.randint(5,15)

    b=random.randint(5,15)

    c=random.randint(8,23)

    d=random.randint(8,23) 

    oled.rect(a,b,c,d,1)  #画矩形

    oled.show()  #执行显示

    while a<100 :

        oled.fill(0)  #清空屏幕

        a+=3

        oled.rect(a,b,c,d,1)  #画矩形

        oled.show()  #执行显示

    while b<40 :

        oled.fill(1)  #清空屏幕

        b+=2

        oled.fill_rect(a,b,c,d,0)  #画矩形

        oled.show()  #执行显示

    while a>5 :

        oled.fill(0)  #清空屏幕

        a-=3

        oled.rect(a,b,c,d,1)  #画矩形

        oled.show()  #执行显示

    while b>5 :

        oled.fill(1)  #清空屏幕

        b-=2

        oled.fill_rect(a,b,c,d,0)  #画矩形

        oled.show()  #执行显示   

同心矩形放大


'''

接线:OLED(IIC)

       SCL-->(18)

       SDA-->(23)         

'''

 

#导入Pin模块

from machine import Pin

import time

from machine import SoftI2C

from ssd1306 import SSD1306_I2C  #I2C的oled选该方法

import random

 

#创建硬件I2C对象

#i2c=I2C(0,sda=Pin(19), scl=Pin(18), freq=400000)

 

#创建软件I2C对象

i2c = SoftI2C(sda=Pin(23), scl=Pin(18))

#创建OLED对象,OLED分辨率、I2C接口

oled = SSD1306_I2C(128, 64, i2c)

 

#程序入口

if __name__=="__main__":

 while True:

    a=60

    b=30

    c=8

    d=4

    e=60

    f=30

    g=8

    h=4

    oled.rect(a,b,c,d,1)  #画矩形

    oled.show()  #执行显示

    while a>50 :

        e-=2

        f-1

        g+=4

        h+=2

        oled.fill(0)  #清空屏幕

        while a>2 :    

            a-=8

            b-=4

            c+=16

            d+=8

            oled.rect(a,b,c,d,1)  #画矩形

            oled.show()  #执行显示

        a=e

        b=f

        c=g

        d=h


————————————————

版权声明:本文为CSDN博主「路易斯720」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/weixin_74155302/article/details/131116741



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 ESP56.com All Rights Reserved

执行时间: 0.009099006652832 seconds