From 7c8d81a20df0b44ae6bc26f9d0ae665dc9138909 Mon Sep 17 00:00:00 2001 From: Anaconda-cjp <836684877@qq.com> Date: Wed, 21 Jul 2021 05:36:17 +0000 Subject: [PATCH 1/3] =?UTF-8?q?update=20TOF10120/code/main.py.=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=A4=9A=E4=BD=99=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TOF10120/code/main.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/TOF10120/code/main.py b/TOF10120/code/main.py index dc722ee..1a99143 100644 --- a/TOF10120/code/main.py +++ b/TOF10120/code/main.py @@ -18,27 +18,12 @@ while True: x2 = int(x1) x1 = x1 + 'mm'# 给字符串加上单位 display.fill(st7789.color565(255, 192, 203)) - display.fill_rect(0, 0, 240, 120, st7789.color565(0, 255, 255))# 画实心矩形 - display.fill_circle(120, 180, 60, st7789.color565(189, 252, 201))# 画实心圆 + display.draw_string(80, 160, x1, size=3, color=st7789.color565(0, 0, 0)) - if x2 > 800:# 判断距离是否合适并给予提示 - display.draw_string(30, 60, 'too far', size=3, color=st7789.color565(0, 0, 0)) - elif x2 < 500: - display.draw_string(30, 60, 'too close!', size=3, color=st7789.color565(255, 0, 0)) - else: - display.draw_string(30, 60, 'perfect!', size=4, color=st7789.color565(0, 255, 0)) + utime.sleep(1) - sum = utime.ticks_diff(utime.ticks_us(), start) # 测量开始时间到新的微秒的递增计数器开始时的差值。 - sum /= 1000000 - if sum > 10: # 半小时使用时间后提示 - display.fill(st7789.color565(0, 200, 0)) # 填充绿色进入休息时间 - display.draw_string(60, 60, 'Please', size=4, color=st7789.color565(255, 255, 255)) - display.draw_string(0, 150, 'take a break', size=4, color=st7789.color565(255, 255, 255)) - utime.sleep(10) # 休息三分钟 - start = utime.ticks_us() # 重置计时器 - continue - + -- Gitee From ca6194fa7fa2b68e2ff856c07be020808f9ef43e Mon Sep 17 00:00:00 2001 From: Anaconda-cjp <836684877@qq.com> Date: Wed, 21 Jul 2021 05:37:04 +0000 Subject: [PATCH 2/3] =?UTF-8?q?update=20TOF10120/code/tof10120.py.=20?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TOF10120/code/tof10120.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/TOF10120/code/tof10120.py b/TOF10120/code/tof10120.py index 65edc55..4ed5e8b 100644 --- a/TOF10120/code/tof10120.py +++ b/TOF10120/code/tof10120.py @@ -25,22 +25,7 @@ def screen_init(): dc=Pin(7, func=Pin.GPIO, dir=Pin.OUT)) display.init() display.fill(st7789.color565(124, 205, 124)) - for i in range(1, 10): - display.draw_string(20, 200 - i * 20, 'Welcome to', size=4, color=st7789.color565(0, 0, 0)) - display.fill_rect(20, 230 - i * 20, 220, 30, st7789.color565(124, 205, 124)) - utime.sleep_us(3200) - for i in range(1, 10): - display.draw_string(20, 200 - i * 17, 'Eye protection', size=3, color=st7789.color565(0, 255, 0)) - display.fill_rect(20, 230 - i * 17, 220, 60, st7789.color565(124, 205, 124)) - utime.sleep_us(1600) - for i in range(1, 10): - display.draw_string(20, 200 - i * 14 - 3, 'assistant!', size=4, color=st7789.color565(200, 0, 0)) - display.fill_rect(20, 230 - i * 14 - 3, 220, 30, st7789.color565(124, 205, 124)) - utime.sleep_us(800) - for i in range(3): - display.fill_circle(120, 180, 60, st7789.color565(250, 252, 0)) - display.draw_string(100, 160, str(3 - i), size=7, color=st7789.color565(255, 255, 255)) - utime.sleep(0.95) + return display -- Gitee From e831f6c476d02d66e6d69aa41405f98f9c930eea Mon Sep 17 00:00:00 2001 From: Anaconda-cjp <836684877@qq.com> Date: Wed, 21 Jul 2021 05:38:46 +0000 Subject: [PATCH 3/3] =?UTF-8?q?update=20TOF10120/readme.md.=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=A4=9A=E4=BD=99=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TOF10120/readme.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/TOF10120/readme.md b/TOF10120/readme.md index 7906ff3..b198fd4 100644 --- a/TOF10120/readme.md +++ b/TOF10120/readme.md @@ -2,13 +2,11 @@ ## 案例展示 -  通过传感器测定屏幕和人脸的距离,如果距离大于50cm,则显示'too far',如果距离小于30cm,显示'too close!',如果距离在两者之间,显示'perfect!' +  通过传感器测定屏幕和人脸的距离,并显示。 + -![输入图片说明](https://images.gitee.com/uploads/images/2021/0716/201859_ba917165_9429392.jpeg "使用界面.jpg") -  后续将改进字体清晰度。此外,使用该工具超过半小时(默认你使用手机与该工具几乎同时开始),将会提醒你休息3分钟,保护视力。 -![输入图片说明](https://images.gitee.com/uploads/images/2021/0716/202049_f42dc2f9_9429392.jpeg "休息界面.jpg") ## 物理连接(如下图) @@ -31,7 +29,7 @@ ## 传感器库使用 -  可以获取TOF10120/code/main.py里的tof10120.py,将此库通过[Waffle Maker](https://wafflenano.blackwalnut.tech/ide/index.html#/editor) 的文件上传功能将此库上传到`Waffle Nano`上。 +  可以获取[tof10120.py](https://gitee.com/Anaconda-cjp/waffle-nano-v1-sensor-lib/blob/master/TOF10120/code/main.py),将此库通过[Waffle Maker](https://wafflenano.blackwalnut.tech/ide/index.html#/editor) 的文件上传功能将此库上传到`Waffle Nano`上。   我们在可以在主函数中使用以下代码导入此库。 @@ -52,6 +50,6 @@ x = uart.read()# 读取数据从激光传感器中获取数据 ## 案例代码复现 -  可以获取TOF10120/code/main.py函数,将其内容复制到[Waffle Maker](https://wafflenano.blackwalnut.tech/ide/index.html#/editor) 编辑器上传输给`Waffle Nano`,以复现此案例。 +  可以获取[main.py](https://gitee.com/Anaconda-cjp/waffle-nano-v1-sensor-lib/blob/master/TOF10120/code/main.py)函数,将其内容复制到[Waffle Maker](https://wafflenano.blackwalnut.tech/ide/index.html#/editor) 编辑器上传输给`Waffle Nano`,以复现此案例。 -  案例相关细节说明详见代码注释[输入链接说明](http://) \ No newline at end of file +  案例相关细节说明详见代码注释 \ No newline at end of file -- Gitee