├── 01.先唠叨两句(好像不止两句) ├── .ipynb_checkpoints │ ├── 1.嵌入式系统的未来-checkpoint.ipynb │ ├── 2.成为时代的弄潮儿,不做局外人-checkpoint.ipynb │ └── 3.本课程面向的群体和参考资料-checkpoint.ipynb ├── 1.嵌入式系统的未来.ipynb ├── 2.成为时代的弄潮儿,不做局外人.ipynb └── 3.本课程面向的群体和参考资料.ipynb ├── 02.近距离看看计算机硬件体系结构 ├── .ipynb_checkpoints │ ├── 1.处理器的分类-checkpoint.ipynb │ ├── 2.观摩下芯片里面的部分-checkpoint.ipynb │ └── 3.先看看我一直赞不绝口的zynq系列内部吧-checkpoint.ipynb ├── 1.处理器的分类.ipynb ├── 2.观摩下芯片里面的部分.ipynb ├── 3.先看看我一直赞不绝口的zynq系列内部吧.ipynb └── picture │ ├── imx6q_soc.png │ ├── pc_board.jpg │ ├── raspi_3b_board.jpg │ ├── zynq7000_soc.png │ ├── zynq_1.jpg │ └── zynq_2.jpg ├── 03.操作系统为何物?为什么要花这么大精力来使用他? ├── .ipynb_checkpoints │ ├── 1.操作系统为何物?-checkpoint.ipynb │ ├── 2.初探我们要使用的Linux内核-checkpoint.ipynb │ └── 3.何为Linux发行版-checkpoint.ipynb ├── 1.操作系统为何物?.ipynb ├── 2.初探我们要使用的Linux内核.ipynb ├── 3.何为Linux发行版.ipynb ├── __pycache__ │ ├── sakshat.cpython-37.pyc │ └── sakspins.cpython-37.pyc └── picture │ ├── linux_kernel_1.jpeg │ └── linux_kernel_2.jpeg ├── 04.多任务,原来如此简单 ├── .ipynb_checkpoints │ ├── 1.前后台设计模式的不利之处-checkpoint.ipynb │ ├── 2.让多任务走起-checkpoint.ipynb │ ├── 3.近距离的看看多任务的工具-进程-checkpoint.ipynb │ └── 4.置身事外看编程语言-checkpoint.ipynb ├── 1.前后台设计模式的不利之处.ipynb ├── 2.让多任务走起.ipynb ├── 3.近距离的看看多任务的工具-进程.ipynb ├── 4.置身事外看编程语言.ipynb ├── __pycache__ │ ├── sakshat.cpython-37.pyc │ └── sakspins.cpython-37.pyc ├── entities │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── buzzer.cpython-37.pyc │ │ ├── digital_display.cpython-37.pyc │ │ ├── digital_display_tm1637.cpython-37.pyc │ │ ├── dip_switch_2bit.cpython-37.pyc │ │ ├── ds18b20.cpython-37.pyc │ │ ├── ic_74hc595.cpython-37.pyc │ │ ├── ic_tm1637.cpython-37.pyc │ │ ├── led.cpython-37.pyc │ │ ├── led_74hc595.cpython-37.pyc │ │ └── tact.cpython-37.pyc │ ├── buzzer.py │ ├── digital_display.py │ ├── digital_display_tm1637.py │ ├── dip_switch_2bit.py │ ├── ds18b20.py │ ├── ic_74hc595.py │ ├── ic_tm1637.py │ ├── led.py │ ├── led_74hc595.py │ └── tact.py ├── picture │ ├── nxez_raspi_setup.jpg │ └── processing_status.png ├── sakshat.py └── sakspins.py ├── 05.不能再两耳不闻窗外事了!你们需要交流 ├── .ipynb_checkpoints │ ├── 1.用什么交流呢_-checkpoint.ipynb │ └── 2.我是最好的消息快递员——队列-checkpoint.ipynb ├── 1.用什么交流呢_.ipynb ├── 2.我是最好的消息快递员——队列.ipynb ├── __pycache__ │ ├── sakshat.cpython-37.pyc │ └── sakspins.cpython-37.pyc ├── entities │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── buzzer.cpython-37.pyc │ │ ├── digital_display.cpython-37.pyc │ │ ├── digital_display_tm1637.cpython-37.pyc │ │ ├── dip_switch_2bit.cpython-37.pyc │ │ ├── ds18b20.cpython-37.pyc │ │ ├── ic_74hc595.cpython-37.pyc │ │ ├── ic_tm1637.cpython-37.pyc │ │ ├── led.cpython-37.pyc │ │ ├── led_74hc595.cpython-37.pyc │ │ └── tact.cpython-37.pyc │ ├── buzzer.py │ ├── digital_display.py │ ├── digital_display_tm1637.py │ ├── dip_switch_2bit.py │ ├── ds18b20.py │ ├── ic_74hc595.py │ ├── ic_tm1637.py │ ├── led.py │ ├── led_74hc595.py │ └── tact.py ├── sakshat.py └── sakspins.py ├── 06.停下来,别争了,咱们定个规矩 ├── .ipynb_checkpoints │ ├── 1.临界资源为何物。锁_你说的是大门锁吗_-checkpoint.ipynb │ └── 2.别争了,我来定个规矩-checkpoint.ipynb ├── 1.临界资源为何物。锁_你说的是大门锁吗_.ipynb ├── 2.别争了,我来定个规矩.ipynb ├── __pycache__ │ ├── sakshat.cpython-37.pyc │ └── sakspins.cpython-37.pyc ├── entities │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── buzzer.cpython-37.pyc │ │ ├── digital_display.cpython-37.pyc │ │ ├── digital_display_tm1637.cpython-37.pyc │ │ ├── dip_switch_2bit.cpython-37.pyc │ │ ├── ds18b20.cpython-37.pyc │ │ ├── ic_74hc595.cpython-37.pyc │ │ ├── ic_tm1637.cpython-37.pyc │ │ ├── led.cpython-37.pyc │ │ ├── led_74hc595.cpython-37.pyc │ │ └── tact.cpython-37.pyc │ ├── buzzer.py │ ├── digital_display.py │ ├── digital_display_tm1637.py │ ├── dip_switch_2bit.py │ ├── ds18b20.py │ ├── ic_74hc595.py │ ├── ic_tm1637.py │ ├── led.py │ ├── led_74hc595.py │ └── tact.py ├── sakshat.py └── sakspins.py ├── 07.LED灯原来是这样点亮的 ├── .ipynb_checkpoints │ └── 1.LED灯的方法真多,我让谁亮,谁就亮-checkpoint.ipynb ├── 1.LED灯的方法真多,我让谁亮,谁就亮.ipynb ├── __pycache__ │ ├── sakshat.cpython-35.pyc │ ├── sakshat.cpython-37.pyc │ └── sakspins.cpython-37.pyc ├── entities │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── buzzer.cpython-37.pyc │ │ ├── digital_display.cpython-37.pyc │ │ ├── digital_display_tm1637.cpython-37.pyc │ │ ├── dip_switch_2bit.cpython-37.pyc │ │ ├── ds18b20.cpython-37.pyc │ │ ├── ic_74hc595.cpython-37.pyc │ │ ├── ic_tm1637.cpython-37.pyc │ │ ├── led.cpython-37.pyc │ │ ├── led_74hc595.cpython-37.pyc │ │ └── tact.cpython-37.pyc │ ├── buzzer.py │ ├── digital_display.py │ ├── digital_display_tm1637.py │ ├── dip_switch_2bit.py │ ├── ds18b20.py │ ├── ic_74hc595.py │ ├── ic_tm1637.py │ ├── led.py │ ├── led_74hc595.py │ └── tact.py ├── sakshat.py └── sakspins.py ├── 08.你牙牙学语的声音真好听 ├── .ipynb_checkpoints │ └── 1.我听到了,马上过去-checkpoint.ipynb ├── 1.我听到了,马上过去.ipynb ├── __pycache__ │ ├── sakshat.cpython-37.pyc │ └── sakspins.cpython-37.pyc ├── entities │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── buzzer.cpython-37.pyc │ │ ├── digital_display.cpython-37.pyc │ │ ├── digital_display_tm1637.cpython-37.pyc │ │ ├── dip_switch_2bit.cpython-37.pyc │ │ ├── ds18b20.cpython-37.pyc │ │ ├── ic_74hc595.cpython-37.pyc │ │ ├── ic_tm1637.cpython-37.pyc │ │ ├── led.cpython-37.pyc │ │ ├── led_74hc595.cpython-37.pyc │ │ └── tact.cpython-37.pyc │ ├── buzzer.py │ ├── digital_display.py │ ├── digital_display_tm1637.py │ ├── dip_switch_2bit.py │ ├── ds18b20.py │ ├── ic_74hc595.py │ ├── ic_tm1637.py │ ├── led.py │ ├── led_74hc595.py │ └── tact.py ├── sakshat.py └── sakspins.py ├── 09.小小按键在我手,我的触碰你知道 ├── .ipynb_checkpoints │ └── 1.按键也不赖,方法同样多-checkpoint.ipynb ├── 1.按键也不赖,方法同样多.ipynb ├── __pycache__ │ ├── sakshat.cpython-37.pyc │ └── sakspins.cpython-37.pyc ├── entities │ ├── .ipynb_checkpoints │ │ └── 未命名-checkpoint.ipynb │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── buzzer.cpython-37.pyc │ │ ├── digital_display.cpython-37.pyc │ │ ├── digital_display_tm1637.cpython-37.pyc │ │ ├── dip_switch_2bit.cpython-37.pyc │ │ ├── ds18b20.cpython-37.pyc │ │ ├── ic_74hc595.cpython-37.pyc │ │ ├── ic_tm1637.cpython-37.pyc │ │ ├── led.cpython-37.pyc │ │ ├── led_74hc595.cpython-37.pyc │ │ └── tact.cpython-37.pyc │ ├── buzzer.py │ ├── digital_display.py │ ├── digital_display_tm1637.py │ ├── dip_switch_2bit.py │ ├── ds18b20.py │ ├── ic_74hc595.py │ ├── ic_tm1637.py │ ├── led.py │ ├── led_74hc595.py │ ├── tact.py │ └── 未命名.ipynb ├── sakshat.py └── sakspins.py ├── 10.有了数码管,数字、字母任我写 ├── .ipynb_checkpoints │ └── 1.哈哈,数码管和挺好用的-checkpoint.ipynb ├── 1.哈哈,数码管和挺好用的.ipynb ├── __pycache__ │ ├── sakshat.cpython-35.pyc │ ├── sakshat.cpython-37.pyc │ └── sakspins.cpython-37.pyc ├── entities │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── buzzer.cpython-37.pyc │ │ ├── digital_display.cpython-37.pyc │ │ ├── digital_display_tm1637.cpython-37.pyc │ │ ├── dip_switch_2bit.cpython-37.pyc │ │ ├── ds18b20.cpython-37.pyc │ │ ├── ic_74hc595.cpython-37.pyc │ │ ├── ic_tm1637.cpython-37.pyc │ │ ├── led.cpython-37.pyc │ │ ├── led_74hc595.cpython-37.pyc │ │ └── tact.cpython-37.pyc │ ├── buzzer.py │ ├── digital_display.py │ ├── digital_display_tm1637.py │ ├── dip_switch_2bit.py │ ├── ds18b20.py │ ├── ic_74hc595.py │ ├── ic_tm1637.py │ ├── led.py │ ├── led_74hc595.py │ └── tact.py ├── sakshat.py └── sakspins.py ├── 11.有了他,再不用到处找温度计了 ├── .ipynb_checkpoints │ └── 1.温度采集这么太简单了吧,还想复杂了-checkpoint.ipynb ├── 1.温度采集这么太简单了吧,还想复杂了.ipynb ├── __pycache__ │ ├── sakshat.cpython-37.pyc │ └── sakspins.cpython-37.pyc ├── entities │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── buzzer.cpython-37.pyc │ │ ├── digital_display.cpython-37.pyc │ │ ├── digital_display_tm1637.cpython-37.pyc │ │ ├── dip_switch_2bit.cpython-37.pyc │ │ ├── ds18b20.cpython-37.pyc │ │ ├── ic_74hc595.cpython-37.pyc │ │ ├── ic_tm1637.cpython-37.pyc │ │ ├── led.cpython-37.pyc │ │ ├── led_74hc595.cpython-37.pyc │ │ └── tact.cpython-37.pyc │ ├── buzzer.py │ ├── digital_display.py │ ├── digital_display_tm1637.py │ ├── dip_switch_2bit.py │ ├── ds18b20.py │ ├── ic_74hc595.py │ ├── ic_tm1637.py │ ├── led.py │ ├── led_74hc595.py │ └── tact.py ├── sakshat.py └── sakspins.py ├── 12.调试器在手,想看什么看什么 ├── .ipynb_checkpoints │ └── 1.调试器,软件开发的“倚天屠龙”-checkpoint.ipynb ├── 1.调试器,软件开发的“倚天屠龙”.ipynb ├── __pycache__ │ ├── sakshat.cpython-37.pyc │ └── sakspins.cpython-37.pyc ├── entities │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── buzzer.cpython-37.pyc │ │ ├── digital_display.cpython-37.pyc │ │ ├── digital_display_tm1637.cpython-37.pyc │ │ ├── dip_switch_2bit.cpython-37.pyc │ │ ├── ds18b20.cpython-37.pyc │ │ ├── ic_74hc595.cpython-37.pyc │ │ ├── ic_tm1637.cpython-37.pyc │ │ ├── led.cpython-37.pyc │ │ ├── led_74hc595.cpython-37.pyc │ │ └── tact.cpython-37.pyc │ ├── buzzer.py │ ├── digital_display.py │ ├── digital_display_tm1637.py │ ├── dip_switch_2bit.py │ ├── ds18b20.py │ ├── ic_74hc595.py │ ├── ic_tm1637.py │ ├── led.py │ ├── led_74hc595.py │ └── tact.py ├── picture │ └── python_pdb.jpg ├── sakshat.py └── sakspins.py ├── 13.不论你身在何处,咱们都能聊天 ├── .ipynb_checkpoints │ └── 1.现在随时随地你可以跟我聊天了-checkpoint.ipynb ├── 1.现在随时随地你可以跟我聊天了.ipynb ├── camWebServer2 │ ├── __pycache__ │ │ ├── camera_pi.cpython-37.pyc │ │ ├── sakshat.cpython-37.pyc │ │ └── sakspins.cpython-37.pyc │ ├── appCam2.py │ ├── entities │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── buzzer.cpython-37.pyc │ │ │ ├── digital_display.cpython-37.pyc │ │ │ ├── digital_display_tm1637.cpython-37.pyc │ │ │ ├── dip_switch_2bit.cpython-37.pyc │ │ │ ├── ds18b20.cpython-37.pyc │ │ │ ├── ic_74hc595.cpython-37.pyc │ │ │ ├── ic_tm1637.cpython-37.pyc │ │ │ ├── led.cpython-37.pyc │ │ │ ├── led_74hc595.cpython-37.pyc │ │ │ └── tact.cpython-37.pyc │ │ ├── buzzer.py │ │ ├── digital_display.py │ │ ├── digital_display_tm1637.py │ │ ├── dip_switch_2bit.py │ │ ├── ds18b20.py │ │ ├── ic_74hc595.py │ │ ├── ic_tm1637.py │ │ ├── led.py │ │ ├── led_74hc595.py │ │ └── tact.py │ ├── sakshat.py │ ├── sakspins.py │ ├── static │ │ └── style.css │ └── templates │ │ └── index.html └── picture │ └── raspi_web.jpg ├── 14.我变聪明了,我可以认识的更多 ├── .ipynb_checkpoints │ ├── 1.换种思考方式,我变聪明了-checkpoint.ipynb │ └── 2.让我们直观感受下深度学习-checkpoint.ipynb ├── 1.换种思考方式,我变聪明了.ipynb ├── 2.让我们直观感受下深度学习.ipynb └── picture │ ├── bp_networks.jpg │ ├── image_class.jpg │ ├── object_detect.jpg │ ├── single_networks.jpg │ ├── yolo_detect.jpg │ ├── yolo_mem_err.jpg │ ├── yolo_mode.jpg │ └── 语义分割.jpg ├── 15.是时候用git进行重新整理了 ├── .ipynb_checkpoints │ ├── 1.git软件工具介绍-checkpoint.ipynb │ ├── 2.git+gitee软件托管平台,进行软件开发-checkpoint.ipynb │ └── 3.git+github软件托管平台,进行软件开发-checkpoint.ipynb ├── 1.git软件工具介绍.ipynb ├── 2.git+gitee软件托管平台,进行软件开发.ipynb └── 3.git+github软件托管平台,进行软件开发.ipynb ├── 16.结束了吗?没有啊,下篇更精彩:) ├── .ipynb_checkpoints │ └── 1.下篇会有什么_-checkpoint.ipynb └── 1.下篇会有什么_.ipynb ├── README.md └── 赠言——我都可以,您一定比我强多了 ├── .ipynb_checkpoints └── 1.鸡汤已盛好,干了它吧-checkpoint.ipynb ├── 1.鸡汤已盛好,干了它吧.ipynb └── picture └── my_books.jpg /01.先唠叨两句(好像不止两句)/.ipynb_checkpoints/2.成为时代的弄潮儿,不做局外人-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# 成为时代的弄潮儿,不做局外人\n", 10 | "AIOT时代已经来临,但我们该如何深入其中呢?如何不断地提升自己技能的层次,不被时代淘汰了?That's a good question.\n", 11 | "\n", 12 | "站在AIOT的山脚下,抬头望去,高耸入云的山峰,从山脚下根本望不到顶峰。必然会发出,路在何方的感叹!的确,路在何方呢?\n", 13 | "\n", 14 | "作为一名嵌入式世界里的老鸟,有义务、有责任带领新手们一起攀登这座高山,我已经走过的弯路,可以带领大家避开;但毕竟我也在攀登的途中,对于没走过的路,我也会先行探路,分享出我的经验教训。\n", 15 | "\n", 16 | "全部旅程我准备按照如下路线,带领各位攀登这座高山、欣赏途中的美景。\n", 17 | "\n", 18 | "(1)用python开始我们的旅程,使用python简单、快速、形象的理解操作系统为我们提供了便利,如何使用多任务、如何指挥他们协同工作;同时借用树莓派和NXEZ扩展模块,通过led灯、温度传感器、数码管等形象的展示出来;然后,咱们利用RPi模块,初探python库是如何使用操作系统提供的API(操作系统以c语言方式提供API接口);最后,简单介绍深度学习包含哪些方面的工作,并在树莓派上使用tensorflowlite使用深度学习来进行图像分裂。在获取树莓派4B和Movidius2神经网络棒后,完成具有实用价值的给予树莓派+Movidius2嵌入式深度学习目标识别系统,使用的网络模型为yolo(后面准备使用fpga来实现yolo网络)。\n", 19 | "\n", 20 | "(2)用C语言继续向上攀登,掌握C语言的基本语法、同时我会将C语言的核武器——指针传授给大家,指针是向上继续攀登探索内核必备核武器;然后,按照与python之旅相同的思路,使用C语言理解操作系统提供的工具,并深入解析python库使用操作系统提供的API;最后,咱们分析下yolo作者分享的yolo开源的c语言版网络分析计算过程,逐层讲解模型和参数,为后面使用HLS在ZYNQ上用硬件实现做准备。\n", 21 | "\n", 22 | "(3)有了python和c语言从应用层看操作系统的实践经验,咱们基本明白了操作系统给我们提供哪些服务,下面让我们继续攀登,探索linux内核。这部分会一起欣赏内核中内核驱动和系统调用接口两部分,看看内核如果操作led灯、温度传感器、数码管等外设,如何给应用程序提供系统调用接口,系统调用接口与API什么关系,我们该如果定制自己的内核驱动;同时,咱们看看内核如何使用c语言实现面向对象的思想。\n", 23 | "\n", 24 | "(4)欣赏完内核驱动后,咱们继续前行,进入到内核核心区域,这里有进程管理、内存管理、虚拟文件系统、网络协议栈四个著名风景区,我会主要讲解进程管理、网络协议栈两部分,概要讲解内存管理、虚拟文件系统;这里我们换个角度,从算法角度,看看散列表、二叉树、B+树等如何在内核中应用,激发咱们对算法的兴趣。其中,我会带大家完整的从应用层api到tcp/ip协议栈再到网卡驱动近距离的走一遍,看看无处不在的网络是什么样子的。\n", 25 | "\n", 26 | "(5)参观完cpu端的部分美景后,估计你具备了自行浏览cpu端其他景点的能力,这里你需要博览群书,整理出自己的cpu端体系架构;我的感受就是,看到一片处理器,我看到的是第一层cpu通过片上总线协调各外设工作;第二层内核定时进行进程管理、内存回收等工作,同时将外设中的数据放到内存中,唤醒相应进程工作;第三层,进程按照用户的意愿进行工作,如果需要协调,则想内核发送报告,内核负责对通信和同步。\n", 27 | "\n", 28 | "(6)自行参观完cpu端景点后,咱们继续前行,AIOT这座高峰就在我们前面。嵌入式出身的探索者,可以按照先PS端、然后是深度学习网络模型学习、最后是PL端学习。使用的配套硬件,准备使用sipeed公司的“荔枝糖hex zynq7020 fpga开发板”。对于PS端开发,按照树莓派的思路进行从python开始、经过c语言、内核驱动,最后是内核核心区域。\n", 29 | "\n", 30 | "(7)我们继续攀登,前面是一个完全新的领域,深度学习领域;在当前的深度学习包含三种工作:①大牛研究深度网络模型改进模型,②我们理解大牛的网络模型,利用其模型的特征提取能力,在网络输出端更改为自己的分类,然后用自己的数据集进行训练自行添加层的权重,③将已经训练好的模型,借助HLS使用FPGA实现,实现高能效计算。对于第一点,作为芸芸众生的我们恐怕功力不够,容易走火入魔;但我们可以做第二、三点工作,让深度学习移植到嵌入式端,在嵌入式端工作,让嵌入式更智能。\n", 31 | "\n", 32 | "(8)领略的深度学习的风采后,我们要借助HLS在FPGA上实现我们的网络模型,实现一个低功耗、高性能的边缘端智能处理平台,初步实现AIOT。\n", 33 | "\n", 34 | "以上是我能带领的全部旅程,当然我现在刚刚攀登到第(7)层,准备安营扎寨,细细品味眼睛的美景。我会继续努力攀登,争取早日到达第(8)层,同时与大家分享一路的风采。\n", 35 | "\n", 36 | "当然,即使到了第(8)层,还有更高的山峰在远方,我似乎能隐约看到,远方有座“数学”的高峰,平静、安详而美丽,希望此生能到达那里,摆脱具体技术的束缚,用“数学“的角度,重新理解这个世界,此生足以。" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "metadata": {}, 43 | "outputs": [], 44 | "source": [] 45 | } 46 | ], 47 | "metadata": { 48 | "kernelspec": { 49 | "display_name": "Python 3", 50 | "language": "python", 51 | "name": "python3" 52 | }, 53 | "language_info": { 54 | "codemirror_mode": { 55 | "name": "ipython", 56 | "version": 3 57 | }, 58 | "file_extension": ".py", 59 | "mimetype": "text/x-python", 60 | "name": "python", 61 | "nbconvert_exporter": "python", 62 | "pygments_lexer": "ipython3", 63 | "version": "3.7.3" 64 | } 65 | }, 66 | "nbformat": 4, 67 | "nbformat_minor": 1 68 | } 69 | -------------------------------------------------------------------------------- /01.先唠叨两句(好像不止两句)/2.成为时代的弄潮儿,不做局外人.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# 成为时代的弄潮儿,不做局外人\n", 10 | "AIOT时代已经来临,但我们该如何深入其中呢?如何不断地提升自己技能的层次,不被时代淘汰了?That's a good question.\n", 11 | "\n", 12 | "站在AIOT的山脚下,抬头望去,高耸入云的山峰,从山脚下根本望不到顶峰。必然会发出,路在何方的感叹!的确,路在何方呢?\n", 13 | "\n", 14 | "作为一名嵌入式世界里的老鸟,有义务、有责任带领新手们一起攀登这座高山,我已经走过的弯路,可以带领大家避开;但毕竟我也在攀登的途中,对于没走过的路,我也会先行探路,分享出我的经验教训。\n", 15 | "\n", 16 | "全部旅程我准备按照如下路线,带领各位攀登这座高山、欣赏途中的美景。\n", 17 | "\n", 18 | "(1)用python开始我们的旅程,使用python简单、快速、形象的理解操作系统为我们提供了便利,如何使用多任务、如何指挥他们协同工作;同时借用树莓派和NXEZ扩展模块,通过led灯、温度传感器、数码管等形象的展示出来;然后,咱们利用RPi模块,初探python库是如何使用操作系统提供的API(操作系统以c语言方式提供API接口);最后,简单介绍深度学习包含哪些方面的工作,并在树莓派上使用tensorflowlite使用深度学习来进行图像分裂。在获取树莓派4B和Movidius2神经网络棒后,完成具有实用价值的给予树莓派+Movidius2嵌入式深度学习目标识别系统,使用的网络模型为yolo(后面准备使用fpga来实现yolo网络)。\n", 19 | "\n", 20 | "(2)用C语言继续向上攀登,掌握C语言的基本语法、同时我会将C语言的核武器——指针传授给大家,指针是向上继续攀登探索内核必备核武器;然后,按照与python之旅相同的思路,使用C语言理解操作系统提供的工具,并深入解析python库使用操作系统提供的API;最后,咱们分析下yolo作者分享的yolo开源的c语言版网络分析计算过程,逐层讲解模型和参数,为后面使用HLS在ZYNQ上用硬件实现做准备。\n", 21 | "\n", 22 | "(3)有了python和c语言从应用层看操作系统的实践经验,咱们基本明白了操作系统给我们提供哪些服务,下面让我们继续攀登,探索linux内核。这部分会一起欣赏内核中内核驱动和系统调用接口两部分,看看内核如果操作led灯、温度传感器、数码管等外设,如何给应用程序提供系统调用接口,系统调用接口与API什么关系,我们该如果定制自己的内核驱动;同时,咱们看看内核如何使用c语言实现面向对象的思想。\n", 23 | "\n", 24 | "(4)欣赏完内核驱动后,咱们继续前行,进入到内核核心区域,这里有进程管理、内存管理、虚拟文件系统、网络协议栈四个著名风景区,我会主要讲解进程管理、网络协议栈两部分,概要讲解内存管理、虚拟文件系统;这里我们换个角度,从算法角度,看看散列表、二叉树、B+树等如何在内核中应用,激发咱们对算法的兴趣。其中,我会带大家完整的从应用层api到tcp/ip协议栈再到网卡驱动近距离的走一遍,看看无处不在的网络是什么样子的。\n", 25 | "\n", 26 | "(5)参观完cpu端的部分美景后,估计你具备了自行浏览cpu端其他景点的能力,这里你需要博览群书,整理出自己的cpu端体系架构;我的感受就是,看到一片处理器,我看到的是第一层cpu通过片上总线协调各外设工作;第二层内核定时进行进程管理、内存回收等工作,同时将外设中的数据放到内存中,唤醒相应进程工作;第三层,进程按照用户的意愿进行工作,如果需要协调,则想内核发送报告,内核负责对通信和同步。\n", 27 | "\n", 28 | "(6)自行参观完cpu端景点后,咱们继续前行,AIOT这座高峰就在我们前面。嵌入式出身的探索者,可以按照先PS端、然后是深度学习网络模型学习、最后是PL端学习。使用的配套硬件,准备使用sipeed公司的“荔枝糖hex zynq7020 fpga开发板”。对于PS端开发,按照树莓派的思路进行从python开始、经过c语言、内核驱动,最后是内核核心区域。\n", 29 | "\n", 30 | "(7)我们继续攀登,前面是一个完全新的领域,深度学习领域;在当前的深度学习包含三种工作:①大牛研究深度网络模型改进模型,②我们理解大牛的网络模型,利用其模型的特征提取能力,在网络输出端更改为自己的分类,然后用自己的数据集进行训练自行添加层的权重,③将已经训练好的模型,借助HLS使用FPGA实现,实现高能效计算。对于第一点,作为芸芸众生的我们恐怕功力不够,容易走火入魔;但我们可以做第二、三点工作,让深度学习移植到嵌入式端,在嵌入式端工作,让嵌入式更智能。\n", 31 | "\n", 32 | "(8)领略的深度学习的风采后,我们要借助HLS在FPGA上实现我们的网络模型,实现一个低功耗、高性能的边缘端智能处理平台,初步实现AIOT。\n", 33 | "\n", 34 | "以上是我能带领的全部旅程,当然我现在刚刚攀登到第(7)层,准备安营扎寨,细细品味眼睛的美景。我会继续努力攀登,争取早日到达第(8)层,同时与大家分享一路的风采。\n", 35 | "\n", 36 | "当然,即使到了第(8)层,还有更高的山峰在远方,我似乎能隐约看到,远方有座“数学”的高峰,平静、安详而美丽,希望此生能到达那里,摆脱具体技术的束缚,用“数学“的角度,重新理解这个世界,此生足以。" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "metadata": {}, 43 | "outputs": [], 44 | "source": [] 45 | } 46 | ], 47 | "metadata": { 48 | "kernelspec": { 49 | "display_name": "Python 3", 50 | "language": "python", 51 | "name": "python3" 52 | }, 53 | "language_info": { 54 | "codemirror_mode": { 55 | "name": "ipython", 56 | "version": 3 57 | }, 58 | "file_extension": ".py", 59 | "mimetype": "text/x-python", 60 | "name": "python", 61 | "nbconvert_exporter": "python", 62 | "pygments_lexer": "ipython3", 63 | "version": "3.7.3" 64 | } 65 | }, 66 | "nbformat": 4, 67 | "nbformat_minor": 1 68 | } 69 | -------------------------------------------------------------------------------- /02.近距离看看计算机硬件体系结构/picture/imx6q_soc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/02.近距离看看计算机硬件体系结构/picture/imx6q_soc.png -------------------------------------------------------------------------------- /02.近距离看看计算机硬件体系结构/picture/pc_board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/02.近距离看看计算机硬件体系结构/picture/pc_board.jpg -------------------------------------------------------------------------------- /02.近距离看看计算机硬件体系结构/picture/raspi_3b_board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/02.近距离看看计算机硬件体系结构/picture/raspi_3b_board.jpg -------------------------------------------------------------------------------- /02.近距离看看计算机硬件体系结构/picture/zynq7000_soc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/02.近距离看看计算机硬件体系结构/picture/zynq7000_soc.png -------------------------------------------------------------------------------- /02.近距离看看计算机硬件体系结构/picture/zynq_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/02.近距离看看计算机硬件体系结构/picture/zynq_1.jpg -------------------------------------------------------------------------------- /02.近距离看看计算机硬件体系结构/picture/zynq_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/02.近距离看看计算机硬件体系结构/picture/zynq_2.jpg -------------------------------------------------------------------------------- /03.操作系统为何物?为什么要花这么大精力来使用他?/.ipynb_checkpoints/1.操作系统为何物?-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# 百度百科定义\n", 10 | "操作系统是管理计算机硬件与软件资源的计算机程序,同时也是计算机系统的内核与基石。操作系统需要处理如管理与配置内存、决定系统资源供需的优先次序、控制输入设备与输出设备、操作网络与管理文件系统等基本事务。操作系统也提供一个让用户与系统交互的操作界面。\n", 11 | "\n", 12 | "帮我们管理好计算机硬件,我们可以通过操作系统友好的使用计算机。" 13 | ] 14 | }, 15 | { 16 | "cell_type": "markdown", 17 | "metadata": {}, 18 | "source": [ 19 | "# 操作系统分类\n", 20 | "\n", 21 | "操作系统体系结构划分:\n", 22 | "\n", 23 | "(1)简单体系结构。例如ucos系列、FreeRTOS、SylixOS、VxWorks(基本级)。特点:用户层与内核层在一个地址空间中。不使用或有限使用虚拟内存。\n", 24 | "\n", 25 | "(2)单体内核(宏内核)。例如,Linux、Unix、Windows、MacOS。特点:操作系统的进程管理、内存管理、设备驱动、文件系统、网络协议栈等都在一个地址空间中,内核十分巨大。\n", 26 | "\n", 27 | "(3)微内核。例如:QNX。特点:内核只保留进程进程管理、内存管理等内核组成模块,将设备驱动、文件系统、网络协议栈编程进程的方式运行,就是一个字:小。\n", 28 | "\n", 29 | "微内核VS宏内核:\n", 30 | "\n", 31 | "(1)系统可靠性:微内核只保留了最基本的内核组成模块,一旦像设备驱动、文件系统异常,不会影响内核运行;而宏内核中,例如你编写了驱动有bug,那整个系统基本都能挂掉了。微内核胜出。\n", 32 | "\n", 33 | "(2)系统性能:宏内核中所有内核组成模块在一个地址空间,模块与模块间通信不涉及内存地址空间的切换,所以速度快;但微内核以像消息队列的方式,完成内核和网络协议栈、设备驱动等模块的通信,这其中涉及内存地址空间的切换,必然形象速度。宏内核胜出。\n", 34 | "\n", 35 | "其实,微内核和宏内核都各有优势,在一个具体的操作系统设计时,会吸取各自的长处;例如,linux是宏内核,但其借鉴了微内核的设计思路,将内核模块引入操作系统中,可以在系统运行过程中,加载或卸载设备驱动等内核组成部分。\n", 36 | "\n", 37 | "按实时性划分:\n", 38 | "\n", 39 | "(1)实时系统。\n", 40 | "\n", 41 | " <1>强实时系统。在指定时间内,一定完成该项任务。例如:VxWorks、SylixOS、QNX等。\n", 42 | " \n", 43 | " <2>弱(软)实时系统。在指定时间内,尽量完成该任务。例如:增加实时性的linux系统。\n", 44 | " \n", 45 | "(2)非实时系统。例如,windows。\n", 46 | "\n", 47 | "影响实时性的几个因素:\n", 48 | "\n", 49 | "(1)中断设计。一般芯片或者操作系统不会配置为中断可嵌套模式,所以CPU进入中断后,除非执行完毕中断处理程序才能执行其他任务。这是一个很重要的指标,我之前你看过linux的部分网络设备驱动程序,有的在中断中记录事件,利用系统提供的网络软中断模式(此时,已经退出中断模式,cpu可以继续响应中断了)进行数据的处理,但有的驱动在中断里进行数据处理,如果cpu正在中断中处理网络数据,但此时来了一紧急中断,那只能等了。\n", 50 | "\n", 51 | "(2)内存管理。有了虚拟内存后,应用层进入内核,内核会应用层,必然消耗大量时间,影响指定时间内完成任务重要因素。\n", 52 | "\n", 53 | "但是,不是你使用了强实时系统,你的设备就能保证强实时的要求,例如你写一个驱动,在中断中完成任务,那因为你的驱动而响应整个系统的实时性。\n", 54 | "\n", 55 | "这么多种操作系统,我们该如何选择呢?\n", 56 | "\n", 57 | "(1)实时性要求极高的系统。可以使用商业的VxWorks和SylixOS,商业的是要收费的,而且VxWorks是美国红河公司的,技术支持的难度可想而知;国产自主可控的SylixOS是一个很好的选择,只是起步晚,成功的案例正在逐步积累,被领域内所认可需要时间。对于非商业的,可以使用FreeRTOS,开源免费的,目前是商业免费的。\n", 58 | "\n", 59 | "(2)任务要求多、功能复杂等的只能选择像linux这样的系统了。基本可以认为,计算机能完成什么样的功能,使用linux的嵌入式系统也能完成;当然要求你的芯片对性能是否有影响。" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": null, 65 | "metadata": {}, 66 | "outputs": [], 67 | "source": [] 68 | } 69 | ], 70 | "metadata": { 71 | "kernelspec": { 72 | "display_name": "Python 3", 73 | "language": "python", 74 | "name": "python3" 75 | }, 76 | "language_info": { 77 | "codemirror_mode": { 78 | "name": "ipython", 79 | "version": 3 80 | }, 81 | "file_extension": ".py", 82 | "mimetype": "text/x-python", 83 | "name": "python", 84 | "nbconvert_exporter": "python", 85 | "pygments_lexer": "ipython3", 86 | "version": "3.7.3" 87 | } 88 | }, 89 | "nbformat": 4, 90 | "nbformat_minor": 1 91 | } 92 | -------------------------------------------------------------------------------- /03.操作系统为何物?为什么要花这么大精力来使用他?/.ipynb_checkpoints/3.何为Linux发行版-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# Linux内核与GNU/Linux发行版\n", 10 | "\n", 11 | "GNU为何物,百度百科给出解释:\n", 12 | "\n", 13 | "GNU是一个自由的操作系统,其内容软件完全以GPL方式发布。这个操作系统是GNU计划的主要目标,名称来自GNU's Not Unix!的递归缩写,因为GNU的设计类似Unix,但它不包含具著作权的Unix代码。GNU的创始人,理查德·马修·斯托曼,将GNU视为“达成社会目的技术方法”。\n", 14 | "\n", 15 | "由于UNIX的商业化,将自己封闭起来;此时,理查德·马修·斯托曼不爽了,建立了GNU组织,经多年的努力,处理操作系统的内核外,像大名鼎鼎的gcc、gdb、emacs(编辑器,据传闻世界只有三种编辑器:emacs、vi、其他编辑器)都是GNU的作品。但唯独缺少好的操作系统内核,1990年还是学生的Linus Torvalds(林哥),贡献出了自己做的一个内核,从此一发不可收拾,全世界的黑客(这里的黑客是hacker的本意,是热爱计算机、水平超高的计算机专家;cracker才是公众所有的窃取、偷窥为目的不良计算机使用者)共同完善这个内核,才有了今天的linux内核。linus是领袖,linux是全世界智慧的结晶。\n", 16 | "\n", 17 | "GNU/Linux发行版,是基于Linux内核的类Unix操作系统。Linux发行版通常包含了包括桌面环境、办公包、媒体播放器、数据库等应用软件。就是在linux内核之上,包含了大量的软件和工具包,让用户可以使用的操作系统。\n", 18 | "\n", 19 | "常见的GNU/Linux发行版:Ubuntu、RedHat、Debian、Fedora、CentOS等。\n", 20 | "\n", 21 | "咱们本套教程用的raspbian操作系统是基于Debian。这是他的介绍:\n", 22 | "\n", 23 | "Raspbian 是基于 Debian GNU/Linux 的免费操作系统,它面向 Raspberry Pi 硬件( armhf 处理器架构)而做了优化。Raspbian 带有 35000 多个软件包或预编译软件,它们按优美的格式打包从而便于在 Raspberry Pi 上安装。该发行的首个创建完成于2012年六月,但它获得了持续活跃的开发,并且重点在于提高尽可能多的 Debian 软件包的稳定性及性能。虽然 Debian 为 arm 架构提供一份发行,但是它只兼容 Raspberry Pi 上之后的版本(即 ARMv7-A 中央处理器及更高版本,相比于 Raspberry Pi 的 ARMv6 中央处理器)" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": null, 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [] 32 | } 33 | ], 34 | "metadata": { 35 | "kernelspec": { 36 | "display_name": "Python 3", 37 | "language": "python", 38 | "name": "python3" 39 | }, 40 | "language_info": { 41 | "codemirror_mode": { 42 | "name": "ipython", 43 | "version": 3 44 | }, 45 | "file_extension": ".py", 46 | "mimetype": "text/x-python", 47 | "name": "python", 48 | "nbconvert_exporter": "python", 49 | "pygments_lexer": "ipython3", 50 | "version": "3.7.3" 51 | } 52 | }, 53 | "nbformat": 4, 54 | "nbformat_minor": 1 55 | } 56 | -------------------------------------------------------------------------------- /03.操作系统为何物?为什么要花这么大精力来使用他?/1.操作系统为何物?.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# 百度百科定义\n", 10 | "操作系统是管理计算机硬件与软件资源的计算机程序,同时也是计算机系统的内核与基石。操作系统需要处理如管理与配置内存、决定系统资源供需的优先次序、控制输入设备与输出设备、操作网络与管理文件系统等基本事务。操作系统也提供一个让用户与系统交互的操作界面。\n", 11 | "\n", 12 | "帮我们管理好计算机硬件,我们可以通过操作系统友好的使用计算机。" 13 | ] 14 | }, 15 | { 16 | "cell_type": "markdown", 17 | "metadata": {}, 18 | "source": [ 19 | "# 操作系统分类\n", 20 | "\n", 21 | "操作系统体系结构划分:\n", 22 | "\n", 23 | "(1)简单体系结构。例如ucos系列、FreeRTOS、SylixOS、VxWorks(基本级)。特点:用户层与内核层在一个地址空间中。不使用或有限使用虚拟内存。\n", 24 | "\n", 25 | "(2)单体内核(宏内核)。例如,Linux、Unix、Windows、MacOS。特点:操作系统的进程管理、内存管理、设备驱动、文件系统、网络协议栈等都在一个地址空间中,内核十分巨大。\n", 26 | "\n", 27 | "(3)微内核。例如:QNX。特点:内核只保留进程进程管理、内存管理等内核组成模块,将设备驱动、文件系统、网络协议栈编程进程的方式运行,就是一个字:小。\n", 28 | "\n", 29 | "微内核VS宏内核:\n", 30 | "\n", 31 | "(1)系统可靠性:微内核只保留了最基本的内核组成模块,一旦像设备驱动、文件系统异常,不会影响内核运行;而宏内核中,例如你编写了驱动有bug,那整个系统基本都能挂掉了。微内核胜出。\n", 32 | "\n", 33 | "(2)系统性能:宏内核中所有内核组成模块在一个地址空间,模块与模块间通信不涉及内存地址空间的切换,所以速度快;但微内核以像消息队列的方式,完成内核和网络协议栈、设备驱动等模块的通信,这其中涉及内存地址空间的切换,必然形象速度。宏内核胜出。\n", 34 | "\n", 35 | "其实,微内核和宏内核都各有优势,在一个具体的操作系统设计时,会吸取各自的长处;例如,linux是宏内核,但其借鉴了微内核的设计思路,将内核模块引入操作系统中,可以在系统运行过程中,加载或卸载设备驱动等内核组成部分。\n", 36 | "\n", 37 | "按实时性划分:\n", 38 | "\n", 39 | "(1)实时系统。\n", 40 | "\n", 41 | " <1>强实时系统。在指定时间内,一定完成该项任务。例如:VxWorks、SylixOS、QNX等。\n", 42 | " \n", 43 | " <2>弱(软)实时系统。在指定时间内,尽量完成该任务。例如:增加实时性的linux系统。\n", 44 | " \n", 45 | "(2)非实时系统。例如,windows。\n", 46 | "\n", 47 | "影响实时性的几个因素:\n", 48 | "\n", 49 | "(1)中断设计。一般芯片或者操作系统不会配置为中断可嵌套模式,所以CPU进入中断后,除非执行完毕中断处理程序才能执行其他任务。这是一个很重要的指标,我之前你看过linux的部分网络设备驱动程序,有的在中断中记录事件,利用系统提供的网络软中断模式(此时,已经退出中断模式,cpu可以继续响应中断了)进行数据的处理,但有的驱动在中断里进行数据处理,如果cpu正在中断中处理网络数据,但此时来了一紧急中断,那只能等了。\n", 50 | "\n", 51 | "(2)内存管理。有了虚拟内存后,应用层进入内核,内核会应用层,必然消耗大量时间,影响指定时间内完成任务重要因素。\n", 52 | "\n", 53 | "但是,不是你使用了强实时系统,你的设备就能保证强实时的要求,例如你写一个驱动,在中断中完成任务,那因为你的驱动而响应整个系统的实时性。\n", 54 | "\n", 55 | "这么多种操作系统,我们该如何选择呢?\n", 56 | "\n", 57 | "(1)实时性要求极高的系统。可以使用商业的VxWorks和SylixOS,商业的是要收费的,而且VxWorks是美国红河公司的,技术支持的难度可想而知;国产自主可控的SylixOS是一个很好的选择,只是起步晚,成功的案例正在逐步积累,被领域内所认可需要时间。对于非商业的,可以使用FreeRTOS,开源免费的,目前是商业免费的。\n", 58 | "\n", 59 | "(2)任务要求多、功能复杂等的只能选择像linux这样的系统了。基本可以认为,计算机能完成什么样的功能,使用linux的嵌入式系统也能完成;当然要求你的芯片对性能是否有影响。" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": null, 65 | "metadata": {}, 66 | "outputs": [], 67 | "source": [] 68 | } 69 | ], 70 | "metadata": { 71 | "kernelspec": { 72 | "display_name": "Python 3", 73 | "language": "python", 74 | "name": "python3" 75 | }, 76 | "language_info": { 77 | "codemirror_mode": { 78 | "name": "ipython", 79 | "version": 3 80 | }, 81 | "file_extension": ".py", 82 | "mimetype": "text/x-python", 83 | "name": "python", 84 | "nbconvert_exporter": "python", 85 | "pygments_lexer": "ipython3", 86 | "version": "3.7.3" 87 | } 88 | }, 89 | "nbformat": 4, 90 | "nbformat_minor": 1 91 | } 92 | -------------------------------------------------------------------------------- /03.操作系统为何物?为什么要花这么大精力来使用他?/3.何为Linux发行版.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# Linux内核与GNU/Linux发行版\n", 10 | "\n", 11 | "GNU为何物,百度百科给出解释:\n", 12 | "\n", 13 | "GNU是一个自由的操作系统,其内容软件完全以GPL方式发布。这个操作系统是GNU计划的主要目标,名称来自GNU's Not Unix!的递归缩写,因为GNU的设计类似Unix,但它不包含具著作权的Unix代码。GNU的创始人,理查德·马修·斯托曼,将GNU视为“达成社会目的技术方法”。\n", 14 | "\n", 15 | "由于UNIX的商业化,将自己封闭起来;此时,理查德·马修·斯托曼不爽了,建立了GNU组织,经多年的努力,处理操作系统的内核外,像大名鼎鼎的gcc、gdb、emacs(编辑器,据传闻世界只有三种编辑器:emacs、vi、其他编辑器)都是GNU的作品。但唯独缺少好的操作系统内核,1990年还是学生的Linus Torvalds(林哥),贡献出了自己做的一个内核,从此一发不可收拾,全世界的黑客(这里的黑客是hacker的本意,是热爱计算机、水平超高的计算机专家;cracker才是公众所有的窃取、偷窥为目的不良计算机使用者)共同完善这个内核,才有了今天的linux内核。linus是领袖,linux是全世界智慧的结晶。\n", 16 | "\n", 17 | "GNU/Linux发行版,是基于Linux内核的类Unix操作系统。Linux发行版通常包含了包括桌面环境、办公包、媒体播放器、数据库等应用软件。就是在linux内核之上,包含了大量的软件和工具包,让用户可以使用的操作系统。\n", 18 | "\n", 19 | "常见的GNU/Linux发行版:Ubuntu、RedHat、Debian、Fedora、CentOS等。\n", 20 | "\n", 21 | "咱们本套教程用的raspbian操作系统是基于Debian。这是他的介绍:\n", 22 | "\n", 23 | "Raspbian 是基于 Debian GNU/Linux 的免费操作系统,它面向 Raspberry Pi 硬件( armhf 处理器架构)而做了优化。Raspbian 带有 35000 多个软件包或预编译软件,它们按优美的格式打包从而便于在 Raspberry Pi 上安装。该发行的首个创建完成于2012年六月,但它获得了持续活跃的开发,并且重点在于提高尽可能多的 Debian 软件包的稳定性及性能。虽然 Debian 为 arm 架构提供一份发行,但是它只兼容 Raspberry Pi 上之后的版本(即 ARMv7-A 中央处理器及更高版本,相比于 Raspberry Pi 的 ARMv6 中央处理器)" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": null, 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [] 32 | } 33 | ], 34 | "metadata": { 35 | "kernelspec": { 36 | "display_name": "Python 3", 37 | "language": "python", 38 | "name": "python3" 39 | }, 40 | "language_info": { 41 | "codemirror_mode": { 42 | "name": "ipython", 43 | "version": 3 44 | }, 45 | "file_extension": ".py", 46 | "mimetype": "text/x-python", 47 | "name": "python", 48 | "nbconvert_exporter": "python", 49 | "pygments_lexer": "ipython3", 50 | "version": "3.7.3" 51 | } 52 | }, 53 | "nbformat": 4, 54 | "nbformat_minor": 1 55 | } 56 | -------------------------------------------------------------------------------- /03.操作系统为何物?为什么要花这么大精力来使用他?/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/03.操作系统为何物?为什么要花这么大精力来使用他?/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /03.操作系统为何物?为什么要花这么大精力来使用他?/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/03.操作系统为何物?为什么要花这么大精力来使用他?/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /03.操作系统为何物?为什么要花这么大精力来使用他?/picture/linux_kernel_1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/03.操作系统为何物?为什么要花这么大精力来使用他?/picture/linux_kernel_1.jpeg -------------------------------------------------------------------------------- /03.操作系统为何物?为什么要花这么大精力来使用他?/picture/linux_kernel_2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/03.操作系统为何物?为什么要花这么大精力来使用他?/picture/linux_kernel_2.jpeg -------------------------------------------------------------------------------- /04.多任务,原来如此简单/.ipynb_checkpoints/4.置身事外看编程语言-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# 注意\n", 8 | "本课程不是python语言语法学习课程,因为现在网上有大量优质的python语言语法学习课程,同学们可以自行选择免费的或收费的python语法课程,学习python本身。\n", 9 | "\n", 10 | "本课程定位于:如何使用python理解树莓派、理解操作系统。放心由于python语言的通俗易懂,加上本课程都是最基本的python,及时没有基础,也可以快速理解,记住,咱们的课程是可以边学边练、随意修改、还有恢复机制,放心折腾吧。" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": {}, 16 | "source": [ 17 | "# 置身事外看编程语言\n", 18 | "咱们不探究python语言本身,那咱们探究下何为编程语言。(下面是个人理解,咱们可以敞开讨论)\n", 19 | "\n", 20 | "编程语言的目的就是——把我们要做成的事情,翻译成计算机能理解的方式,告送计算机,由计算机帮我们实现。那咱们看看我总结的编程语言三大组成部分:\n", 21 | "\n", 22 | "(1)变量。就是咱们要处理的信息,例如:温度数据、车的速度,楼的高度。变量可以继续划分,但划分的目的就是存储数据的大小,例如8位(2的8次方)变量可以存储0~255数字量,32位数据(2的32次方)存储0~4294967295。还有16位,64位、或者像python中不限制大小的变量。\n", 23 | "\n", 24 | "(2)程序结构。就是咱们处理信息所使用的流程。有顺序结构、条件结构、循环结构。顺序结构很容易理解,就是依次处理数据,例如,我们依次进行,获取温度数据、获取汽车速度;条件结构,就是需要对信息进行判断,然后再处理,例如,获取完毕汽车速度后,判断汽车超速,就进行刹车;循环结构,就是不断地重复相同的事情,例如,我们每隔1s采集一次温度,就是不断循环的进行采集温度、睡眠1s、再采集温度、睡眠1s...。\n", 25 | "\n", 26 | "(3)系统和第三方提供的库。其实有了变量和程序结构,就可以完成咱们要的工作,但是如果事必躬亲的话,估计咱们还处在原始社会。后人进步总是站在前人的肩膀上继续攀登。所以,前人已经他们已完成的工作,打包好,前人已完成的功能,我们理解后直接用,我们专注于自己新的工作。系统和第三方库,就是我们可以使用的现成工具,我们合理利用这些工具,重新组合完成我们新的需求,如果您做的好,您可以将您的工作封装成第三方库,留给后人使用。\n", 27 | "\n", 28 | "这是我理解的编程语言的框架,您可以先按照我的方式看语言,或者自己建立自己语言框架。" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [] 37 | } 38 | ], 39 | "metadata": { 40 | "kernelspec": { 41 | "display_name": "Python 3", 42 | "language": "python", 43 | "name": "python3" 44 | }, 45 | "language_info": { 46 | "codemirror_mode": { 47 | "name": "ipython", 48 | "version": 3 49 | }, 50 | "file_extension": ".py", 51 | "mimetype": "text/x-python", 52 | "name": "python", 53 | "nbconvert_exporter": "python", 54 | "pygments_lexer": "ipython3", 55 | "version": "3.7.3" 56 | } 57 | }, 58 | "nbformat": 4, 59 | "nbformat_minor": 2 60 | } 61 | -------------------------------------------------------------------------------- /04.多任务,原来如此简单/4.置身事外看编程语言.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# 注意\n", 8 | "本课程不是python语言语法学习课程,因为现在网上有大量优质的python语言语法学习课程,同学们可以自行选择免费的或收费的python语法课程,学习python本身。\n", 9 | "\n", 10 | "本课程定位于:如何使用python理解树莓派、理解操作系统。放心由于python语言的通俗易懂,加上本课程都是最基本的python,及时没有基础,也可以快速理解,记住,咱们的课程是可以边学边练、随意修改、还有恢复机制,放心折腾吧。" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": {}, 16 | "source": [ 17 | "# 置身事外看编程语言\n", 18 | "咱们不探究python语言本身,那咱们探究下何为编程语言。(下面是个人理解,咱们可以敞开讨论)\n", 19 | "\n", 20 | "编程语言的目的就是——把我们要做成的事情,翻译成计算机能理解的方式,告送计算机,由计算机帮我们实现。那咱们看看我总结的编程语言三大组成部分:\n", 21 | "\n", 22 | "(1)变量。就是咱们要处理的信息,例如:温度数据、车的速度,楼的高度。变量可以继续划分,但划分的目的就是存储数据的大小,例如8位(2的8次方)变量可以存储0~255数字量,32位数据(2的32次方)存储0~4294967295。还有16位,64位、或者像python中不限制大小的变量。\n", 23 | "\n", 24 | "(2)程序结构。就是咱们处理信息所使用的流程。有顺序结构、条件结构、循环结构。顺序结构很容易理解,就是依次处理数据,例如,我们依次进行,获取温度数据、获取汽车速度;条件结构,就是需要对信息进行判断,然后再处理,例如,获取完毕汽车速度后,判断汽车超速,就进行刹车;循环结构,就是不断地重复相同的事情,例如,我们每隔1s采集一次温度,就是不断循环的进行采集温度、睡眠1s、再采集温度、睡眠1s...。\n", 25 | "\n", 26 | "(3)系统和第三方提供的库。其实有了变量和程序结构,就可以完成咱们要的工作,但是如果事必躬亲的话,估计咱们还处在原始社会。后人进步总是站在前人的肩膀上继续攀登。所以,前人已经他们已完成的工作,打包好,前人已完成的功能,我们理解后直接用,我们专注于自己新的工作。系统和第三方库,就是我们可以使用的现成工具,我们合理利用这些工具,重新组合完成我们新的需求,如果您做的好,您可以将您的工作封装成第三方库,留给后人使用。\n", 27 | "\n", 28 | "这是我理解的编程语言的框架,您可以先按照我的方式看语言,或者自己建立自己语言框架。" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [] 37 | } 38 | ], 39 | "metadata": { 40 | "kernelspec": { 41 | "display_name": "Python 3", 42 | "language": "python", 43 | "name": "python3" 44 | }, 45 | "language_info": { 46 | "codemirror_mode": { 47 | "name": "ipython", 48 | "version": 3 49 | }, 50 | "file_extension": ".py", 51 | "mimetype": "text/x-python", 52 | "name": "python", 53 | "nbconvert_exporter": "python", 54 | "pygments_lexer": "ipython3", 55 | "version": "3.7.3" 56 | } 57 | }, 58 | "nbformat": 4, 59 | "nbformat_minor": 2 60 | } 61 | -------------------------------------------------------------------------------- /04.多任务,原来如此简单/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__init__.py: -------------------------------------------------------------------------------- 1 | from .buzzer import Buzzer 2 | from .led import Led 3 | from .led import LedRow 4 | from .ds18b20 import DS18B20 5 | from .digital_display import DigitalDisplay 6 | from .dip_switch_2bit import DipSwitch2Bit 7 | from .tact import Tact 8 | from .tact import TactRow 9 | from .ic_74hc595 import IC_74HC595 10 | from .led_74hc595 import Led74HC595 11 | from .ic_tm1637 import IC_TM1637 12 | from .digital_display_tm1637 import DigitalDisplayTM1637 13 | -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/buzzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/buzzer.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/digital_display.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/digital_display.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/digital_display_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/digital_display_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/dip_switch_2bit.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/dip_switch_2bit.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/ds18b20.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/ds18b20.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/ic_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/ic_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/ic_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/ic_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/led.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/led.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/led_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/led_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/__pycache__/tact.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/entities/__pycache__/tact.cpython-37.pyc -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2015 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | import time 21 | 22 | class Buzzer(object): 23 | ''' 24 | Buzzer class 25 | ''' 26 | __pin = 0 27 | __real_true = GPIO.HIGH 28 | __is_on = False 29 | 30 | def __init__(self, pin, real_true = GPIO.HIGH): 31 | ''' 32 | Init the buzzer 33 | :param pin: pin number 34 | :param real_true: GPIO.HIGH or GPIO.LOW 35 | :return: void 36 | ''' 37 | self.__pin = pin 38 | self.__real_true = real_true 39 | 40 | #Stauts. 41 | @property 42 | def is_on(self): 43 | ''' 44 | Return the status of buzzer 45 | :return: void 46 | ''' 47 | return self.__is_on 48 | 49 | #Verbs. 50 | def on(self): 51 | ''' 52 | Set buzzer on 53 | :return: void 54 | ''' 55 | GPIO.output(self.__pin, self.__real_true) 56 | self.__is_on = True 57 | 58 | def off(self): 59 | ''' 60 | Set buzzer off 61 | :return: void 62 | ''' 63 | GPIO.output(self.__pin, not self.__real_true) 64 | self.__is_on = False 65 | 66 | #functions. 67 | def beep(self, seconds): 68 | ''' 69 | Beep one time 70 | :param seconds: beep time 71 | :return: void 72 | ''' 73 | self.on() 74 | time.sleep(seconds) 75 | self.off() 76 | 77 | def beepAction(self, secs, sleepsecs, times): 78 | ''' 79 | Beep in a rhythm 80 | e.g. beepAction(0.02,0.02,30) 81 | :param secs: beep time 82 | :param sleepsecs: break time 83 | :param times: repeat times 84 | :return: void 85 | ''' 86 | for i in range(times): 87 | self.beep(secs) 88 | time.sleep(sleepsecs) 89 | -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/ic_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | 21 | class IC_74HC595(object): 22 | ''' 23 | IC_74HC595 class 24 | ''' 25 | __pins = {'ds':0, 'shcp':0, 'stcp':0} 26 | __real_true = GPIO.HIGH 27 | __data = 0x00 28 | 29 | def __init__(self, pins, real_true = GPIO.HIGH): 30 | ''' 31 | Init the ic 32 | :param pin: pin number 33 | :param real_true: GPIO.HIGH or GPIO.LOW 34 | :return: void 35 | ''' 36 | self.__pins = pins 37 | self.__real_true = real_true 38 | 39 | #Stauts. 40 | @property 41 | def data(self): 42 | ''' 43 | Return the data 44 | :return: void 45 | ''' 46 | return self.__data 47 | 48 | #Verbs. 49 | def flush_shcp(self): 50 | ''' 51 | Flush a shcp 52 | :return: void 53 | ''' 54 | GPIO.output(self.__pins['shcp'], not self.__real_true) 55 | GPIO.output(self.__pins['shcp'], self.__real_true) 56 | 57 | def flush_stcp(self): 58 | ''' 59 | Flush a stcp 60 | :return: void 61 | ''' 62 | GPIO.output(self.__pins['stcp'], not self.__real_true) 63 | GPIO.output(self.__pins['stcp'], self.__real_true) 64 | 65 | def set_bit(self, bit): 66 | ''' 67 | Set a bit 68 | :param bit: bit 69 | :return: void 70 | ''' 71 | GPIO.output(self.__pins['ds'], bit) 72 | self.flush_shcp() 73 | 74 | def set_data(self, data): 75 | ''' 76 | Set a byte 77 | :param data: data 78 | :return: void 79 | ''' 80 | self.__data = data 81 | for i in range (0, 8): 82 | self.set_bit((self.__data >> i) & 0x01) 83 | 84 | self.flush_stcp() 85 | 86 | 87 | def clear(self): 88 | ''' 89 | Clear the data 90 | :return: void 91 | ''' 92 | self.set_data(0x00) 93 | -------------------------------------------------------------------------------- /04.多任务,原来如此简单/entities/led_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | from .ic_74hc595 import IC_74HC595 as IC_74HC595 21 | 22 | class Led74HC595(object): 23 | ''' 24 | Class of leds in 74HC595 25 | ''' 26 | __ic_74hc595 = None 27 | 28 | def __init__(self, pins, real_true = GPIO.HIGH): 29 | ''' 30 | Init the leds 31 | :param pin: pin numbers in array 32 | :param real_true: GPIO.HIGH or GPIO.LOW 33 | :return: void 34 | ''' 35 | self.__ic_74hc595 = IC_74HC595(pins, real_true) 36 | 37 | #Stauts. 38 | @property 39 | def ic(self): 40 | return self.__ic_74hc595 41 | 42 | def is_on(self, index): 43 | ''' 44 | Get status of led in ledrow by index 45 | :param index: index of the led 46 | :return: status in boolean 47 | ''' 48 | if index >= 8: 49 | return False 50 | return self.__ic_74hc595.data >> index & 0x01 51 | 52 | @property 53 | def row_status(self): 54 | ''' 55 | Get status array of the ledrow 56 | :return: status array 57 | ''' 58 | r = [] 59 | for i in range (0, 8): 60 | r.append(self.__ic_74hc595.data >> i & 0x01) 61 | return r 62 | 63 | #Verbs. 64 | def on(self): 65 | ''' 66 | Set all the leds on 67 | :return: void 68 | ''' 69 | self.__ic_74hc595.set_data(0xff) 70 | 71 | def off(self): 72 | ''' 73 | Set all the leds off 74 | :return: void 75 | ''' 76 | self.__ic_74hc595.clear() 77 | 78 | def on_for_index(self, index): 79 | ''' 80 | Set the led on by index in the ledrow 81 | :return: void 82 | ''' 83 | self.__ic_74hc595.set_data(self.__ic_74hc595.data | (0x01 << (index))) 84 | 85 | def off_for_index(self, index): 86 | ''' 87 | Set the led off by index in the ledrow 88 | :return: void 89 | ''' 90 | arr = [0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f] 91 | self.__ic_74hc595.set_data(self.__ic_74hc595.data & arr[index]) 92 | 93 | def set_row(self, status): 94 | ''' 95 | Set the ledrow's status in boolean array 96 | :param status: boolean array 97 | :return: void 98 | ''' 99 | for i in range(len(status)): 100 | #print(str(i) + str(status[i])) 101 | if status[i] is None: 102 | continue 103 | if status[i]: 104 | self.on_for_index(i) 105 | else: 106 | self.off_for_index(i) 107 | -------------------------------------------------------------------------------- /04.多任务,原来如此简单/picture/nxez_raspi_setup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/picture/nxez_raspi_setup.jpg -------------------------------------------------------------------------------- /04.多任务,原来如此简单/picture/processing_status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/04.多任务,原来如此简单/picture/processing_status.png -------------------------------------------------------------------------------- /04.多任务,原来如此简单/sakshat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | __author__ = 'Spoony' 20 | __version__ = 'version 0.0.1' 21 | __license__ = 'Copyright (c) 2016 NXEZ.COM' 22 | 23 | import RPi.GPIO as GPIO 24 | from sakspins import SAKSPins as PINS 25 | import entities 26 | 27 | class SAKSHAT(object): 28 | ''' 29 | SAKS HAT class, some useful function are declared. 30 | ''' 31 | buzzer = None 32 | ledrow = None 33 | ds18b20 = None 34 | digital_display = None 35 | dip_switch = None 36 | tactrow = None 37 | 38 | def saks_gpio_init(self): 39 | #print 'saks_gpio_init' 40 | GPIO.setwarnings(False) 41 | GPIO.cleanup() 42 | GPIO.setmode(GPIO.BCM) 43 | 44 | GPIO.setup(PINS.BUZZER, GPIO.OUT) 45 | GPIO.output(PINS.BUZZER, GPIO.HIGH) 46 | 47 | for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: 48 | GPIO.setup(p, GPIO.OUT) 49 | GPIO.output(p, GPIO.LOW) 50 | 51 | for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 52 | GPIO.setup(p, GPIO.OUT) 53 | GPIO.output(p, GPIO.HIGH) 54 | 55 | for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 56 | GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 57 | 58 | def __init__(self): 59 | self.saks_gpio_init() 60 | self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW) 61 | self.ledrow = entities.Led74HC595({'ds': PINS.IC_74HC595_DS, 'shcp': PINS.IC_74HC595_SHCP, 'stcp': PINS.IC_74HC595_STCP}, GPIO.HIGH) 62 | self.ds18b20 = entities.DS18B20(PINS.DS18B20) 63 | self.digital_display = entities.DigitalDisplayTM1637({'di': PINS.IC_TM1637_DI, 'clk': PINS.IC_TM1637_CLK}, GPIO.HIGH) 64 | self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW) 65 | self.dip_switch.register(self) 66 | self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW) 67 | for t in self.tactrow.items: 68 | t.register(self) 69 | 70 | #print('self.dip_switch.register(self)') 71 | 72 | dip_switch_status_changed_handler = None 73 | def on_dip_switch_2bit_status_changed(self, status): 74 | #print('on_dip_switch_2bit_status_changed') 75 | if self.dip_switch_status_changed_handler is not None: 76 | self.dip_switch_status_changed_handler(status) 77 | 78 | tact_event_handler = None 79 | def on_tact_event(self, pin, status): 80 | #print('on_tact_event') 81 | if self.tact_event_handler is not None: 82 | self.tact_event_handler(pin, status) 83 | -------------------------------------------------------------------------------- /04.多任务,原来如此简单/sakspins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | class SAKSPins(object): 20 | ''' 21 | SAKS Pins Code With BCM for Raspberry Pi. 22 | ''' 23 | 24 | IC_74HC595_DS = 6 25 | IC_74HC595_SHCP = 19 26 | IC_74HC595_STCP = 13 27 | 28 | IC_TM1637_DI = 25 29 | IC_TM1637_CLK = 5 30 | 31 | BUZZER = 12 32 | 33 | TACT_RIGHT = 20 34 | TACT_LEFT = 16 35 | DIP_SWITCH_1 = 21 36 | DIP_SWITCH_2 = 26 37 | 38 | IR_SENDER = 17 39 | IR_RECEIVER = 9 40 | DS18B20 = 4 41 | UART_TXD = 14 42 | UART_RXD = 15 43 | I2C_SDA = 2 44 | I2C_SLC = 3 -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__init__.py: -------------------------------------------------------------------------------- 1 | from .buzzer import Buzzer 2 | from .led import Led 3 | from .led import LedRow 4 | from .ds18b20 import DS18B20 5 | from .digital_display import DigitalDisplay 6 | from .dip_switch_2bit import DipSwitch2Bit 7 | from .tact import Tact 8 | from .tact import TactRow 9 | from .ic_74hc595 import IC_74HC595 10 | from .led_74hc595 import Led74HC595 11 | from .ic_tm1637 import IC_TM1637 12 | from .digital_display_tm1637 import DigitalDisplayTM1637 13 | -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/buzzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/buzzer.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/digital_display.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/digital_display.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/digital_display_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/digital_display_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/dip_switch_2bit.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/dip_switch_2bit.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/ds18b20.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/ds18b20.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/ic_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/ic_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/ic_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/ic_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/led.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/led.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/led_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/led_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/tact.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/05.不能再两耳不闻窗外事了!你们需要交流/entities/__pycache__/tact.cpython-37.pyc -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2015 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | import time 21 | 22 | class Buzzer(object): 23 | ''' 24 | Buzzer class 25 | ''' 26 | __pin = 0 27 | __real_true = GPIO.HIGH 28 | __is_on = False 29 | 30 | def __init__(self, pin, real_true = GPIO.HIGH): 31 | ''' 32 | Init the buzzer 33 | :param pin: pin number 34 | :param real_true: GPIO.HIGH or GPIO.LOW 35 | :return: void 36 | ''' 37 | self.__pin = pin 38 | self.__real_true = real_true 39 | 40 | #Stauts. 41 | @property 42 | def is_on(self): 43 | ''' 44 | Return the status of buzzer 45 | :return: void 46 | ''' 47 | return self.__is_on 48 | 49 | #Verbs. 50 | def on(self): 51 | ''' 52 | Set buzzer on 53 | :return: void 54 | ''' 55 | GPIO.output(self.__pin, self.__real_true) 56 | self.__is_on = True 57 | 58 | def off(self): 59 | ''' 60 | Set buzzer off 61 | :return: void 62 | ''' 63 | GPIO.output(self.__pin, not self.__real_true) 64 | self.__is_on = False 65 | 66 | #functions. 67 | def beep(self, seconds): 68 | ''' 69 | Beep one time 70 | :param seconds: beep time 71 | :return: void 72 | ''' 73 | self.on() 74 | time.sleep(seconds) 75 | self.off() 76 | 77 | def beepAction(self, secs, sleepsecs, times): 78 | ''' 79 | Beep in a rhythm 80 | e.g. beepAction(0.02,0.02,30) 81 | :param secs: beep time 82 | :param sleepsecs: break time 83 | :param times: repeat times 84 | :return: void 85 | ''' 86 | for i in range(times): 87 | self.beep(secs) 88 | time.sleep(sleepsecs) 89 | -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/entities/ic_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | 21 | class IC_74HC595(object): 22 | ''' 23 | IC_74HC595 class 24 | ''' 25 | __pins = {'ds':0, 'shcp':0, 'stcp':0} 26 | __real_true = GPIO.HIGH 27 | __data = 0x00 28 | 29 | def __init__(self, pins, real_true = GPIO.HIGH): 30 | ''' 31 | Init the ic 32 | :param pin: pin number 33 | :param real_true: GPIO.HIGH or GPIO.LOW 34 | :return: void 35 | ''' 36 | self.__pins = pins 37 | self.__real_true = real_true 38 | 39 | #Stauts. 40 | @property 41 | def data(self): 42 | ''' 43 | Return the data 44 | :return: void 45 | ''' 46 | return self.__data 47 | 48 | #Verbs. 49 | def flush_shcp(self): 50 | ''' 51 | Flush a shcp 52 | :return: void 53 | ''' 54 | GPIO.output(self.__pins['shcp'], not self.__real_true) 55 | GPIO.output(self.__pins['shcp'], self.__real_true) 56 | 57 | def flush_stcp(self): 58 | ''' 59 | Flush a stcp 60 | :return: void 61 | ''' 62 | GPIO.output(self.__pins['stcp'], not self.__real_true) 63 | GPIO.output(self.__pins['stcp'], self.__real_true) 64 | 65 | def set_bit(self, bit): 66 | ''' 67 | Set a bit 68 | :param bit: bit 69 | :return: void 70 | ''' 71 | GPIO.output(self.__pins['ds'], bit) 72 | self.flush_shcp() 73 | 74 | def set_data(self, data): 75 | ''' 76 | Set a byte 77 | :param data: data 78 | :return: void 79 | ''' 80 | self.__data = data 81 | for i in range (0, 8): 82 | self.set_bit((self.__data >> i) & 0x01) 83 | 84 | self.flush_stcp() 85 | 86 | 87 | def clear(self): 88 | ''' 89 | Clear the data 90 | :return: void 91 | ''' 92 | self.set_data(0x00) 93 | -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/sakshat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | __author__ = 'Spoony' 20 | __version__ = 'version 0.0.1' 21 | __license__ = 'Copyright (c) 2016 NXEZ.COM' 22 | 23 | import RPi.GPIO as GPIO 24 | from sakspins import SAKSPins as PINS 25 | import entities 26 | 27 | class SAKSHAT(object): 28 | ''' 29 | SAKS HAT class, some useful function are declared. 30 | ''' 31 | buzzer = None 32 | ledrow = None 33 | ds18b20 = None 34 | digital_display = None 35 | dip_switch = None 36 | tactrow = None 37 | 38 | def saks_gpio_init(self): 39 | #print 'saks_gpio_init' 40 | GPIO.setwarnings(False) 41 | GPIO.cleanup() 42 | GPIO.setmode(GPIO.BCM) 43 | 44 | GPIO.setup(PINS.BUZZER, GPIO.OUT) 45 | GPIO.output(PINS.BUZZER, GPIO.HIGH) 46 | 47 | for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: 48 | GPIO.setup(p, GPIO.OUT) 49 | GPIO.output(p, GPIO.LOW) 50 | 51 | for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 52 | GPIO.setup(p, GPIO.OUT) 53 | GPIO.output(p, GPIO.HIGH) 54 | 55 | for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 56 | GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 57 | 58 | def __init__(self): 59 | self.saks_gpio_init() 60 | self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW) 61 | self.ledrow = entities.Led74HC595({'ds': PINS.IC_74HC595_DS, 'shcp': PINS.IC_74HC595_SHCP, 'stcp': PINS.IC_74HC595_STCP}, GPIO.HIGH) 62 | self.ds18b20 = entities.DS18B20(PINS.DS18B20) 63 | self.digital_display = entities.DigitalDisplayTM1637({'di': PINS.IC_TM1637_DI, 'clk': PINS.IC_TM1637_CLK}, GPIO.HIGH) 64 | self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW) 65 | self.dip_switch.register(self) 66 | self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW) 67 | for t in self.tactrow.items: 68 | t.register(self) 69 | 70 | #print('self.dip_switch.register(self)') 71 | 72 | dip_switch_status_changed_handler = None 73 | def on_dip_switch_2bit_status_changed(self, status): 74 | #print('on_dip_switch_2bit_status_changed') 75 | if self.dip_switch_status_changed_handler is not None: 76 | self.dip_switch_status_changed_handler(status) 77 | 78 | tact_event_handler = None 79 | def on_tact_event(self, pin, status): 80 | #print('on_tact_event') 81 | if self.tact_event_handler is not None: 82 | self.tact_event_handler(pin, status) 83 | -------------------------------------------------------------------------------- /05.不能再两耳不闻窗外事了!你们需要交流/sakspins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | class SAKSPins(object): 20 | ''' 21 | SAKS Pins Code With BCM for Raspberry Pi. 22 | ''' 23 | 24 | IC_74HC595_DS = 6 25 | IC_74HC595_SHCP = 19 26 | IC_74HC595_STCP = 13 27 | 28 | IC_TM1637_DI = 25 29 | IC_TM1637_CLK = 5 30 | 31 | BUZZER = 12 32 | 33 | TACT_RIGHT = 20 34 | TACT_LEFT = 16 35 | DIP_SWITCH_1 = 21 36 | DIP_SWITCH_2 = 26 37 | 38 | IR_SENDER = 17 39 | IR_RECEIVER = 9 40 | DS18B20 = 4 41 | UART_TXD = 14 42 | UART_RXD = 15 43 | I2C_SDA = 2 44 | I2C_SLC = 3 -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/.ipynb_checkpoints/1.临界资源为何物。锁_你说的是大门锁吗_-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# 临界资源为何物 \n", 10 | "先看看百度百科给出的解释(https://baike.baidu.com/item/%E4%B8%B4%E7%95%8C%E8%B5%84%E6%BA%90/1880269?fr=aladdin):\n", 11 | "\n", 12 | "临界资源:多道程序系统中存在许多进程,它们共享各种资源,然而有很多资源一次只能供一个进程使用。一次仅允许一个进程使用的资源称为临界资源。许多物理设备都属于临界资源,如输入机、打印机、磁带机等。\n", 13 | "\n", 14 | "举个通俗点的例子:一桌人吃饭(中国作为美食大国,拿吃举例是最形象的,我就是的吃货),上了一大碗“海鲜全家福”(最爱里面的扇贝丁和虾仁),只有一个公用勺(要讲餐桌礼仪,只能用公用勺取菜),这个公用勺就是“临界资源”,A拿了公用勺后,B、C、D等诸位只能等着,不然群起而拿之,一个公用勺同时有4只手,这场面不忍直视。\n", 15 | "\n", 16 | "对于公用勺(临界资源)的使用我们要有保护,我们用餐桌礼仪约定(进程间同步的锁)来规范公用勺(临界资源)的使用。\n", 17 | "\n", 18 | "上述够形象吧:)" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": {}, 24 | "source": [ 25 | "# 锁?你说的是大门锁吗\n", 26 | "当然不是了,但起到的作用和大门锁一致——你想进房间,先拿到钥匙,用完房间后,把钥匙归还;在这期间,其他人要用房间,只能等着,拿到钥匙才能继续使用。这里的房间就是“临界资源”。\n", 27 | "\n", 28 | "操作系统为我们提供了哪些“临界资源”的保护机制。\n", 29 | "\n", 30 | "操作系统为我们提供的保护机制就是锁。这个锁包含:互斥锁、读写锁、自旋锁。\n", 31 | "\n", 32 | "(1)互斥锁。同一时刻,只能有1个进程访问临界资源。\n", 33 | "\n", 34 | "(2)读写锁。多了读临界资源的进程可用同时访问,但写临界资源的进程一旦访问,所有使用临界资源的进程都要等待着该进程结束后,才能访问临界资源。\n", 35 | "\n", 36 | "适用场合:预估您的系统中,对该临界资源的读操作次数大于写操作的次数,此时读写锁就可以带来比互斥锁更好的性能。\n", 37 | "\n", 38 | "读写锁存在的原因:读操作不改变临界资源的值,读操作相当与您看看临界资源,看也不会咋样,所有可以由多个进程访问;但写就不一样,一旦写后,临界资源就被改变了,所有写操作由只能一个进程来进行。\n", 39 | "\n", 40 | "(3)自旋锁。只在内核中使用,而且只在有多核处理器的情况使用。\n", 41 | "\n", 42 | "自旋锁,就是一直死等着临界资源,同时占着CPU不放,就在原地跑圈(也不怕自己转晕了:))。\n", 43 | "\n", 44 | "在使用互斥锁、读写锁时,等待锁期间,该进程是被拉入锁的等待队列中的,进程处于睡眠态,其他进程被拉入CPU进行操作;但使用自旋锁时,不释放CPU,就在那空等;\n", 45 | "\n", 46 | "那为什么要引入自旋锁呢? 就是效率问题,如果临界资源很快可使用,此时,获取到了自旋锁使用权限,继续执行后续代码;但使用互斥锁和读写锁则引入进程(或内核线程)频繁的切入、切出CPU的运行队列,耗费了大量时间,降低了系统的性能;这就是自旋锁适用的场合。" 47 | ] 48 | }, 49 | { 50 | "cell_type": "markdown", 51 | "metadata": {}, 52 | "source": [ 53 | "# Multiprocessing模块提供的进程间同步机制\n", 54 | "multiprocessing支持进程同步机制——锁(互斥锁)。同一时刻只有一个进程可以获取锁。" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": 1, 60 | "metadata": {}, 61 | "outputs": [ 62 | { 63 | "name": "stdout", 64 | "output_type": "stream", 65 | "text": [ 66 | "Help on method Lock in multiprocessing:\n", 67 | "\n", 68 | "multiprocessing.Lock = Lock() method of multiprocessing.context.DefaultContext instance\n", 69 | " Returns a non-recursive lock object\n", 70 | "\n" 71 | ] 72 | } 73 | ], 74 | "source": [ 75 | "help(\"multiprocessing.Lock\")" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [] 84 | } 85 | ], 86 | "metadata": { 87 | "kernelspec": { 88 | "display_name": "Python 3", 89 | "language": "python", 90 | "name": "python3" 91 | }, 92 | "language_info": { 93 | "codemirror_mode": { 94 | "name": "ipython", 95 | "version": 3 96 | }, 97 | "file_extension": ".py", 98 | "mimetype": "text/x-python", 99 | "name": "python", 100 | "nbconvert_exporter": "python", 101 | "pygments_lexer": "ipython3", 102 | "version": "3.7.3" 103 | } 104 | }, 105 | "nbformat": 4, 106 | "nbformat_minor": 1 107 | } 108 | -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/1.临界资源为何物。锁_你说的是大门锁吗_.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# 临界资源为何物 \n", 10 | "先看看百度百科给出的解释(https://baike.baidu.com/item/%E4%B8%B4%E7%95%8C%E8%B5%84%E6%BA%90/1880269?fr=aladdin):\n", 11 | "\n", 12 | "临界资源:多道程序系统中存在许多进程,它们共享各种资源,然而有很多资源一次只能供一个进程使用。一次仅允许一个进程使用的资源称为临界资源。许多物理设备都属于临界资源,如输入机、打印机、磁带机等。\n", 13 | "\n", 14 | "举个通俗点的例子:一桌人吃饭(中国作为美食大国,拿吃举例是最形象的,我就是的吃货),上了一大碗“海鲜全家福”(最爱里面的扇贝丁和虾仁),只有一个公用勺(要讲餐桌礼仪,只能用公用勺取菜),这个公用勺就是“临界资源”,A拿了公用勺后,B、C、D等诸位只能等着,不然群起而拿之,一个公用勺同时有4只手,这场面不忍直视。\n", 15 | "\n", 16 | "对于公用勺(临界资源)的使用我们要有保护,我们用餐桌礼仪约定(进程间同步的锁)来规范公用勺(临界资源)的使用。\n", 17 | "\n", 18 | "上述够形象吧:)" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": {}, 24 | "source": [ 25 | "# 锁?你说的是大门锁吗\n", 26 | "当然不是了,但起到的作用和大门锁一致——你想进房间,先拿到钥匙,用完房间后,把钥匙归还;在这期间,其他人要用房间,只能等着,拿到钥匙才能继续使用。这里的房间就是“临界资源”。\n", 27 | "\n", 28 | "操作系统为我们提供了哪些“临界资源”的保护机制。\n", 29 | "\n", 30 | "操作系统为我们提供的保护机制就是锁。这个锁包含:互斥锁、读写锁、自旋锁。\n", 31 | "\n", 32 | "(1)互斥锁。同一时刻,只能有1个进程访问临界资源。\n", 33 | "\n", 34 | "(2)读写锁。多了读临界资源的进程可用同时访问,但写临界资源的进程一旦访问,所有使用临界资源的进程都要等待着该进程结束后,才能访问临界资源。\n", 35 | "\n", 36 | "适用场合:预估您的系统中,对该临界资源的读操作次数大于写操作的次数,此时读写锁就可以带来比互斥锁更好的性能。\n", 37 | "\n", 38 | "读写锁存在的原因:读操作不改变临界资源的值,读操作相当与您看看临界资源,看也不会咋样,所有可以由多个进程访问;但写就不一样,一旦写后,临界资源就被改变了,所有写操作由只能一个进程来进行。\n", 39 | "\n", 40 | "(3)自旋锁。只在内核中使用,而且只在有多核处理器的情况使用。\n", 41 | "\n", 42 | "自旋锁,就是一直死等着临界资源,同时占着CPU不放,就在原地跑圈(也不怕自己转晕了:))。\n", 43 | "\n", 44 | "在使用互斥锁、读写锁时,等待锁期间,该进程是被拉入锁的等待队列中的,进程处于睡眠态,其他进程被拉入CPU进行操作;但使用自旋锁时,不释放CPU,就在那空等;\n", 45 | "\n", 46 | "那为什么要引入自旋锁呢? 就是效率问题,如果临界资源很快可使用,此时,获取到了自旋锁使用权限,继续执行后续代码;但使用互斥锁和读写锁则引入进程(或内核线程)频繁的切入、切出CPU的运行队列,耗费了大量时间,降低了系统的性能;这就是自旋锁适用的场合。" 47 | ] 48 | }, 49 | { 50 | "cell_type": "markdown", 51 | "metadata": {}, 52 | "source": [ 53 | "# Multiprocessing模块提供的进程间同步机制\n", 54 | "multiprocessing支持进程同步机制——锁(互斥锁)。同一时刻只有一个进程可以获取锁。" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": 1, 60 | "metadata": {}, 61 | "outputs": [ 62 | { 63 | "name": "stdout", 64 | "output_type": "stream", 65 | "text": [ 66 | "Help on method Lock in multiprocessing:\n", 67 | "\n", 68 | "multiprocessing.Lock = Lock() method of multiprocessing.context.DefaultContext instance\n", 69 | " Returns a non-recursive lock object\n", 70 | "\n" 71 | ] 72 | } 73 | ], 74 | "source": [ 75 | "help(\"multiprocessing.Lock\")" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [] 84 | } 85 | ], 86 | "metadata": { 87 | "kernelspec": { 88 | "display_name": "Python 3", 89 | "language": "python", 90 | "name": "python3" 91 | }, 92 | "language_info": { 93 | "codemirror_mode": { 94 | "name": "ipython", 95 | "version": 3 96 | }, 97 | "file_extension": ".py", 98 | "mimetype": "text/x-python", 99 | "name": "python", 100 | "nbconvert_exporter": "python", 101 | "pygments_lexer": "ipython3", 102 | "version": "3.7.3" 103 | } 104 | }, 105 | "nbformat": 4, 106 | "nbformat_minor": 1 107 | } 108 | -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__init__.py: -------------------------------------------------------------------------------- 1 | from .buzzer import Buzzer 2 | from .led import Led 3 | from .led import LedRow 4 | from .ds18b20 import DS18B20 5 | from .digital_display import DigitalDisplay 6 | from .dip_switch_2bit import DipSwitch2Bit 7 | from .tact import Tact 8 | from .tact import TactRow 9 | from .ic_74hc595 import IC_74HC595 10 | from .led_74hc595 import Led74HC595 11 | from .ic_tm1637 import IC_TM1637 12 | from .digital_display_tm1637 import DigitalDisplayTM1637 13 | -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/buzzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/buzzer.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/digital_display.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/digital_display.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/digital_display_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/digital_display_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/dip_switch_2bit.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/dip_switch_2bit.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/ds18b20.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/ds18b20.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/ic_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/ic_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/ic_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/ic_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/led.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/led.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/led_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/led_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/__pycache__/tact.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/06.停下来,别争了,咱们定个规矩/entities/__pycache__/tact.cpython-37.pyc -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2015 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | import time 21 | 22 | class Buzzer(object): 23 | ''' 24 | Buzzer class 25 | ''' 26 | __pin = 0 27 | __real_true = GPIO.HIGH 28 | __is_on = False 29 | 30 | def __init__(self, pin, real_true = GPIO.HIGH): 31 | ''' 32 | Init the buzzer 33 | :param pin: pin number 34 | :param real_true: GPIO.HIGH or GPIO.LOW 35 | :return: void 36 | ''' 37 | self.__pin = pin 38 | self.__real_true = real_true 39 | 40 | #Stauts. 41 | @property 42 | def is_on(self): 43 | ''' 44 | Return the status of buzzer 45 | :return: void 46 | ''' 47 | return self.__is_on 48 | 49 | #Verbs. 50 | def on(self): 51 | ''' 52 | Set buzzer on 53 | :return: void 54 | ''' 55 | GPIO.output(self.__pin, self.__real_true) 56 | self.__is_on = True 57 | 58 | def off(self): 59 | ''' 60 | Set buzzer off 61 | :return: void 62 | ''' 63 | GPIO.output(self.__pin, not self.__real_true) 64 | self.__is_on = False 65 | 66 | #functions. 67 | def beep(self, seconds): 68 | ''' 69 | Beep one time 70 | :param seconds: beep time 71 | :return: void 72 | ''' 73 | self.on() 74 | time.sleep(seconds) 75 | self.off() 76 | 77 | def beepAction(self, secs, sleepsecs, times): 78 | ''' 79 | Beep in a rhythm 80 | e.g. beepAction(0.02,0.02,30) 81 | :param secs: beep time 82 | :param sleepsecs: break time 83 | :param times: repeat times 84 | :return: void 85 | ''' 86 | for i in range(times): 87 | self.beep(secs) 88 | time.sleep(sleepsecs) 89 | -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/entities/ic_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | 21 | class IC_74HC595(object): 22 | ''' 23 | IC_74HC595 class 24 | ''' 25 | __pins = {'ds':0, 'shcp':0, 'stcp':0} 26 | __real_true = GPIO.HIGH 27 | __data = 0x00 28 | 29 | def __init__(self, pins, real_true = GPIO.HIGH): 30 | ''' 31 | Init the ic 32 | :param pin: pin number 33 | :param real_true: GPIO.HIGH or GPIO.LOW 34 | :return: void 35 | ''' 36 | self.__pins = pins 37 | self.__real_true = real_true 38 | 39 | #Stauts. 40 | @property 41 | def data(self): 42 | ''' 43 | Return the data 44 | :return: void 45 | ''' 46 | return self.__data 47 | 48 | #Verbs. 49 | def flush_shcp(self): 50 | ''' 51 | Flush a shcp 52 | :return: void 53 | ''' 54 | GPIO.output(self.__pins['shcp'], not self.__real_true) 55 | GPIO.output(self.__pins['shcp'], self.__real_true) 56 | 57 | def flush_stcp(self): 58 | ''' 59 | Flush a stcp 60 | :return: void 61 | ''' 62 | GPIO.output(self.__pins['stcp'], not self.__real_true) 63 | GPIO.output(self.__pins['stcp'], self.__real_true) 64 | 65 | def set_bit(self, bit): 66 | ''' 67 | Set a bit 68 | :param bit: bit 69 | :return: void 70 | ''' 71 | GPIO.output(self.__pins['ds'], bit) 72 | self.flush_shcp() 73 | 74 | def set_data(self, data): 75 | ''' 76 | Set a byte 77 | :param data: data 78 | :return: void 79 | ''' 80 | self.__data = data 81 | for i in range (0, 8): 82 | self.set_bit((self.__data >> i) & 0x01) 83 | 84 | self.flush_stcp() 85 | 86 | 87 | def clear(self): 88 | ''' 89 | Clear the data 90 | :return: void 91 | ''' 92 | self.set_data(0x00) 93 | -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/sakshat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | __author__ = 'Spoony' 20 | __version__ = 'version 0.0.1' 21 | __license__ = 'Copyright (c) 2016 NXEZ.COM' 22 | 23 | import RPi.GPIO as GPIO 24 | from sakspins import SAKSPins as PINS 25 | import entities 26 | 27 | class SAKSHAT(object): 28 | ''' 29 | SAKS HAT class, some useful function are declared. 30 | ''' 31 | buzzer = None 32 | ledrow = None 33 | ds18b20 = None 34 | digital_display = None 35 | dip_switch = None 36 | tactrow = None 37 | 38 | def saks_gpio_init(self): 39 | #print 'saks_gpio_init' 40 | GPIO.setwarnings(False) 41 | GPIO.cleanup() 42 | GPIO.setmode(GPIO.BCM) 43 | 44 | GPIO.setup(PINS.BUZZER, GPIO.OUT) 45 | GPIO.output(PINS.BUZZER, GPIO.HIGH) 46 | 47 | for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: 48 | GPIO.setup(p, GPIO.OUT) 49 | GPIO.output(p, GPIO.LOW) 50 | 51 | for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 52 | GPIO.setup(p, GPIO.OUT) 53 | GPIO.output(p, GPIO.HIGH) 54 | 55 | for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 56 | GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 57 | 58 | def __init__(self): 59 | self.saks_gpio_init() 60 | self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW) 61 | self.ledrow = entities.Led74HC595({'ds': PINS.IC_74HC595_DS, 'shcp': PINS.IC_74HC595_SHCP, 'stcp': PINS.IC_74HC595_STCP}, GPIO.HIGH) 62 | self.ds18b20 = entities.DS18B20(PINS.DS18B20) 63 | self.digital_display = entities.DigitalDisplayTM1637({'di': PINS.IC_TM1637_DI, 'clk': PINS.IC_TM1637_CLK}, GPIO.HIGH) 64 | self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW) 65 | self.dip_switch.register(self) 66 | self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW) 67 | for t in self.tactrow.items: 68 | t.register(self) 69 | 70 | #print('self.dip_switch.register(self)') 71 | 72 | dip_switch_status_changed_handler = None 73 | def on_dip_switch_2bit_status_changed(self, status): 74 | #print('on_dip_switch_2bit_status_changed') 75 | if self.dip_switch_status_changed_handler is not None: 76 | self.dip_switch_status_changed_handler(status) 77 | 78 | tact_event_handler = None 79 | def on_tact_event(self, pin, status): 80 | #print('on_tact_event') 81 | if self.tact_event_handler is not None: 82 | self.tact_event_handler(pin, status) 83 | -------------------------------------------------------------------------------- /06.停下来,别争了,咱们定个规矩/sakspins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | class SAKSPins(object): 20 | ''' 21 | SAKS Pins Code With BCM for Raspberry Pi. 22 | ''' 23 | 24 | IC_74HC595_DS = 6 25 | IC_74HC595_SHCP = 19 26 | IC_74HC595_STCP = 13 27 | 28 | IC_TM1637_DI = 25 29 | IC_TM1637_CLK = 5 30 | 31 | BUZZER = 12 32 | 33 | TACT_RIGHT = 20 34 | TACT_LEFT = 16 35 | DIP_SWITCH_1 = 21 36 | DIP_SWITCH_2 = 26 37 | 38 | IR_SENDER = 17 39 | IR_RECEIVER = 9 40 | DS18B20 = 4 41 | UART_TXD = 14 42 | UART_RXD = 15 43 | I2C_SDA = 2 44 | I2C_SLC = 3 -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/__pycache__/sakshat.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/__pycache__/sakshat.cpython-35.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__init__.py: -------------------------------------------------------------------------------- 1 | from .buzzer import Buzzer 2 | from .led import Led 3 | from .led import LedRow 4 | from .ds18b20 import DS18B20 5 | from .digital_display import DigitalDisplay 6 | from .dip_switch_2bit import DipSwitch2Bit 7 | from .tact import Tact 8 | from .tact import TactRow 9 | from .ic_74hc595 import IC_74HC595 10 | from .led_74hc595 import Led74HC595 11 | from .ic_tm1637 import IC_TM1637 12 | from .digital_display_tm1637 import DigitalDisplayTM1637 13 | -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/buzzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/buzzer.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/digital_display.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/digital_display.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/digital_display_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/digital_display_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/dip_switch_2bit.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/dip_switch_2bit.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/ds18b20.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/ds18b20.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/ic_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/ic_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/ic_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/ic_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/led.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/led.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/led_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/led_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/__pycache__/tact.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/07.LED灯原来是这样点亮的/entities/__pycache__/tact.cpython-37.pyc -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2015 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | import time 21 | 22 | class Buzzer(object): 23 | ''' 24 | Buzzer class 25 | ''' 26 | __pin = 0 27 | __real_true = GPIO.HIGH 28 | __is_on = False 29 | 30 | def __init__(self, pin, real_true = GPIO.HIGH): 31 | ''' 32 | Init the buzzer 33 | :param pin: pin number 34 | :param real_true: GPIO.HIGH or GPIO.LOW 35 | :return: void 36 | ''' 37 | self.__pin = pin 38 | self.__real_true = real_true 39 | 40 | #Stauts. 41 | @property 42 | def is_on(self): 43 | ''' 44 | Return the status of buzzer 45 | :return: void 46 | ''' 47 | return self.__is_on 48 | 49 | #Verbs. 50 | def on(self): 51 | ''' 52 | Set buzzer on 53 | :return: void 54 | ''' 55 | GPIO.output(self.__pin, self.__real_true) 56 | self.__is_on = True 57 | 58 | def off(self): 59 | ''' 60 | Set buzzer off 61 | :return: void 62 | ''' 63 | GPIO.output(self.__pin, not self.__real_true) 64 | self.__is_on = False 65 | 66 | #functions. 67 | def beep(self, seconds): 68 | ''' 69 | Beep one time 70 | :param seconds: beep time 71 | :return: void 72 | ''' 73 | self.on() 74 | time.sleep(seconds) 75 | self.off() 76 | 77 | def beepAction(self, secs, sleepsecs, times): 78 | ''' 79 | Beep in a rhythm 80 | e.g. beepAction(0.02,0.02,30) 81 | :param secs: beep time 82 | :param sleepsecs: break time 83 | :param times: repeat times 84 | :return: void 85 | ''' 86 | for i in range(times): 87 | self.beep(secs) 88 | time.sleep(sleepsecs) 89 | -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/ic_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | 21 | class IC_74HC595(object): 22 | ''' 23 | IC_74HC595 class 24 | ''' 25 | __pins = {'ds':0, 'shcp':0, 'stcp':0} 26 | __real_true = GPIO.HIGH 27 | __data = 0x00 28 | 29 | def __init__(self, pins, real_true = GPIO.HIGH): 30 | ''' 31 | Init the ic 32 | :param pin: pin number 33 | :param real_true: GPIO.HIGH or GPIO.LOW 34 | :return: void 35 | ''' 36 | self.__pins = pins 37 | self.__real_true = real_true 38 | 39 | #Stauts. 40 | @property 41 | def data(self): 42 | ''' 43 | Return the data 44 | :return: void 45 | ''' 46 | return self.__data 47 | 48 | #Verbs. 49 | def flush_shcp(self): 50 | ''' 51 | Flush a shcp 52 | :return: void 53 | ''' 54 | GPIO.output(self.__pins['shcp'], not self.__real_true) 55 | GPIO.output(self.__pins['shcp'], self.__real_true) 56 | 57 | def flush_stcp(self): 58 | ''' 59 | Flush a stcp 60 | :return: void 61 | ''' 62 | GPIO.output(self.__pins['stcp'], not self.__real_true) 63 | GPIO.output(self.__pins['stcp'], self.__real_true) 64 | 65 | def set_bit(self, bit): 66 | ''' 67 | Set a bit 68 | :param bit: bit 69 | :return: void 70 | ''' 71 | GPIO.output(self.__pins['ds'], bit) 72 | self.flush_shcp() 73 | 74 | def set_data(self, data): 75 | ''' 76 | Set a byte 77 | :param data: data 78 | :return: void 79 | ''' 80 | self.__data = data 81 | for i in range (0, 8): 82 | self.set_bit((self.__data >> i) & 0x01) 83 | 84 | self.flush_stcp() 85 | 86 | 87 | def clear(self): 88 | ''' 89 | Clear the data 90 | :return: void 91 | ''' 92 | self.set_data(0x00) 93 | -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/entities/led_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | from .ic_74hc595 import IC_74HC595 as IC_74HC595 21 | 22 | class Led74HC595(object): 23 | ''' 24 | Class of leds in 74HC595 25 | ''' 26 | __ic_74hc595 = None 27 | 28 | def __init__(self, pins, real_true = GPIO.HIGH): 29 | ''' 30 | Init the leds 31 | :param pin: pin numbers in array 32 | :param real_true: GPIO.HIGH or GPIO.LOW 33 | :return: void 34 | ''' 35 | self.__ic_74hc595 = IC_74HC595(pins, real_true) 36 | 37 | #Stauts. 38 | @property 39 | def ic(self): 40 | return self.__ic_74hc595 41 | 42 | def is_on(self, index): 43 | ''' 44 | Get status of led in ledrow by index 45 | :param index: index of the led 46 | :return: status in boolean 47 | ''' 48 | if index >= 8: 49 | return False 50 | return self.__ic_74hc595.data >> index & 0x01 51 | 52 | @property 53 | def row_status(self): 54 | ''' 55 | Get status array of the ledrow 56 | :return: status array 57 | ''' 58 | r = [] 59 | for i in range (0, 8): 60 | r.append(self.__ic_74hc595.data >> i & 0x01) 61 | return r 62 | 63 | #Verbs. 64 | def on(self): 65 | ''' 66 | Set all the leds on 67 | :return: void 68 | ''' 69 | self.__ic_74hc595.set_data(0xff) 70 | 71 | def off(self): 72 | ''' 73 | Set all the leds off 74 | :return: void 75 | ''' 76 | self.__ic_74hc595.clear() 77 | 78 | def on_for_index(self, index): 79 | ''' 80 | Set the led on by index in the ledrow 81 | :return: void 82 | ''' 83 | self.__ic_74hc595.set_data(self.__ic_74hc595.data | (0x01 << (index))) 84 | 85 | def off_for_index(self, index): 86 | ''' 87 | Set the led off by index in the ledrow 88 | :return: void 89 | ''' 90 | arr = [0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f] 91 | self.__ic_74hc595.set_data(self.__ic_74hc595.data & arr[index]) 92 | 93 | def set_row(self, status): 94 | ''' 95 | Set the ledrow's status in boolean array 96 | :param status: boolean array 97 | :return: void 98 | ''' 99 | for i in range(len(status)): 100 | #print(str(i) + str(status[i])) 101 | if status[i] is None: 102 | continue 103 | if status[i]: 104 | self.on_for_index(i) 105 | else: 106 | self.off_for_index(i) 107 | -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/sakshat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | __author__ = 'Spoony' 20 | __version__ = 'version 0.0.1' 21 | __license__ = 'Copyright (c) 2016 NXEZ.COM' 22 | 23 | import RPi.GPIO as GPIO 24 | from sakspins import SAKSPins as PINS 25 | import entities 26 | 27 | class SAKSHAT(object): 28 | ''' 29 | SAKS HAT class, some useful function are declared. 30 | ''' 31 | buzzer = None 32 | ledrow = None 33 | ds18b20 = None 34 | digital_display = None 35 | dip_switch = None 36 | tactrow = None 37 | 38 | def saks_gpio_init(self): 39 | #print 'saks_gpio_init' 40 | GPIO.setwarnings(False) 41 | GPIO.cleanup() 42 | GPIO.setmode(GPIO.BCM) 43 | 44 | GPIO.setup(PINS.BUZZER, GPIO.OUT) 45 | GPIO.output(PINS.BUZZER, GPIO.HIGH) 46 | 47 | for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: 48 | GPIO.setup(p, GPIO.OUT) 49 | GPIO.output(p, GPIO.LOW) 50 | 51 | for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 52 | GPIO.setup(p, GPIO.OUT) 53 | GPIO.output(p, GPIO.HIGH) 54 | 55 | for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 56 | GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 57 | 58 | def __init__(self): 59 | self.saks_gpio_init() 60 | self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW) 61 | self.ledrow = entities.Led74HC595({'ds': PINS.IC_74HC595_DS, 'shcp': PINS.IC_74HC595_SHCP, 'stcp': PINS.IC_74HC595_STCP}, GPIO.HIGH) 62 | self.ds18b20 = entities.DS18B20(PINS.DS18B20) 63 | self.digital_display = entities.DigitalDisplayTM1637({'di': PINS.IC_TM1637_DI, 'clk': PINS.IC_TM1637_CLK}, GPIO.HIGH) 64 | self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW) 65 | self.dip_switch.register(self) 66 | self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW) 67 | for t in self.tactrow.items: 68 | t.register(self) 69 | 70 | #print('self.dip_switch.register(self)') 71 | 72 | dip_switch_status_changed_handler = None 73 | def on_dip_switch_2bit_status_changed(self, status): 74 | #print('on_dip_switch_2bit_status_changed') 75 | if self.dip_switch_status_changed_handler is not None: 76 | self.dip_switch_status_changed_handler(status) 77 | 78 | tact_event_handler = None 79 | def on_tact_event(self, pin, status): 80 | #print('on_tact_event') 81 | if self.tact_event_handler is not None: 82 | self.tact_event_handler(pin, status) 83 | -------------------------------------------------------------------------------- /07.LED灯原来是这样点亮的/sakspins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | class SAKSPins(object): 20 | ''' 21 | SAKS Pins Code With BCM for Raspberry Pi. 22 | ''' 23 | 24 | IC_74HC595_DS = 6 25 | IC_74HC595_SHCP = 19 26 | IC_74HC595_STCP = 13 27 | 28 | IC_TM1637_DI = 25 29 | IC_TM1637_CLK = 5 30 | 31 | BUZZER = 12 32 | 33 | TACT_RIGHT = 20 34 | TACT_LEFT = 16 35 | DIP_SWITCH_1 = 21 36 | DIP_SWITCH_2 = 26 37 | 38 | IR_SENDER = 17 39 | IR_RECEIVER = 9 40 | DS18B20 = 4 41 | UART_TXD = 14 42 | UART_RXD = 15 43 | I2C_SDA = 2 44 | I2C_SLC = 3 -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__init__.py: -------------------------------------------------------------------------------- 1 | from .buzzer import Buzzer 2 | from .led import Led 3 | from .led import LedRow 4 | from .ds18b20 import DS18B20 5 | from .digital_display import DigitalDisplay 6 | from .dip_switch_2bit import DipSwitch2Bit 7 | from .tact import Tact 8 | from .tact import TactRow 9 | from .ic_74hc595 import IC_74HC595 10 | from .led_74hc595 import Led74HC595 11 | from .ic_tm1637 import IC_TM1637 12 | from .digital_display_tm1637 import DigitalDisplayTM1637 13 | -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/buzzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/buzzer.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/digital_display.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/digital_display.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/digital_display_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/digital_display_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/dip_switch_2bit.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/dip_switch_2bit.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/ds18b20.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/ds18b20.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/ic_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/ic_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/ic_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/ic_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/led.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/led.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/led_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/led_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/__pycache__/tact.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/08.你牙牙学语的声音真好听/entities/__pycache__/tact.cpython-37.pyc -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2015 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | import time 21 | 22 | class Buzzer(object): 23 | ''' 24 | Buzzer class 25 | ''' 26 | __pin = 0 27 | __real_true = GPIO.HIGH 28 | __is_on = False 29 | 30 | def __init__(self, pin, real_true = GPIO.HIGH): 31 | ''' 32 | Init the buzzer 33 | :param pin: pin number 34 | :param real_true: GPIO.HIGH or GPIO.LOW 35 | :return: void 36 | ''' 37 | self.__pin = pin 38 | self.__real_true = real_true 39 | 40 | #Stauts. 41 | @property 42 | def is_on(self): 43 | ''' 44 | Return the status of buzzer 45 | :return: void 46 | ''' 47 | return self.__is_on 48 | 49 | #Verbs. 50 | def on(self): 51 | ''' 52 | Set buzzer on 53 | :return: void 54 | ''' 55 | GPIO.output(self.__pin, self.__real_true) 56 | self.__is_on = True 57 | 58 | def off(self): 59 | ''' 60 | Set buzzer off 61 | :return: void 62 | ''' 63 | GPIO.output(self.__pin, not self.__real_true) 64 | self.__is_on = False 65 | 66 | #functions. 67 | def beep(self, seconds): 68 | ''' 69 | Beep one time 70 | :param seconds: beep time 71 | :return: void 72 | ''' 73 | self.on() 74 | time.sleep(seconds) 75 | self.off() 76 | 77 | def beepAction(self, secs, sleepsecs, times): 78 | ''' 79 | Beep in a rhythm 80 | e.g. beepAction(0.02,0.02,30) 81 | :param secs: beep time 82 | :param sleepsecs: break time 83 | :param times: repeat times 84 | :return: void 85 | ''' 86 | for i in range(times): 87 | self.beep(secs) 88 | time.sleep(sleepsecs) 89 | -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/entities/ic_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | 21 | class IC_74HC595(object): 22 | ''' 23 | IC_74HC595 class 24 | ''' 25 | __pins = {'ds':0, 'shcp':0, 'stcp':0} 26 | __real_true = GPIO.HIGH 27 | __data = 0x00 28 | 29 | def __init__(self, pins, real_true = GPIO.HIGH): 30 | ''' 31 | Init the ic 32 | :param pin: pin number 33 | :param real_true: GPIO.HIGH or GPIO.LOW 34 | :return: void 35 | ''' 36 | self.__pins = pins 37 | self.__real_true = real_true 38 | 39 | #Stauts. 40 | @property 41 | def data(self): 42 | ''' 43 | Return the data 44 | :return: void 45 | ''' 46 | return self.__data 47 | 48 | #Verbs. 49 | def flush_shcp(self): 50 | ''' 51 | Flush a shcp 52 | :return: void 53 | ''' 54 | GPIO.output(self.__pins['shcp'], not self.__real_true) 55 | GPIO.output(self.__pins['shcp'], self.__real_true) 56 | 57 | def flush_stcp(self): 58 | ''' 59 | Flush a stcp 60 | :return: void 61 | ''' 62 | GPIO.output(self.__pins['stcp'], not self.__real_true) 63 | GPIO.output(self.__pins['stcp'], self.__real_true) 64 | 65 | def set_bit(self, bit): 66 | ''' 67 | Set a bit 68 | :param bit: bit 69 | :return: void 70 | ''' 71 | GPIO.output(self.__pins['ds'], bit) 72 | self.flush_shcp() 73 | 74 | def set_data(self, data): 75 | ''' 76 | Set a byte 77 | :param data: data 78 | :return: void 79 | ''' 80 | self.__data = data 81 | for i in range (0, 8): 82 | self.set_bit((self.__data >> i) & 0x01) 83 | 84 | self.flush_stcp() 85 | 86 | 87 | def clear(self): 88 | ''' 89 | Clear the data 90 | :return: void 91 | ''' 92 | self.set_data(0x00) 93 | -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/sakshat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | __author__ = 'Spoony' 20 | __version__ = 'version 0.0.1' 21 | __license__ = 'Copyright (c) 2016 NXEZ.COM' 22 | 23 | import RPi.GPIO as GPIO 24 | from sakspins import SAKSPins as PINS 25 | import entities 26 | 27 | class SAKSHAT(object): 28 | ''' 29 | SAKS HAT class, some useful function are declared. 30 | ''' 31 | buzzer = None 32 | ledrow = None 33 | ds18b20 = None 34 | digital_display = None 35 | dip_switch = None 36 | tactrow = None 37 | 38 | def saks_gpio_init(self): 39 | #print 'saks_gpio_init' 40 | GPIO.setwarnings(False) 41 | GPIO.cleanup() 42 | GPIO.setmode(GPIO.BCM) 43 | 44 | GPIO.setup(PINS.BUZZER, GPIO.OUT) 45 | GPIO.output(PINS.BUZZER, GPIO.HIGH) 46 | 47 | for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: 48 | GPIO.setup(p, GPIO.OUT) 49 | GPIO.output(p, GPIO.LOW) 50 | 51 | for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 52 | GPIO.setup(p, GPIO.OUT) 53 | GPIO.output(p, GPIO.HIGH) 54 | 55 | for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 56 | GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 57 | 58 | def __init__(self): 59 | self.saks_gpio_init() 60 | self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW) 61 | self.ledrow = entities.Led74HC595({'ds': PINS.IC_74HC595_DS, 'shcp': PINS.IC_74HC595_SHCP, 'stcp': PINS.IC_74HC595_STCP}, GPIO.HIGH) 62 | self.ds18b20 = entities.DS18B20(PINS.DS18B20) 63 | self.digital_display = entities.DigitalDisplayTM1637({'di': PINS.IC_TM1637_DI, 'clk': PINS.IC_TM1637_CLK}, GPIO.HIGH) 64 | self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW) 65 | self.dip_switch.register(self) 66 | self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW) 67 | for t in self.tactrow.items: 68 | t.register(self) 69 | 70 | #print('self.dip_switch.register(self)') 71 | 72 | dip_switch_status_changed_handler = None 73 | def on_dip_switch_2bit_status_changed(self, status): 74 | #print('on_dip_switch_2bit_status_changed') 75 | if self.dip_switch_status_changed_handler is not None: 76 | self.dip_switch_status_changed_handler(status) 77 | 78 | tact_event_handler = None 79 | def on_tact_event(self, pin, status): 80 | #print('on_tact_event') 81 | if self.tact_event_handler is not None: 82 | self.tact_event_handler(pin, status) 83 | -------------------------------------------------------------------------------- /08.你牙牙学语的声音真好听/sakspins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | class SAKSPins(object): 20 | ''' 21 | SAKS Pins Code With BCM for Raspberry Pi. 22 | ''' 23 | 24 | IC_74HC595_DS = 6 25 | IC_74HC595_SHCP = 19 26 | IC_74HC595_STCP = 13 27 | 28 | IC_TM1637_DI = 25 29 | IC_TM1637_CLK = 5 30 | 31 | BUZZER = 12 32 | 33 | TACT_RIGHT = 20 34 | TACT_LEFT = 16 35 | DIP_SWITCH_1 = 21 36 | DIP_SWITCH_2 = 26 37 | 38 | IR_SENDER = 17 39 | IR_RECEIVER = 9 40 | DS18B20 = 4 41 | UART_TXD = 14 42 | UART_RXD = 15 43 | I2C_SDA = 2 44 | I2C_SLC = 3 -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/.ipynb_checkpoints/未命名-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 2 6 | } 7 | -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__init__.py: -------------------------------------------------------------------------------- 1 | from .buzzer import Buzzer 2 | from .led import Led 3 | from .led import LedRow 4 | from .ds18b20 import DS18B20 5 | from .digital_display import DigitalDisplay 6 | from .dip_switch_2bit import DipSwitch2Bit 7 | from .tact import Tact 8 | from .tact import TactRow 9 | from .ic_74hc595 import IC_74HC595 10 | from .led_74hc595 import Led74HC595 11 | from .ic_tm1637 import IC_TM1637 12 | from .digital_display_tm1637 import DigitalDisplayTM1637 13 | -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/buzzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/buzzer.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/digital_display.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/digital_display.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/digital_display_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/digital_display_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/dip_switch_2bit.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/dip_switch_2bit.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/ds18b20.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/ds18b20.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/ic_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/ic_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/ic_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/ic_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/led.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/led.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/led_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/led_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/__pycache__/tact.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/09.小小按键在我手,我的触碰你知道/entities/__pycache__/tact.cpython-37.pyc -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2015 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | import time 21 | 22 | class Buzzer(object): 23 | ''' 24 | Buzzer class 25 | ''' 26 | __pin = 0 27 | __real_true = GPIO.HIGH 28 | __is_on = False 29 | 30 | def __init__(self, pin, real_true = GPIO.HIGH): 31 | ''' 32 | Init the buzzer 33 | :param pin: pin number 34 | :param real_true: GPIO.HIGH or GPIO.LOW 35 | :return: void 36 | ''' 37 | self.__pin = pin 38 | self.__real_true = real_true 39 | 40 | #Stauts. 41 | @property 42 | def is_on(self): 43 | ''' 44 | Return the status of buzzer 45 | :return: void 46 | ''' 47 | return self.__is_on 48 | 49 | #Verbs. 50 | def on(self): 51 | ''' 52 | Set buzzer on 53 | :return: void 54 | ''' 55 | GPIO.output(self.__pin, self.__real_true) 56 | self.__is_on = True 57 | 58 | def off(self): 59 | ''' 60 | Set buzzer off 61 | :return: void 62 | ''' 63 | GPIO.output(self.__pin, not self.__real_true) 64 | self.__is_on = False 65 | 66 | #functions. 67 | def beep(self, seconds): 68 | ''' 69 | Beep one time 70 | :param seconds: beep time 71 | :return: void 72 | ''' 73 | self.on() 74 | time.sleep(seconds) 75 | self.off() 76 | 77 | def beepAction(self, secs, sleepsecs, times): 78 | ''' 79 | Beep in a rhythm 80 | e.g. beepAction(0.02,0.02,30) 81 | :param secs: beep time 82 | :param sleepsecs: break time 83 | :param times: repeat times 84 | :return: void 85 | ''' 86 | for i in range(times): 87 | self.beep(secs) 88 | time.sleep(sleepsecs) 89 | -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/ic_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | 21 | class IC_74HC595(object): 22 | ''' 23 | IC_74HC595 class 24 | ''' 25 | __pins = {'ds':0, 'shcp':0, 'stcp':0} 26 | __real_true = GPIO.HIGH 27 | __data = 0x00 28 | 29 | def __init__(self, pins, real_true = GPIO.HIGH): 30 | ''' 31 | Init the ic 32 | :param pin: pin number 33 | :param real_true: GPIO.HIGH or GPIO.LOW 34 | :return: void 35 | ''' 36 | self.__pins = pins 37 | self.__real_true = real_true 38 | 39 | #Stauts. 40 | @property 41 | def data(self): 42 | ''' 43 | Return the data 44 | :return: void 45 | ''' 46 | return self.__data 47 | 48 | #Verbs. 49 | def flush_shcp(self): 50 | ''' 51 | Flush a shcp 52 | :return: void 53 | ''' 54 | GPIO.output(self.__pins['shcp'], not self.__real_true) 55 | GPIO.output(self.__pins['shcp'], self.__real_true) 56 | 57 | def flush_stcp(self): 58 | ''' 59 | Flush a stcp 60 | :return: void 61 | ''' 62 | GPIO.output(self.__pins['stcp'], not self.__real_true) 63 | GPIO.output(self.__pins['stcp'], self.__real_true) 64 | 65 | def set_bit(self, bit): 66 | ''' 67 | Set a bit 68 | :param bit: bit 69 | :return: void 70 | ''' 71 | GPIO.output(self.__pins['ds'], bit) 72 | self.flush_shcp() 73 | 74 | def set_data(self, data): 75 | ''' 76 | Set a byte 77 | :param data: data 78 | :return: void 79 | ''' 80 | self.__data = data 81 | for i in range (0, 8): 82 | self.set_bit((self.__data >> i) & 0x01) 83 | 84 | self.flush_stcp() 85 | 86 | 87 | def clear(self): 88 | ''' 89 | Clear the data 90 | :return: void 91 | ''' 92 | self.set_data(0x00) 93 | -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/entities/未命名.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 2 6 | } 7 | -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/sakshat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | __author__ = 'Spoony' 20 | __version__ = 'version 0.0.1' 21 | __license__ = 'Copyright (c) 2016 NXEZ.COM' 22 | 23 | import RPi.GPIO as GPIO 24 | from sakspins import SAKSPins as PINS 25 | import entities 26 | 27 | class SAKSHAT(object): 28 | ''' 29 | SAKS HAT class, some useful function are declared. 30 | ''' 31 | buzzer = None 32 | ledrow = None 33 | ds18b20 = None 34 | digital_display = None 35 | dip_switch = None 36 | tactrow = None 37 | 38 | def saks_gpio_init(self): 39 | #print 'saks_gpio_init' 40 | GPIO.setwarnings(False) 41 | GPIO.cleanup() 42 | GPIO.setmode(GPIO.BCM) 43 | 44 | GPIO.setup(PINS.BUZZER, GPIO.OUT) 45 | GPIO.output(PINS.BUZZER, GPIO.HIGH) 46 | 47 | for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: 48 | GPIO.setup(p, GPIO.OUT) 49 | GPIO.output(p, GPIO.LOW) 50 | 51 | for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 52 | GPIO.setup(p, GPIO.OUT) 53 | GPIO.output(p, GPIO.HIGH) 54 | 55 | for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 56 | GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 57 | 58 | def __init__(self): 59 | self.saks_gpio_init() 60 | self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW) 61 | self.ledrow = entities.Led74HC595({'ds': PINS.IC_74HC595_DS, 'shcp': PINS.IC_74HC595_SHCP, 'stcp': PINS.IC_74HC595_STCP}, GPIO.HIGH) 62 | self.ds18b20 = entities.DS18B20(PINS.DS18B20) 63 | self.digital_display = entities.DigitalDisplayTM1637({'di': PINS.IC_TM1637_DI, 'clk': PINS.IC_TM1637_CLK}, GPIO.HIGH) 64 | self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW) 65 | self.dip_switch.register(self) 66 | self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW) 67 | for t in self.tactrow.items: 68 | t.register(self) 69 | 70 | #print('self.dip_switch.register(self)') 71 | 72 | dip_switch_status_changed_handler = None 73 | def on_dip_switch_2bit_status_changed(self, status): 74 | #print('on_dip_switch_2bit_status_changed') 75 | if self.dip_switch_status_changed_handler is not None: 76 | self.dip_switch_status_changed_handler(status) 77 | 78 | tact_event_handler = None 79 | def on_tact_event(self, pin, status): 80 | #print('on_tact_event') 81 | if self.tact_event_handler is not None: 82 | self.tact_event_handler(pin, status) 83 | -------------------------------------------------------------------------------- /09.小小按键在我手,我的触碰你知道/sakspins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | class SAKSPins(object): 20 | ''' 21 | SAKS Pins Code With BCM for Raspberry Pi. 22 | ''' 23 | 24 | IC_74HC595_DS = 6 25 | IC_74HC595_SHCP = 19 26 | IC_74HC595_STCP = 13 27 | 28 | IC_TM1637_DI = 25 29 | IC_TM1637_CLK = 5 30 | 31 | BUZZER = 12 32 | 33 | TACT_RIGHT = 20 34 | TACT_LEFT = 16 35 | DIP_SWITCH_1 = 21 36 | DIP_SWITCH_2 = 26 37 | 38 | IR_SENDER = 17 39 | IR_RECEIVER = 9 40 | DS18B20 = 4 41 | UART_TXD = 14 42 | UART_RXD = 15 43 | I2C_SDA = 2 44 | I2C_SLC = 3 -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/__pycache__/sakshat.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/__pycache__/sakshat.cpython-35.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__init__.py: -------------------------------------------------------------------------------- 1 | from .buzzer import Buzzer 2 | from .led import Led 3 | from .led import LedRow 4 | from .ds18b20 import DS18B20 5 | from .digital_display import DigitalDisplay 6 | from .dip_switch_2bit import DipSwitch2Bit 7 | from .tact import Tact 8 | from .tact import TactRow 9 | from .ic_74hc595 import IC_74HC595 10 | from .led_74hc595 import Led74HC595 11 | from .ic_tm1637 import IC_TM1637 12 | from .digital_display_tm1637 import DigitalDisplayTM1637 13 | -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/buzzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/buzzer.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/digital_display.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/digital_display.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/digital_display_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/digital_display_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/dip_switch_2bit.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/dip_switch_2bit.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/ds18b20.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/ds18b20.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/ic_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/ic_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/ic_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/ic_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/led.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/led.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/led_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/led_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/__pycache__/tact.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/10.有了数码管,数字、字母任我写/entities/__pycache__/tact.cpython-37.pyc -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2015 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | import time 21 | 22 | class Buzzer(object): 23 | ''' 24 | Buzzer class 25 | ''' 26 | __pin = 0 27 | __real_true = GPIO.HIGH 28 | __is_on = False 29 | 30 | def __init__(self, pin, real_true = GPIO.HIGH): 31 | ''' 32 | Init the buzzer 33 | :param pin: pin number 34 | :param real_true: GPIO.HIGH or GPIO.LOW 35 | :return: void 36 | ''' 37 | self.__pin = pin 38 | self.__real_true = real_true 39 | 40 | #Stauts. 41 | @property 42 | def is_on(self): 43 | ''' 44 | Return the status of buzzer 45 | :return: void 46 | ''' 47 | return self.__is_on 48 | 49 | #Verbs. 50 | def on(self): 51 | ''' 52 | Set buzzer on 53 | :return: void 54 | ''' 55 | GPIO.output(self.__pin, self.__real_true) 56 | self.__is_on = True 57 | 58 | def off(self): 59 | ''' 60 | Set buzzer off 61 | :return: void 62 | ''' 63 | GPIO.output(self.__pin, not self.__real_true) 64 | self.__is_on = False 65 | 66 | #functions. 67 | def beep(self, seconds): 68 | ''' 69 | Beep one time 70 | :param seconds: beep time 71 | :return: void 72 | ''' 73 | self.on() 74 | time.sleep(seconds) 75 | self.off() 76 | 77 | def beepAction(self, secs, sleepsecs, times): 78 | ''' 79 | Beep in a rhythm 80 | e.g. beepAction(0.02,0.02,30) 81 | :param secs: beep time 82 | :param sleepsecs: break time 83 | :param times: repeat times 84 | :return: void 85 | ''' 86 | for i in range(times): 87 | self.beep(secs) 88 | time.sleep(sleepsecs) 89 | -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/entities/ic_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | 21 | class IC_74HC595(object): 22 | ''' 23 | IC_74HC595 class 24 | ''' 25 | __pins = {'ds':0, 'shcp':0, 'stcp':0} 26 | __real_true = GPIO.HIGH 27 | __data = 0x00 28 | 29 | def __init__(self, pins, real_true = GPIO.HIGH): 30 | ''' 31 | Init the ic 32 | :param pin: pin number 33 | :param real_true: GPIO.HIGH or GPIO.LOW 34 | :return: void 35 | ''' 36 | self.__pins = pins 37 | self.__real_true = real_true 38 | 39 | #Stauts. 40 | @property 41 | def data(self): 42 | ''' 43 | Return the data 44 | :return: void 45 | ''' 46 | return self.__data 47 | 48 | #Verbs. 49 | def flush_shcp(self): 50 | ''' 51 | Flush a shcp 52 | :return: void 53 | ''' 54 | GPIO.output(self.__pins['shcp'], not self.__real_true) 55 | GPIO.output(self.__pins['shcp'], self.__real_true) 56 | 57 | def flush_stcp(self): 58 | ''' 59 | Flush a stcp 60 | :return: void 61 | ''' 62 | GPIO.output(self.__pins['stcp'], not self.__real_true) 63 | GPIO.output(self.__pins['stcp'], self.__real_true) 64 | 65 | def set_bit(self, bit): 66 | ''' 67 | Set a bit 68 | :param bit: bit 69 | :return: void 70 | ''' 71 | GPIO.output(self.__pins['ds'], bit) 72 | self.flush_shcp() 73 | 74 | def set_data(self, data): 75 | ''' 76 | Set a byte 77 | :param data: data 78 | :return: void 79 | ''' 80 | self.__data = data 81 | for i in range (0, 8): 82 | self.set_bit((self.__data >> i) & 0x01) 83 | 84 | self.flush_stcp() 85 | 86 | 87 | def clear(self): 88 | ''' 89 | Clear the data 90 | :return: void 91 | ''' 92 | self.set_data(0x00) 93 | -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/sakshat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | __author__ = 'Spoony' 20 | __version__ = 'version 0.0.1' 21 | __license__ = 'Copyright (c) 2016 NXEZ.COM' 22 | 23 | import RPi.GPIO as GPIO 24 | from sakspins import SAKSPins as PINS 25 | import entities 26 | 27 | class SAKSHAT(object): 28 | ''' 29 | SAKS HAT class, some useful function are declared. 30 | ''' 31 | buzzer = None 32 | ledrow = None 33 | ds18b20 = None 34 | digital_display = None 35 | dip_switch = None 36 | tactrow = None 37 | 38 | def saks_gpio_init(self): 39 | #print 'saks_gpio_init' 40 | GPIO.setwarnings(False) 41 | GPIO.cleanup() 42 | GPIO.setmode(GPIO.BCM) 43 | 44 | GPIO.setup(PINS.BUZZER, GPIO.OUT) 45 | GPIO.output(PINS.BUZZER, GPIO.HIGH) 46 | 47 | for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: 48 | GPIO.setup(p, GPIO.OUT) 49 | GPIO.output(p, GPIO.LOW) 50 | 51 | for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 52 | GPIO.setup(p, GPIO.OUT) 53 | GPIO.output(p, GPIO.HIGH) 54 | 55 | for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 56 | GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 57 | 58 | def __init__(self): 59 | self.saks_gpio_init() 60 | self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW) 61 | self.ledrow = entities.Led74HC595({'ds': PINS.IC_74HC595_DS, 'shcp': PINS.IC_74HC595_SHCP, 'stcp': PINS.IC_74HC595_STCP}, GPIO.HIGH) 62 | self.ds18b20 = entities.DS18B20(PINS.DS18B20) 63 | self.digital_display = entities.DigitalDisplayTM1637({'di': PINS.IC_TM1637_DI, 'clk': PINS.IC_TM1637_CLK}, GPIO.HIGH) 64 | self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW) 65 | self.dip_switch.register(self) 66 | self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW) 67 | for t in self.tactrow.items: 68 | t.register(self) 69 | 70 | #print('self.dip_switch.register(self)') 71 | 72 | dip_switch_status_changed_handler = None 73 | def on_dip_switch_2bit_status_changed(self, status): 74 | #print('on_dip_switch_2bit_status_changed') 75 | if self.dip_switch_status_changed_handler is not None: 76 | self.dip_switch_status_changed_handler(status) 77 | 78 | tact_event_handler = None 79 | def on_tact_event(self, pin, status): 80 | #print('on_tact_event') 81 | if self.tact_event_handler is not None: 82 | self.tact_event_handler(pin, status) 83 | -------------------------------------------------------------------------------- /10.有了数码管,数字、字母任我写/sakspins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | class SAKSPins(object): 20 | ''' 21 | SAKS Pins Code With BCM for Raspberry Pi. 22 | ''' 23 | 24 | IC_74HC595_DS = 6 25 | IC_74HC595_SHCP = 19 26 | IC_74HC595_STCP = 13 27 | 28 | IC_TM1637_DI = 25 29 | IC_TM1637_CLK = 5 30 | 31 | BUZZER = 12 32 | 33 | TACT_RIGHT = 20 34 | TACT_LEFT = 16 35 | DIP_SWITCH_1 = 21 36 | DIP_SWITCH_2 = 26 37 | 38 | IR_SENDER = 17 39 | IR_RECEIVER = 9 40 | DS18B20 = 4 41 | UART_TXD = 14 42 | UART_RXD = 15 43 | I2C_SDA = 2 44 | I2C_SLC = 3 -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/.ipynb_checkpoints/1.温度采集这么太简单了吧,还想复杂了-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# SAKSHAT提供的DS18B20使用方法\n", 10 | "当前SAKSHAT为我们提供的方法参考:http://wiki.nxez.com/saks:sdk:libraries:ds18b20\n", 11 | "\n", 12 | "这里就直接摘录了,以下是创百科的内容:\n", 13 | " \n", 14 | "DS18B20\n", 15 | "\n", 16 | "DS18B20温度传感器类,从传感器读取温度数据。方法如下:\n", 17 | "\n", 18 | "__init__(self, pin = 4)\n", 19 | "\n", 20 | "初始化对象,设置传感器数据引脚。\n", 21 | "\n", 22 | "is_exist(self, index = 0)\n", 23 | "\n", 24 | "返回传感器是否存在。true 或 false。存在多个传感器并联时 index 用于区分第几个传感器,编号从 0 开始。\n", 25 | "\n", 26 | "temperature(self, index = 0)\n", 27 | "\n", 28 | "返回当前传感器的温度数据,当传感器不存在或读取失败时返回 -128 度。存在多个传感器并联时 index 用于区分第几个传感器,编号从 0 开始。\n" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "#获取温度传感器温度,并进行显示\n", 38 | "from sakshat import SAKSHAT\n", 39 | "from sakspins import SAKSPins as PINS\n", 40 | "\n", 41 | "if __name__ == \"__main__\":\n", 42 | " try:\n", 43 | " #Declare the SAKS Board\n", 44 | " SAKS = SAKSHAT()\n", 45 | " \n", 46 | " while True: \n", 47 | " #从 ds18b20 读取温度(摄氏度为单位)\n", 48 | " temp = SAKS.ds18b20.temperature\n", 49 | "\n", 50 | " #下方输出温度值\n", 51 | " print (\"这就是我采集到的温度值\" + (\"%5.1f\" % temp).replace(' ','#'))\n", 52 | " \n", 53 | " #数码管显示温度\n", 54 | " SAKS.digital_display.show((\"%5.1f\" % temp).replace(' ','#'))\n", 55 | " \n", 56 | " except KeyboardInterrupt:\n", 57 | " print(\"任务被终止了\")" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": null, 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [] 66 | } 67 | ], 68 | "metadata": { 69 | "kernelspec": { 70 | "display_name": "Python 3", 71 | "language": "python", 72 | "name": "python3" 73 | }, 74 | "language_info": { 75 | "codemirror_mode": { 76 | "name": "ipython", 77 | "version": 3 78 | }, 79 | "file_extension": ".py", 80 | "mimetype": "text/x-python", 81 | "name": "python", 82 | "nbconvert_exporter": "python", 83 | "pygments_lexer": "ipython3", 84 | "version": "3.7.3" 85 | } 86 | }, 87 | "nbformat": 4, 88 | "nbformat_minor": 1 89 | } 90 | -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/1.温度采集这么太简单了吧,还想复杂了.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# SAKSHAT提供的DS18B20使用方法\n", 10 | "当前SAKSHAT为我们提供的方法参考:http://wiki.nxez.com/saks:sdk:libraries:ds18b20\n", 11 | "\n", 12 | "这里就直接摘录了,以下是创百科的内容:\n", 13 | " \n", 14 | "DS18B20\n", 15 | "\n", 16 | "DS18B20温度传感器类,从传感器读取温度数据。方法如下:\n", 17 | "\n", 18 | "__init__(self, pin = 4)\n", 19 | "\n", 20 | "初始化对象,设置传感器数据引脚。\n", 21 | "\n", 22 | "is_exist(self, index = 0)\n", 23 | "\n", 24 | "返回传感器是否存在。true 或 false。存在多个传感器并联时 index 用于区分第几个传感器,编号从 0 开始。\n", 25 | "\n", 26 | "temperature(self, index = 0)\n", 27 | "\n", 28 | "返回当前传感器的温度数据,当传感器不存在或读取失败时返回 -128 度。存在多个传感器并联时 index 用于区分第几个传感器,编号从 0 开始。\n" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "#获取温度传感器温度,并进行显示\n", 38 | "from sakshat import SAKSHAT\n", 39 | "from sakspins import SAKSPins as PINS\n", 40 | "\n", 41 | "if __name__ == \"__main__\":\n", 42 | " try:\n", 43 | " #Declare the SAKS Board\n", 44 | " SAKS = SAKSHAT()\n", 45 | " \n", 46 | " while True: \n", 47 | " #从 ds18b20 读取温度(摄氏度为单位)\n", 48 | " temp = SAKS.ds18b20.temperature\n", 49 | "\n", 50 | " #下方输出温度值\n", 51 | " print (\"这就是我采集到的温度值\" + (\"%5.1f\" % temp).replace(' ','#'))\n", 52 | " \n", 53 | " #数码管显示温度\n", 54 | " SAKS.digital_display.show((\"%5.1f\" % temp).replace(' ','#'))\n", 55 | " \n", 56 | " except KeyboardInterrupt:\n", 57 | " print(\"任务被终止了\")" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": null, 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [] 66 | } 67 | ], 68 | "metadata": { 69 | "kernelspec": { 70 | "display_name": "Python 3", 71 | "language": "python", 72 | "name": "python3" 73 | }, 74 | "language_info": { 75 | "codemirror_mode": { 76 | "name": "ipython", 77 | "version": 3 78 | }, 79 | "file_extension": ".py", 80 | "mimetype": "text/x-python", 81 | "name": "python", 82 | "nbconvert_exporter": "python", 83 | "pygments_lexer": "ipython3", 84 | "version": "3.7.3" 85 | } 86 | }, 87 | "nbformat": 4, 88 | "nbformat_minor": 1 89 | } 90 | -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__init__.py: -------------------------------------------------------------------------------- 1 | from .buzzer import Buzzer 2 | from .led import Led 3 | from .led import LedRow 4 | from .ds18b20 import DS18B20 5 | from .digital_display import DigitalDisplay 6 | from .dip_switch_2bit import DipSwitch2Bit 7 | from .tact import Tact 8 | from .tact import TactRow 9 | from .ic_74hc595 import IC_74HC595 10 | from .led_74hc595 import Led74HC595 11 | from .ic_tm1637 import IC_TM1637 12 | from .digital_display_tm1637 import DigitalDisplayTM1637 13 | -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/buzzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/buzzer.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/digital_display.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/digital_display.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/digital_display_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/digital_display_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/dip_switch_2bit.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/dip_switch_2bit.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/ds18b20.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/ds18b20.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/ic_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/ic_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/ic_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/ic_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/led.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/led.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/led_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/led_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/__pycache__/tact.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/11.有了他,再不用到处找温度计了/entities/__pycache__/tact.cpython-37.pyc -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2015 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | import time 21 | 22 | class Buzzer(object): 23 | ''' 24 | Buzzer class 25 | ''' 26 | __pin = 0 27 | __real_true = GPIO.HIGH 28 | __is_on = False 29 | 30 | def __init__(self, pin, real_true = GPIO.HIGH): 31 | ''' 32 | Init the buzzer 33 | :param pin: pin number 34 | :param real_true: GPIO.HIGH or GPIO.LOW 35 | :return: void 36 | ''' 37 | self.__pin = pin 38 | self.__real_true = real_true 39 | 40 | #Stauts. 41 | @property 42 | def is_on(self): 43 | ''' 44 | Return the status of buzzer 45 | :return: void 46 | ''' 47 | return self.__is_on 48 | 49 | #Verbs. 50 | def on(self): 51 | ''' 52 | Set buzzer on 53 | :return: void 54 | ''' 55 | GPIO.output(self.__pin, self.__real_true) 56 | self.__is_on = True 57 | 58 | def off(self): 59 | ''' 60 | Set buzzer off 61 | :return: void 62 | ''' 63 | GPIO.output(self.__pin, not self.__real_true) 64 | self.__is_on = False 65 | 66 | #functions. 67 | def beep(self, seconds): 68 | ''' 69 | Beep one time 70 | :param seconds: beep time 71 | :return: void 72 | ''' 73 | self.on() 74 | time.sleep(seconds) 75 | self.off() 76 | 77 | def beepAction(self, secs, sleepsecs, times): 78 | ''' 79 | Beep in a rhythm 80 | e.g. beepAction(0.02,0.02,30) 81 | :param secs: beep time 82 | :param sleepsecs: break time 83 | :param times: repeat times 84 | :return: void 85 | ''' 86 | for i in range(times): 87 | self.beep(secs) 88 | time.sleep(sleepsecs) 89 | -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/entities/ic_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | 21 | class IC_74HC595(object): 22 | ''' 23 | IC_74HC595 class 24 | ''' 25 | __pins = {'ds':0, 'shcp':0, 'stcp':0} 26 | __real_true = GPIO.HIGH 27 | __data = 0x00 28 | 29 | def __init__(self, pins, real_true = GPIO.HIGH): 30 | ''' 31 | Init the ic 32 | :param pin: pin number 33 | :param real_true: GPIO.HIGH or GPIO.LOW 34 | :return: void 35 | ''' 36 | self.__pins = pins 37 | self.__real_true = real_true 38 | 39 | #Stauts. 40 | @property 41 | def data(self): 42 | ''' 43 | Return the data 44 | :return: void 45 | ''' 46 | return self.__data 47 | 48 | #Verbs. 49 | def flush_shcp(self): 50 | ''' 51 | Flush a shcp 52 | :return: void 53 | ''' 54 | GPIO.output(self.__pins['shcp'], not self.__real_true) 55 | GPIO.output(self.__pins['shcp'], self.__real_true) 56 | 57 | def flush_stcp(self): 58 | ''' 59 | Flush a stcp 60 | :return: void 61 | ''' 62 | GPIO.output(self.__pins['stcp'], not self.__real_true) 63 | GPIO.output(self.__pins['stcp'], self.__real_true) 64 | 65 | def set_bit(self, bit): 66 | ''' 67 | Set a bit 68 | :param bit: bit 69 | :return: void 70 | ''' 71 | GPIO.output(self.__pins['ds'], bit) 72 | self.flush_shcp() 73 | 74 | def set_data(self, data): 75 | ''' 76 | Set a byte 77 | :param data: data 78 | :return: void 79 | ''' 80 | self.__data = data 81 | for i in range (0, 8): 82 | self.set_bit((self.__data >> i) & 0x01) 83 | 84 | self.flush_stcp() 85 | 86 | 87 | def clear(self): 88 | ''' 89 | Clear the data 90 | :return: void 91 | ''' 92 | self.set_data(0x00) 93 | -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/sakshat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | __author__ = 'Spoony' 20 | __version__ = 'version 0.0.1' 21 | __license__ = 'Copyright (c) 2016 NXEZ.COM' 22 | 23 | import RPi.GPIO as GPIO 24 | from sakspins import SAKSPins as PINS 25 | import entities 26 | 27 | class SAKSHAT(object): 28 | ''' 29 | SAKS HAT class, some useful function are declared. 30 | ''' 31 | buzzer = None 32 | ledrow = None 33 | ds18b20 = None 34 | digital_display = None 35 | dip_switch = None 36 | tactrow = None 37 | 38 | def saks_gpio_init(self): 39 | #print 'saks_gpio_init' 40 | GPIO.setwarnings(False) 41 | GPIO.cleanup() 42 | GPIO.setmode(GPIO.BCM) 43 | 44 | GPIO.setup(PINS.BUZZER, GPIO.OUT) 45 | GPIO.output(PINS.BUZZER, GPIO.HIGH) 46 | 47 | for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: 48 | GPIO.setup(p, GPIO.OUT) 49 | GPIO.output(p, GPIO.LOW) 50 | 51 | for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 52 | GPIO.setup(p, GPIO.OUT) 53 | GPIO.output(p, GPIO.HIGH) 54 | 55 | for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 56 | GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 57 | 58 | def __init__(self): 59 | self.saks_gpio_init() 60 | self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW) 61 | self.ledrow = entities.Led74HC595({'ds': PINS.IC_74HC595_DS, 'shcp': PINS.IC_74HC595_SHCP, 'stcp': PINS.IC_74HC595_STCP}, GPIO.HIGH) 62 | self.ds18b20 = entities.DS18B20(PINS.DS18B20) 63 | self.digital_display = entities.DigitalDisplayTM1637({'di': PINS.IC_TM1637_DI, 'clk': PINS.IC_TM1637_CLK}, GPIO.HIGH) 64 | self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW) 65 | self.dip_switch.register(self) 66 | self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW) 67 | for t in self.tactrow.items: 68 | t.register(self) 69 | 70 | #print('self.dip_switch.register(self)') 71 | 72 | dip_switch_status_changed_handler = None 73 | def on_dip_switch_2bit_status_changed(self, status): 74 | #print('on_dip_switch_2bit_status_changed') 75 | if self.dip_switch_status_changed_handler is not None: 76 | self.dip_switch_status_changed_handler(status) 77 | 78 | tact_event_handler = None 79 | def on_tact_event(self, pin, status): 80 | #print('on_tact_event') 81 | if self.tact_event_handler is not None: 82 | self.tact_event_handler(pin, status) 83 | -------------------------------------------------------------------------------- /11.有了他,再不用到处找温度计了/sakspins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | class SAKSPins(object): 20 | ''' 21 | SAKS Pins Code With BCM for Raspberry Pi. 22 | ''' 23 | 24 | IC_74HC595_DS = 6 25 | IC_74HC595_SHCP = 19 26 | IC_74HC595_STCP = 13 27 | 28 | IC_TM1637_DI = 25 29 | IC_TM1637_CLK = 5 30 | 31 | BUZZER = 12 32 | 33 | TACT_RIGHT = 20 34 | TACT_LEFT = 16 35 | DIP_SWITCH_1 = 21 36 | DIP_SWITCH_2 = 26 37 | 38 | IR_SENDER = 17 39 | IR_RECEIVER = 9 40 | DS18B20 = 4 41 | UART_TXD = 14 42 | UART_RXD = 15 43 | I2C_SDA = 2 44 | I2C_SLC = 3 -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__init__.py: -------------------------------------------------------------------------------- 1 | from .buzzer import Buzzer 2 | from .led import Led 3 | from .led import LedRow 4 | from .ds18b20 import DS18B20 5 | from .digital_display import DigitalDisplay 6 | from .dip_switch_2bit import DipSwitch2Bit 7 | from .tact import Tact 8 | from .tact import TactRow 9 | from .ic_74hc595 import IC_74HC595 10 | from .led_74hc595 import Led74HC595 11 | from .ic_tm1637 import IC_TM1637 12 | from .digital_display_tm1637 import DigitalDisplayTM1637 13 | -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/buzzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/buzzer.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/digital_display.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/digital_display.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/digital_display_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/digital_display_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/dip_switch_2bit.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/dip_switch_2bit.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/ds18b20.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/ds18b20.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/ic_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/ic_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/ic_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/ic_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/led.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/led.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/led_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/led_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/__pycache__/tact.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/entities/__pycache__/tact.cpython-37.pyc -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2015 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | import time 21 | 22 | class Buzzer(object): 23 | ''' 24 | Buzzer class 25 | ''' 26 | __pin = 0 27 | __real_true = GPIO.HIGH 28 | __is_on = False 29 | 30 | def __init__(self, pin, real_true = GPIO.HIGH): 31 | ''' 32 | Init the buzzer 33 | :param pin: pin number 34 | :param real_true: GPIO.HIGH or GPIO.LOW 35 | :return: void 36 | ''' 37 | self.__pin = pin 38 | self.__real_true = real_true 39 | 40 | #Stauts. 41 | @property 42 | def is_on(self): 43 | ''' 44 | Return the status of buzzer 45 | :return: void 46 | ''' 47 | return self.__is_on 48 | 49 | #Verbs. 50 | def on(self): 51 | ''' 52 | Set buzzer on 53 | :return: void 54 | ''' 55 | GPIO.output(self.__pin, self.__real_true) 56 | self.__is_on = True 57 | 58 | def off(self): 59 | ''' 60 | Set buzzer off 61 | :return: void 62 | ''' 63 | GPIO.output(self.__pin, not self.__real_true) 64 | self.__is_on = False 65 | 66 | #functions. 67 | def beep(self, seconds): 68 | ''' 69 | Beep one time 70 | :param seconds: beep time 71 | :return: void 72 | ''' 73 | self.on() 74 | time.sleep(seconds) 75 | self.off() 76 | 77 | def beepAction(self, secs, sleepsecs, times): 78 | ''' 79 | Beep in a rhythm 80 | e.g. beepAction(0.02,0.02,30) 81 | :param secs: beep time 82 | :param sleepsecs: break time 83 | :param times: repeat times 84 | :return: void 85 | ''' 86 | for i in range(times): 87 | self.beep(secs) 88 | time.sleep(sleepsecs) 89 | -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/entities/ic_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | 21 | class IC_74HC595(object): 22 | ''' 23 | IC_74HC595 class 24 | ''' 25 | __pins = {'ds':0, 'shcp':0, 'stcp':0} 26 | __real_true = GPIO.HIGH 27 | __data = 0x00 28 | 29 | def __init__(self, pins, real_true = GPIO.HIGH): 30 | ''' 31 | Init the ic 32 | :param pin: pin number 33 | :param real_true: GPIO.HIGH or GPIO.LOW 34 | :return: void 35 | ''' 36 | self.__pins = pins 37 | self.__real_true = real_true 38 | 39 | #Stauts. 40 | @property 41 | def data(self): 42 | ''' 43 | Return the data 44 | :return: void 45 | ''' 46 | return self.__data 47 | 48 | #Verbs. 49 | def flush_shcp(self): 50 | ''' 51 | Flush a shcp 52 | :return: void 53 | ''' 54 | GPIO.output(self.__pins['shcp'], not self.__real_true) 55 | GPIO.output(self.__pins['shcp'], self.__real_true) 56 | 57 | def flush_stcp(self): 58 | ''' 59 | Flush a stcp 60 | :return: void 61 | ''' 62 | GPIO.output(self.__pins['stcp'], not self.__real_true) 63 | GPIO.output(self.__pins['stcp'], self.__real_true) 64 | 65 | def set_bit(self, bit): 66 | ''' 67 | Set a bit 68 | :param bit: bit 69 | :return: void 70 | ''' 71 | GPIO.output(self.__pins['ds'], bit) 72 | self.flush_shcp() 73 | 74 | def set_data(self, data): 75 | ''' 76 | Set a byte 77 | :param data: data 78 | :return: void 79 | ''' 80 | self.__data = data 81 | for i in range (0, 8): 82 | self.set_bit((self.__data >> i) & 0x01) 83 | 84 | self.flush_stcp() 85 | 86 | 87 | def clear(self): 88 | ''' 89 | Clear the data 90 | :return: void 91 | ''' 92 | self.set_data(0x00) 93 | -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/picture/python_pdb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/12.调试器在手,想看什么看什么/picture/python_pdb.jpg -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/sakshat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | __author__ = 'Spoony' 20 | __version__ = 'version 0.0.1' 21 | __license__ = 'Copyright (c) 2016 NXEZ.COM' 22 | 23 | import RPi.GPIO as GPIO 24 | from sakspins import SAKSPins as PINS 25 | import entities 26 | 27 | class SAKSHAT(object): 28 | ''' 29 | SAKS HAT class, some useful function are declared. 30 | ''' 31 | buzzer = None 32 | ledrow = None 33 | ds18b20 = None 34 | digital_display = None 35 | dip_switch = None 36 | tactrow = None 37 | 38 | def saks_gpio_init(self): 39 | #print 'saks_gpio_init' 40 | GPIO.setwarnings(False) 41 | GPIO.cleanup() 42 | GPIO.setmode(GPIO.BCM) 43 | 44 | GPIO.setup(PINS.BUZZER, GPIO.OUT) 45 | GPIO.output(PINS.BUZZER, GPIO.HIGH) 46 | 47 | for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: 48 | GPIO.setup(p, GPIO.OUT) 49 | GPIO.output(p, GPIO.LOW) 50 | 51 | for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 52 | GPIO.setup(p, GPIO.OUT) 53 | GPIO.output(p, GPIO.HIGH) 54 | 55 | for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 56 | GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 57 | 58 | def __init__(self): 59 | self.saks_gpio_init() 60 | self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW) 61 | self.ledrow = entities.Led74HC595({'ds': PINS.IC_74HC595_DS, 'shcp': PINS.IC_74HC595_SHCP, 'stcp': PINS.IC_74HC595_STCP}, GPIO.HIGH) 62 | self.ds18b20 = entities.DS18B20(PINS.DS18B20) 63 | self.digital_display = entities.DigitalDisplayTM1637({'di': PINS.IC_TM1637_DI, 'clk': PINS.IC_TM1637_CLK}, GPIO.HIGH) 64 | self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW) 65 | self.dip_switch.register(self) 66 | self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW) 67 | for t in self.tactrow.items: 68 | t.register(self) 69 | 70 | #print('self.dip_switch.register(self)') 71 | 72 | dip_switch_status_changed_handler = None 73 | def on_dip_switch_2bit_status_changed(self, status): 74 | #print('on_dip_switch_2bit_status_changed') 75 | if self.dip_switch_status_changed_handler is not None: 76 | self.dip_switch_status_changed_handler(status) 77 | 78 | tact_event_handler = None 79 | def on_tact_event(self, pin, status): 80 | #print('on_tact_event') 81 | if self.tact_event_handler is not None: 82 | self.tact_event_handler(pin, status) 83 | -------------------------------------------------------------------------------- /12.调试器在手,想看什么看什么/sakspins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | class SAKSPins(object): 20 | ''' 21 | SAKS Pins Code With BCM for Raspberry Pi. 22 | ''' 23 | 24 | IC_74HC595_DS = 6 25 | IC_74HC595_SHCP = 19 26 | IC_74HC595_STCP = 13 27 | 28 | IC_TM1637_DI = 25 29 | IC_TM1637_CLK = 5 30 | 31 | BUZZER = 12 32 | 33 | TACT_RIGHT = 20 34 | TACT_LEFT = 16 35 | DIP_SWITCH_1 = 21 36 | DIP_SWITCH_2 = 26 37 | 38 | IR_SENDER = 17 39 | IR_RECEIVER = 9 40 | DS18B20 = 4 41 | UART_TXD = 14 42 | UART_RXD = 15 43 | I2C_SDA = 2 44 | I2C_SLC = 3 -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/__pycache__/camera_pi.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/__pycache__/camera_pi.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/__pycache__/sakshat.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/__pycache__/sakshat.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/__pycache__/sakspins.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/__pycache__/sakspins.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/appCam2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # appCam.py 5 | # based on tutorial ==> https://blog.miguelgrinberg.com/post/video-streaming-with-flask 6 | # PiCam Local Web Server with Flask 7 | # MJRoBot.org 19Jan18 8 | 9 | from flask import Flask, render_template, Response 10 | app = Flask(__name__) 11 | 12 | 13 | import time 14 | from sakshat import SAKSHAT 15 | from sakspins import SAKSPins as PINS 16 | 17 | #Declare the SAKS Board 18 | 19 | # get data from DHT sensor 20 | def getDHTdata(): 21 | #DHT22Sensor = Adafruit_DHT.DHT22 22 | #DHTpin = 16 23 | #hum, temp = Adafruit_DHT.read_retry(DHT22Sensor, DHTpin) 24 | 25 | hum = 1 26 | temp = SAKS.ds18b20.temperature 27 | if hum is not None and temp is not None: 28 | hum = round(hum) 29 | temp = round(temp, 1) 30 | return temp, hum 31 | 32 | 33 | @app.route("/") 34 | def index(): 35 | timeNow = time.asctime( time.localtime(time.time()) ) 36 | temp, hum = getDHTdata() 37 | 38 | templateData = { 39 | 'time': timeNow, 40 | 'temp': temp, 41 | 'hum' : hum 42 | } 43 | return render_template('index.html', **templateData) 44 | 45 | @app.route('/led_light') 46 | def led_on(): 47 | #点亮所有LED灯 48 | SAKS.ledrow.on() 49 | timeNow = time.asctime( time.localtime(time.time()) ) 50 | temp, hum = getDHTdata() 51 | 52 | templateData = { 53 | 'time': timeNow, 54 | 'temp': temp, 55 | 'hum' : hum 56 | } 57 | return render_template('index.html', **templateData) 58 | 59 | @app.route('/led_close') 60 | def led_off(): 61 | #点亮所有LED灯 62 | SAKS.ledrow.off() 63 | timeNow = time.asctime( time.localtime(time.time()) ) 64 | temp, hum = getDHTdata() 65 | 66 | templateData = { 67 | 'time': timeNow, 68 | 'temp': temp, 69 | 'hum' : hum 70 | } 71 | return render_template('index.html', **templateData) 72 | 73 | if __name__ == '__main__': 74 | SAKS = SAKSHAT() 75 | app.run(host='0.0.0.0', port =8080, debug=True, threaded=True) 76 | -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__init__.py: -------------------------------------------------------------------------------- 1 | from .buzzer import Buzzer 2 | from .led import Led 3 | from .led import LedRow 4 | from .ds18b20 import DS18B20 5 | from .digital_display import DigitalDisplay 6 | from .dip_switch_2bit import DipSwitch2Bit 7 | from .tact import Tact 8 | from .tact import TactRow 9 | from .ic_74hc595 import IC_74HC595 10 | from .led_74hc595 import Led74HC595 11 | from .ic_tm1637 import IC_TM1637 12 | from .digital_display_tm1637 import DigitalDisplayTM1637 13 | -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/buzzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/buzzer.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/digital_display.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/digital_display.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/digital_display_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/digital_display_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/dip_switch_2bit.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/dip_switch_2bit.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/ds18b20.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/ds18b20.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/ic_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/ic_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/ic_tm1637.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/ic_tm1637.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/led.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/led.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/led_74hc595.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/led_74hc595.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/tact.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/camWebServer2/entities/__pycache__/tact.cpython-37.pyc -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2015 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | import time 21 | 22 | class Buzzer(object): 23 | ''' 24 | Buzzer class 25 | ''' 26 | __pin = 0 27 | __real_true = GPIO.HIGH 28 | __is_on = False 29 | 30 | def __init__(self, pin, real_true = GPIO.HIGH): 31 | ''' 32 | Init the buzzer 33 | :param pin: pin number 34 | :param real_true: GPIO.HIGH or GPIO.LOW 35 | :return: void 36 | ''' 37 | self.__pin = pin 38 | self.__real_true = real_true 39 | 40 | #Stauts. 41 | @property 42 | def is_on(self): 43 | ''' 44 | Return the status of buzzer 45 | :return: void 46 | ''' 47 | return self.__is_on 48 | 49 | #Verbs. 50 | def on(self): 51 | ''' 52 | Set buzzer on 53 | :return: void 54 | ''' 55 | GPIO.output(self.__pin, self.__real_true) 56 | self.__is_on = True 57 | 58 | def off(self): 59 | ''' 60 | Set buzzer off 61 | :return: void 62 | ''' 63 | GPIO.output(self.__pin, not self.__real_true) 64 | self.__is_on = False 65 | 66 | #functions. 67 | def beep(self, seconds): 68 | ''' 69 | Beep one time 70 | :param seconds: beep time 71 | :return: void 72 | ''' 73 | self.on() 74 | time.sleep(seconds) 75 | self.off() 76 | 77 | def beepAction(self, secs, sleepsecs, times): 78 | ''' 79 | Beep in a rhythm 80 | e.g. beepAction(0.02,0.02,30) 81 | :param secs: beep time 82 | :param sleepsecs: break time 83 | :param times: repeat times 84 | :return: void 85 | ''' 86 | for i in range(times): 87 | self.beep(secs) 88 | time.sleep(sleepsecs) 89 | -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/entities/ic_74hc595.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | import RPi.GPIO as GPIO 20 | 21 | class IC_74HC595(object): 22 | ''' 23 | IC_74HC595 class 24 | ''' 25 | __pins = {'ds':0, 'shcp':0, 'stcp':0} 26 | __real_true = GPIO.HIGH 27 | __data = 0x00 28 | 29 | def __init__(self, pins, real_true = GPIO.HIGH): 30 | ''' 31 | Init the ic 32 | :param pin: pin number 33 | :param real_true: GPIO.HIGH or GPIO.LOW 34 | :return: void 35 | ''' 36 | self.__pins = pins 37 | self.__real_true = real_true 38 | 39 | #Stauts. 40 | @property 41 | def data(self): 42 | ''' 43 | Return the data 44 | :return: void 45 | ''' 46 | return self.__data 47 | 48 | #Verbs. 49 | def flush_shcp(self): 50 | ''' 51 | Flush a shcp 52 | :return: void 53 | ''' 54 | GPIO.output(self.__pins['shcp'], not self.__real_true) 55 | GPIO.output(self.__pins['shcp'], self.__real_true) 56 | 57 | def flush_stcp(self): 58 | ''' 59 | Flush a stcp 60 | :return: void 61 | ''' 62 | GPIO.output(self.__pins['stcp'], not self.__real_true) 63 | GPIO.output(self.__pins['stcp'], self.__real_true) 64 | 65 | def set_bit(self, bit): 66 | ''' 67 | Set a bit 68 | :param bit: bit 69 | :return: void 70 | ''' 71 | GPIO.output(self.__pins['ds'], bit) 72 | self.flush_shcp() 73 | 74 | def set_data(self, data): 75 | ''' 76 | Set a byte 77 | :param data: data 78 | :return: void 79 | ''' 80 | self.__data = data 81 | for i in range (0, 8): 82 | self.set_bit((self.__data >> i) & 0x01) 83 | 84 | self.flush_stcp() 85 | 86 | 87 | def clear(self): 88 | ''' 89 | Clear the data 90 | :return: void 91 | ''' 92 | self.set_data(0x00) 93 | -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/sakshat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | __author__ = 'Spoony' 20 | __version__ = 'version 0.0.1' 21 | __license__ = 'Copyright (c) 2016 NXEZ.COM' 22 | 23 | import RPi.GPIO as GPIO 24 | from sakspins import SAKSPins as PINS 25 | import entities 26 | 27 | class SAKSHAT(object): 28 | ''' 29 | SAKS HAT class, some useful function are declared. 30 | ''' 31 | buzzer = None 32 | ledrow = None 33 | ds18b20 = None 34 | digital_display = None 35 | dip_switch = None 36 | tactrow = None 37 | 38 | def saks_gpio_init(self): 39 | #print 'saks_gpio_init' 40 | GPIO.setwarnings(False) 41 | GPIO.cleanup() 42 | GPIO.setmode(GPIO.BCM) 43 | 44 | GPIO.setup(PINS.BUZZER, GPIO.OUT) 45 | GPIO.output(PINS.BUZZER, GPIO.HIGH) 46 | 47 | for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: 48 | GPIO.setup(p, GPIO.OUT) 49 | GPIO.output(p, GPIO.LOW) 50 | 51 | for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 52 | GPIO.setup(p, GPIO.OUT) 53 | GPIO.output(p, GPIO.HIGH) 54 | 55 | for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: 56 | GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 57 | 58 | def __init__(self): 59 | self.saks_gpio_init() 60 | self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW) 61 | self.ledrow = entities.Led74HC595({'ds': PINS.IC_74HC595_DS, 'shcp': PINS.IC_74HC595_SHCP, 'stcp': PINS.IC_74HC595_STCP}, GPIO.HIGH) 62 | self.ds18b20 = entities.DS18B20(PINS.DS18B20) 63 | self.digital_display = entities.DigitalDisplayTM1637({'di': PINS.IC_TM1637_DI, 'clk': PINS.IC_TM1637_CLK}, GPIO.HIGH) 64 | self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW) 65 | self.dip_switch.register(self) 66 | self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW) 67 | for t in self.tactrow.items: 68 | t.register(self) 69 | 70 | #print('self.dip_switch.register(self)') 71 | 72 | dip_switch_status_changed_handler = None 73 | def on_dip_switch_2bit_status_changed(self, status): 74 | #print('on_dip_switch_2bit_status_changed') 75 | if self.dip_switch_status_changed_handler is not None: 76 | self.dip_switch_status_changed_handler(status) 77 | 78 | tact_event_handler = None 79 | def on_tact_event(self, pin, status): 80 | #print('on_tact_event') 81 | if self.tact_event_handler is not None: 82 | self.tact_event_handler(pin, status) 83 | -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/sakspins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (c) 2016 NXEZ.COM. 5 | # http://www.nxez.com 6 | # 7 | # Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.gnu.org/licenses/gpl-2.0.html 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | class SAKSPins(object): 20 | ''' 21 | SAKS Pins Code With BCM for Raspberry Pi. 22 | ''' 23 | 24 | IC_74HC595_DS = 6 25 | IC_74HC595_SHCP = 19 26 | IC_74HC595_STCP = 13 27 | 28 | IC_TM1637_DI = 25 29 | IC_TM1637_CLK = 5 30 | 31 | BUZZER = 12 32 | 33 | TACT_RIGHT = 20 34 | TACT_LEFT = 16 35 | DIP_SWITCH_1 = 21 36 | DIP_SWITCH_2 = 26 37 | 38 | IR_SENDER = 17 39 | IR_RECEIVER = 9 40 | DS18B20 = 4 41 | UART_TXD = 14 42 | UART_RXD = 15 43 | I2C_SDA = 2 44 | I2C_SLC = 3 -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/static/style.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | body{ 4 | background: blue; 5 | color: yellow; 6 | padding:1%; 7 | text-align: center; 8 | } 9 | 10 | .button { 11 | font: bold 15px Arial; 12 | text-decoration: none; 13 | background-color: #EEEEEE; 14 | color: #333333; 15 | padding: 2px 6px 2px 6px; 16 | border-top: 1px solid #CCCCCC; 17 | border-right: 1px solid #333333; 18 | border-bottom: 1px solid #333333; 19 | border-left: 1px solid #CCCCCC; 20 | } 21 | 22 | img{ 23 | display: display: inline-block 24 | } 25 | -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/camWebServer2/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |@2018 Developed
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /13.不论你身在何处,咱们都能聊天/picture/raspi_web.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/13.不论你身在何处,咱们都能聊天/picture/raspi_web.jpg -------------------------------------------------------------------------------- /14.我变聪明了,我可以认识的更多/picture/bp_networks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/14.我变聪明了,我可以认识的更多/picture/bp_networks.jpg -------------------------------------------------------------------------------- /14.我变聪明了,我可以认识的更多/picture/image_class.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/14.我变聪明了,我可以认识的更多/picture/image_class.jpg -------------------------------------------------------------------------------- /14.我变聪明了,我可以认识的更多/picture/object_detect.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/14.我变聪明了,我可以认识的更多/picture/object_detect.jpg -------------------------------------------------------------------------------- /14.我变聪明了,我可以认识的更多/picture/single_networks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/14.我变聪明了,我可以认识的更多/picture/single_networks.jpg -------------------------------------------------------------------------------- /14.我变聪明了,我可以认识的更多/picture/yolo_detect.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/14.我变聪明了,我可以认识的更多/picture/yolo_detect.jpg -------------------------------------------------------------------------------- /14.我变聪明了,我可以认识的更多/picture/yolo_mem_err.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/14.我变聪明了,我可以认识的更多/picture/yolo_mem_err.jpg -------------------------------------------------------------------------------- /14.我变聪明了,我可以认识的更多/picture/yolo_mode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/14.我变聪明了,我可以认识的更多/picture/yolo_mode.jpg -------------------------------------------------------------------------------- /14.我变聪明了,我可以认识的更多/picture/语义分割.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/14.我变聪明了,我可以认识的更多/picture/语义分割.jpg -------------------------------------------------------------------------------- /15.是时候用git进行重新整理了/.ipynb_checkpoints/1.git软件工具介绍-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# Git介绍\n", 10 | "下面是百度百科的介绍:https://baike.baidu.com/item/GIT/12647237?fr=aladdin\n", 11 | "\n", 12 | "Git(读音为/gɪt/。)是一个开源的分布式版本控制系统,可以有效、高速地处理从很小到非常大的项目版本管理。 [1] Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。\n", 13 | "\n", 14 | "Git的诞生(摘抄自廖雪峰老师的git教程):https://www.liaoxuefeng.com/wiki/896043488029600/896202815778784\n", 15 | "\n", 16 | "很多人都知道,Linus在1991年创建了开源的Linux,从此,Linux系统不断发展,已经成为最大的服务器系统软件了。\n", 17 | "\n", 18 | "Linus虽然创建了Linux,但Linux的壮大是靠全世界热心的志愿者参与的,这么多人在世界各地为Linux编写代码,那Linux的代码是如何管理的呢?\n", 19 | "\n", 20 | "事实是,在2002年以前,世界各地的志愿者把源代码文件通过diff的方式发给Linus,然后由Linus本人通过手工方式合并代码!\n", 21 | "\n", 22 | "你也许会想,为什么Linus不把Linux代码放到版本控制系统里呢?不是有CVS、SVN这些免费的版本控制系统吗?因为Linus坚定地反对CVS和SVN,这些集中式的版本控制系统不但速度慢,而且必须联网才能使用。有一些商用的版本控制系统,虽然比CVS、SVN好用,但那是付费的,和Linux的开源精神不符。\n", 23 | "\n", 24 | "不过,到了2002年,Linux系统已经发展了十年了,代码库之大让Linus很难继续通过手工方式管理了,社区的弟兄们也对这种方式表达了强烈不满,于是Linus选择了一个商业的版本控制系统BitKeeper,BitKeeper的东家BitMover公司出于人道主义精神,授权Linux社区免费使用这个版本控制系统。\n", 25 | "\n", 26 | "安定团结的大好局面在2005年就被打破了,原因是Linux社区牛人聚集,不免沾染了一些梁山好汉的江湖习气。开发Samba的Andrew试图破解BitKeeper的协议(这么干的其实也不只他一个),被BitMover公司发现了(监控工作做得不错!),于是BitMover公司怒了,要收回Linux社区的免费使用权。\n", 27 | "\n", 28 | "Linus可以向BitMover公司道个歉,保证以后严格管教弟兄们,嗯,这是不可能的。实际情况是这样的:\n", 29 | "\n", 30 | "Linus花了两周时间自己用C写了一个分布式版本控制系统,这就是Git!一个月之内,Linux系统的源码已经由Git管理了!牛是怎么定义的呢?大家可以体会一下。\n", 31 | "\n", 32 | "Git迅速成为最流行的分布式版本控制系统,尤其是2008年,GitHub网站上线了,它为开源项目免费提供Git存储,无数开源项目开始迁移至GitHub,包括jQuery,PHP,Ruby等等。\n", 33 | "\n", 34 | "历史就是这么偶然,如果不是当年BitMover公司威胁Linux社区,可能现在我们就没有免费而超级好用的Git了。\n", 35 | "\n", 36 | "Git如果您想掌握更多git技巧,请参见廖雪峰老师的git教程:https://www.liaoxuefeng.com/wiki/896043488029600\n" 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": {}, 42 | "source": [ 43 | "# Gitee和Github\n", 44 | "git是版本管理工具,用于管理本地软件开发流程,虽然git是分布式版本管理器,但也需要中心节点用于软件托管,但仅仅是软件的暂存而已。\n", 45 | "\n", 46 | "gitee和github就是这样的专业的软件托管服务器。区别就是,gitee是国内的,github是美国的。为以防万一,我们可以将已在github上托管的软件,同时在gitee上进行托管,用于备份。" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": null, 52 | "metadata": { 53 | "collapsed": true 54 | }, 55 | "outputs": [], 56 | "source": [] 57 | } 58 | ], 59 | "metadata": { 60 | "kernelspec": { 61 | "display_name": "Python 3", 62 | "language": "python", 63 | "name": "python3" 64 | }, 65 | "language_info": { 66 | "codemirror_mode": { 67 | "name": "ipython", 68 | "version": 3 69 | }, 70 | "file_extension": ".py", 71 | "mimetype": "text/x-python", 72 | "name": "python", 73 | "nbconvert_exporter": "python", 74 | "pygments_lexer": "ipython3", 75 | "version": "3.7.3" 76 | } 77 | }, 78 | "nbformat": 4, 79 | "nbformat_minor": 1 80 | } 81 | -------------------------------------------------------------------------------- /15.是时候用git进行重新整理了/.ipynb_checkpoints/2.git+gitee软件托管平台,进行软件开发-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# git+gitee软件过程管理工作流程\n", 10 | "关于git+gitee的软件过程管理有很多种使用方式,我介绍下我一直在使用的工作流程。这里介绍我工作流程的前半部分,简单的软件过程管理;后半部分,软件过程的三库管理(开发库、受控库、产皮库)将在《动手学树莓派-python下篇》中介绍。\n", 11 | "\n", 12 | "当前课程,主要介绍下述内容:\n", 13 | "\n", 14 | "(1)在gitee上建立软件库。\n", 15 | "\n", 16 | "(2)在本地下载(克隆)gitee上的软件库。\n", 17 | "\n", 18 | "(3)在本地进行软件开发,并进行软件开发过程管理。\n", 19 | "\n", 20 | "(4)将本地软件开发过程管理同步到gitee上,用于备份。\n", 21 | "\n", 22 | "(5)最新修改不合适,进行版本回退。\n", 23 | "\n", 24 | "通过上述步骤,你理解了git的基本使用方式,gitee软件托管的意义,可以使用git进行初步软件管理了,想获取更多git使用,请参见廖雪峰老师的git教程:https://www.liaoxuefeng.com/wiki/896043488029600 。" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "# 使用到的指令\n", 32 | "git clone 填写自己的仓库地址 //从远端克隆自己新建的软件工程\n", 33 | "\n", 34 | "git push origin 填写自己开发库名称,输入账户和密码 //即可将开发库推送到远程仓库\n", 35 | "\n", 36 | "git diff //查看本地开发中修改的信息\n", 37 | "\n", 38 | "git status //查看当前新增的文件等\n", 39 | "\n", 40 | "git add -A //将修改提交到暂存库中\n", 41 | "\n", 42 | "git commit -m \"添加本次修改的备注\" //将暂存库中的修改信息提交库中\n", 43 | "\n", 44 | "git push origin master //将修改提交的远程库中" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [] 53 | } 54 | ], 55 | "metadata": { 56 | "kernelspec": { 57 | "display_name": "Python 3", 58 | "language": "python", 59 | "name": "python3" 60 | }, 61 | "language_info": { 62 | "codemirror_mode": { 63 | "name": "ipython", 64 | "version": 3 65 | }, 66 | "file_extension": ".py", 67 | "mimetype": "text/x-python", 68 | "name": "python", 69 | "nbconvert_exporter": "python", 70 | "pygments_lexer": "ipython3", 71 | "version": "3.7.3" 72 | } 73 | }, 74 | "nbformat": 4, 75 | "nbformat_minor": 1 76 | } 77 | -------------------------------------------------------------------------------- /15.是时候用git进行重新整理了/.ipynb_checkpoints/3.git+github软件托管平台,进行软件开发-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# git+github软件过程管理工作流程\n", 10 | "关于git+github的软件过程管理有很多种使用方式,我介绍下我一直在使用的工作流程。这里介绍我工作流程的前半部分,简单的软件过程管理;后半部分,软件过程的三库管理(开发库、受控库、产皮库)将在《动手学树莓派-python下篇》中介绍。\n", 11 | "\n", 12 | "当前课程,主要介绍下述内容:\n", 13 | "\n", 14 | "(1)在github上建立软件库。\n", 15 | "\n", 16 | "(2)在本地下载(克隆)github上的软件库。\n", 17 | "\n", 18 | "(3)在本地进行软件开发,并进行软件开发过程管理。\n", 19 | "\n", 20 | "(4)将本地软件开发过程管理同步到github上,用于备份。\n", 21 | "\n", 22 | "(5)最新修改不合适,进行版本回退。\n", 23 | "\n", 24 | "通过上述步骤,你理解了git的基本使用方式,github软件托管的意义,可以使用git进行初步软件管理了,想获取更多git使用,请参见廖雪峰老师的git教程:https://www.liaoxuefeng.com/wiki/896043488029600 。" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "# 使用到的指令\n", 32 | "git clone 填写自己的仓库地址 //从远端克隆自己新建的软件工程\n", 33 | "\n", 34 | "git push origin 填写自己开发库名称,输入账户和密码 //即可将开发库推送到远程仓库\n", 35 | "\n", 36 | "git diff //查看本地开发中修改的信息\n", 37 | "\n", 38 | "git status //查看当前新增的文件等\n", 39 | "\n", 40 | "git add -A //将修改提交到暂存库中\n", 41 | "\n", 42 | "git commit -m \"添加本次修改的备注\" //将暂存库中的修改信息提交库中\n", 43 | "\n", 44 | "git push origin master //将修改提交的远程库中" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [] 53 | } 54 | ], 55 | "metadata": { 56 | "kernelspec": { 57 | "display_name": "Python 3", 58 | "language": "python", 59 | "name": "python3" 60 | }, 61 | "language_info": { 62 | "codemirror_mode": { 63 | "name": "ipython", 64 | "version": 3 65 | }, 66 | "file_extension": ".py", 67 | "mimetype": "text/x-python", 68 | "name": "python", 69 | "nbconvert_exporter": "python", 70 | "pygments_lexer": "ipython3", 71 | "version": "3.7.3" 72 | } 73 | }, 74 | "nbformat": 4, 75 | "nbformat_minor": 1 76 | } 77 | -------------------------------------------------------------------------------- /15.是时候用git进行重新整理了/1.git软件工具介绍.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# Git介绍\n", 10 | "下面是百度百科的介绍:https://baike.baidu.com/item/GIT/12647237?fr=aladdin\n", 11 | "\n", 12 | "Git(读音为/gɪt/。)是一个开源的分布式版本控制系统,可以有效、高速地处理从很小到非常大的项目版本管理。 [1] Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。\n", 13 | "\n", 14 | "Git的诞生(摘抄自廖雪峰老师的git教程):https://www.liaoxuefeng.com/wiki/896043488029600/896202815778784\n", 15 | "\n", 16 | "很多人都知道,Linus在1991年创建了开源的Linux,从此,Linux系统不断发展,已经成为最大的服务器系统软件了。\n", 17 | "\n", 18 | "Linus虽然创建了Linux,但Linux的壮大是靠全世界热心的志愿者参与的,这么多人在世界各地为Linux编写代码,那Linux的代码是如何管理的呢?\n", 19 | "\n", 20 | "事实是,在2002年以前,世界各地的志愿者把源代码文件通过diff的方式发给Linus,然后由Linus本人通过手工方式合并代码!\n", 21 | "\n", 22 | "你也许会想,为什么Linus不把Linux代码放到版本控制系统里呢?不是有CVS、SVN这些免费的版本控制系统吗?因为Linus坚定地反对CVS和SVN,这些集中式的版本控制系统不但速度慢,而且必须联网才能使用。有一些商用的版本控制系统,虽然比CVS、SVN好用,但那是付费的,和Linux的开源精神不符。\n", 23 | "\n", 24 | "不过,到了2002年,Linux系统已经发展了十年了,代码库之大让Linus很难继续通过手工方式管理了,社区的弟兄们也对这种方式表达了强烈不满,于是Linus选择了一个商业的版本控制系统BitKeeper,BitKeeper的东家BitMover公司出于人道主义精神,授权Linux社区免费使用这个版本控制系统。\n", 25 | "\n", 26 | "安定团结的大好局面在2005年就被打破了,原因是Linux社区牛人聚集,不免沾染了一些梁山好汉的江湖习气。开发Samba的Andrew试图破解BitKeeper的协议(这么干的其实也不只他一个),被BitMover公司发现了(监控工作做得不错!),于是BitMover公司怒了,要收回Linux社区的免费使用权。\n", 27 | "\n", 28 | "Linus可以向BitMover公司道个歉,保证以后严格管教弟兄们,嗯,这是不可能的。实际情况是这样的:\n", 29 | "\n", 30 | "Linus花了两周时间自己用C写了一个分布式版本控制系统,这就是Git!一个月之内,Linux系统的源码已经由Git管理了!牛是怎么定义的呢?大家可以体会一下。\n", 31 | "\n", 32 | "Git迅速成为最流行的分布式版本控制系统,尤其是2008年,GitHub网站上线了,它为开源项目免费提供Git存储,无数开源项目开始迁移至GitHub,包括jQuery,PHP,Ruby等等。\n", 33 | "\n", 34 | "历史就是这么偶然,如果不是当年BitMover公司威胁Linux社区,可能现在我们就没有免费而超级好用的Git了。\n", 35 | "\n", 36 | "Git如果您想掌握更多git技巧,请参见廖雪峰老师的git教程:https://www.liaoxuefeng.com/wiki/896043488029600\n" 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": {}, 42 | "source": [ 43 | "# Gitee和Github\n", 44 | "git是版本管理工具,用于管理本地软件开发流程,虽然git是分布式版本管理器,但也需要中心节点用于软件托管,但仅仅是软件的暂存而已。\n", 45 | "\n", 46 | "gitee和github就是这样的专业的软件托管服务器。区别就是,gitee是国内的,github是美国的。为以防万一,我们可以将已在github上托管的软件,同时在gitee上进行托管,用于备份。" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": null, 52 | "metadata": { 53 | "collapsed": true 54 | }, 55 | "outputs": [], 56 | "source": [] 57 | } 58 | ], 59 | "metadata": { 60 | "kernelspec": { 61 | "display_name": "Python 3", 62 | "language": "python", 63 | "name": "python3" 64 | }, 65 | "language_info": { 66 | "codemirror_mode": { 67 | "name": "ipython", 68 | "version": 3 69 | }, 70 | "file_extension": ".py", 71 | "mimetype": "text/x-python", 72 | "name": "python", 73 | "nbconvert_exporter": "python", 74 | "pygments_lexer": "ipython3", 75 | "version": "3.7.3" 76 | } 77 | }, 78 | "nbformat": 4, 79 | "nbformat_minor": 1 80 | } 81 | -------------------------------------------------------------------------------- /15.是时候用git进行重新整理了/2.git+gitee软件托管平台,进行软件开发.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# git+gitee软件过程管理工作流程\n", 10 | "关于git+gitee的软件过程管理有很多种使用方式,我介绍下我一直在使用的工作流程。这里介绍我工作流程的前半部分,简单的软件过程管理;后半部分,软件过程的三库管理(开发库、受控库、产皮库)将在《动手学树莓派-python下篇》中介绍。\n", 11 | "\n", 12 | "当前课程,主要介绍下述内容:\n", 13 | "\n", 14 | "(1)在gitee上建立软件库。\n", 15 | "\n", 16 | "(2)在本地下载(克隆)gitee上的软件库。\n", 17 | "\n", 18 | "(3)在本地进行软件开发,并进行软件开发过程管理。\n", 19 | "\n", 20 | "(4)将本地软件开发过程管理同步到gitee上,用于备份。\n", 21 | "\n", 22 | "(5)最新修改不合适,进行版本回退。\n", 23 | "\n", 24 | "通过上述步骤,你理解了git的基本使用方式,gitee软件托管的意义,可以使用git进行初步软件管理了,想获取更多git使用,请参见廖雪峰老师的git教程:https://www.liaoxuefeng.com/wiki/896043488029600 。" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "# 使用到的指令\n", 32 | "git clone 填写自己的仓库地址 //从远端克隆自己新建的软件工程\n", 33 | "\n", 34 | "git push origin 填写自己开发库名称,输入账户和密码 //即可将开发库推送到远程仓库\n", 35 | "\n", 36 | "git diff //查看本地开发中修改的信息\n", 37 | "\n", 38 | "git status //查看当前新增的文件等\n", 39 | "\n", 40 | "git add -A //将修改提交到暂存库中\n", 41 | "\n", 42 | "git commit -m \"添加本次修改的备注\" //将暂存库中的修改信息提交库中\n", 43 | "\n", 44 | "git push origin master //将修改提交的远程库中" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [] 53 | } 54 | ], 55 | "metadata": { 56 | "kernelspec": { 57 | "display_name": "Python 3", 58 | "language": "python", 59 | "name": "python3" 60 | }, 61 | "language_info": { 62 | "codemirror_mode": { 63 | "name": "ipython", 64 | "version": 3 65 | }, 66 | "file_extension": ".py", 67 | "mimetype": "text/x-python", 68 | "name": "python", 69 | "nbconvert_exporter": "python", 70 | "pygments_lexer": "ipython3", 71 | "version": "3.7.3" 72 | } 73 | }, 74 | "nbformat": 4, 75 | "nbformat_minor": 1 76 | } 77 | -------------------------------------------------------------------------------- /15.是时候用git进行重新整理了/3.git+github软件托管平台,进行软件开发.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# git+github软件过程管理工作流程\n", 10 | "关于git+github的软件过程管理有很多种使用方式,我介绍下我一直在使用的工作流程。这里介绍我工作流程的前半部分,简单的软件过程管理;后半部分,软件过程的三库管理(开发库、受控库、产皮库)将在《动手学树莓派-python下篇》中介绍。\n", 11 | "\n", 12 | "当前课程,主要介绍下述内容:\n", 13 | "\n", 14 | "(1)在github上建立软件库。\n", 15 | "\n", 16 | "(2)在本地下载(克隆)github上的软件库。\n", 17 | "\n", 18 | "(3)在本地进行软件开发,并进行软件开发过程管理。\n", 19 | "\n", 20 | "(4)将本地软件开发过程管理同步到github上,用于备份。\n", 21 | "\n", 22 | "(5)最新修改不合适,进行版本回退。\n", 23 | "\n", 24 | "通过上述步骤,你理解了git的基本使用方式,github软件托管的意义,可以使用git进行初步软件管理了,想获取更多git使用,请参见廖雪峰老师的git教程:https://www.liaoxuefeng.com/wiki/896043488029600 。" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "# 使用到的指令\n", 32 | "git clone 填写自己的仓库地址 //从远端克隆自己新建的软件工程\n", 33 | "\n", 34 | "git push origin 填写自己开发库名称,输入账户和密码 //即可将开发库推送到远程仓库\n", 35 | "\n", 36 | "git diff //查看本地开发中修改的信息\n", 37 | "\n", 38 | "git status //查看当前新增的文件等\n", 39 | "\n", 40 | "git add -A //将修改提交到暂存库中\n", 41 | "\n", 42 | "git commit -m \"添加本次修改的备注\" //将暂存库中的修改信息提交库中\n", 43 | "\n", 44 | "git push origin master //将修改提交的远程库中" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [] 53 | } 54 | ], 55 | "metadata": { 56 | "kernelspec": { 57 | "display_name": "Python 3", 58 | "language": "python", 59 | "name": "python3" 60 | }, 61 | "language_info": { 62 | "codemirror_mode": { 63 | "name": "ipython", 64 | "version": 3 65 | }, 66 | "file_extension": ".py", 67 | "mimetype": "text/x-python", 68 | "name": "python", 69 | "nbconvert_exporter": "python", 70 | "pygments_lexer": "ipython3", 71 | "version": "3.7.3" 72 | } 73 | }, 74 | "nbformat": 4, 75 | "nbformat_minor": 1 76 | } 77 | -------------------------------------------------------------------------------- /16.结束了吗?没有啊,下篇更精彩:)/.ipynb_checkpoints/1.下篇会有什么_-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# 你可以愉快的玩耍树莓派了\n", 10 | "到此,您已经完成《动手学树莓派——python上篇》旅程了,可以初步理解操作系统提供的任务服务了,咱们也探索了一番NXEZ“树莓派瑞士军刀扩展板卡”,如果你觉得意犹未尽,可以尝试尝试树莓派实验室(http://shumeipai.nxez.com/) 其他好玩的项目。" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": {}, 16 | "source": [ 17 | "# 打开武林之宝“九阴真经”,开启上乘“武功”的修改\n", 18 | "我们的九阴真经可不止上下卷,是一整套的,满足你从外功到内功的修炼。如果计算机系统是您最爱的“大玩具”,您想深入其中,把它当做您毕生的事业,好的,我来推荐内功心法第一卷了:\n", 19 | "\n", 20 | "(1)《深入理解计算机系统(第三版)》,作者:(美)兰德尔 E.布莱恩特(Randal E.Bryant)等,机械工业出版社出版。\n", 21 | "\n", 22 | "(2)《操作系统:精髓与设计原理(第6版)》,作者:斯托林斯(William Stallings),机械工业出版社出版。\n", 23 | "\n", 24 | "(3)《计算机网络(第5版)》,作者:[美] 特南鲍姆,[美] 韦瑟罗尔 著,清华大学出版社出版。\n", 25 | "\n", 26 | "(4)《计算机网络:系统方法(第5版)》,作者:美 拉里 L 彼得森 Larry L 著,机械工业出版社出版。\n", 27 | "\n", 28 | "(5)《Python学习手册(第5版)》,作者:马克·卢茨(Mark Lutz) 著,机械工业出版社出版。\n", 29 | "\n", 30 | "(6)《Python编程(第4版)》,作者:[美] Mark Lutz(马克·卢茨) 著,中国电力出版社出版。\n", 31 | "\n", 32 | "这套内功心法,可以让您拨开云雾,看到属于你的计算机世界。推荐购买正版图书,尊敬创作者的同时,也可保护您的眼睛。" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "# 还有《动手学树莓派——python下篇》?!\n", 40 | "\n", 41 | "下篇会在4G版树莓派4B上进行,毕竟现在是4B的时代,当然您的树莓派3B+不用吃灰,我同时会在树莓派3B+上做验证,保证最大程度的兼容性。\n", 42 | "\n", 43 | "别小看了树莓派,就像“1.2 成为时代的弄潮儿,不做局外人”节所讲到了,不止有python篇,还有c语言篇、内核驱动篇、内核核心篇...等。\n", 44 | "\n", 45 | "“别扯这么多了,我关心的是《动手学树莓派——python下篇》!”\n", 46 | "\n", 47 | "好的,那我就提前透露,《动手学树莓派——python下篇》包含以下内容:\n", 48 | "\n", 49 | "(1)NXEZ树莓派瑞士军刀扩展板卡,实时时钟的提供方法。\n", 50 | "\n", 51 | "(2)NXEZ树莓派瑞士军刀扩展板卡,拨码开关的提供方法。\n", 52 | "\n", 53 | "(3)到此,扩展板卡的外设都演示完了,是不是感觉很虚,那就看看在python中,我们怎么实现的外设方法。将深入到SAKS SDK中一探LED灯、数码管、蜂鸣器、按键、温度传感器、拨码开关和实时时钟实现方式。\n", 54 | "\n", 55 | "(4)使用git+gitee进行软件过程三库管理(开发库、受控库、产品库),开始真正的软件开发。\n", 56 | "\n", 57 | "(5)我们利用RPi.GPIO包,来一场从python到内核驱动的刺激之旅,瞻仰下您在pyhon中的一个小调用,是如何传递到具体的硬件上的。\n", 58 | "\n", 59 | "(6)文件存储,我们看看如何将我们采集的温度进行记录在树莓派本地的SD卡上,感受下“一切皆文件”的便利。\n", 60 | "\n", 61 | "(7)数据只在本地存储多麻烦啊,每次都要拿回来拷数据!别着急,我们有套接字方法,将数据实时传送,也有FTP服务器,直接拷贝文件。\n", 62 | "\n", 63 | "(8)网络现在用的这么普遍,那不如用树莓派来一场网络应用层API的探索,看看如果使用TCP和UDP进行数据通信。\n", 64 | "\n", 65 | "(9)GUI设计我真没做过,但可以使用B/S模式,让浏览器当我们的图形界面显示,本地、远端都可显示:)。\n", 66 | "\n", 67 | "(10)最激动人心的时刻,我将在树莓派4B上,安装摄像头,用Movidius2加速目标检测,我们看看如果将将别人的模型修改成自己的模型,并用Movidius2加速目标检测速率,让树莓派有一颗聪明的大脑。关注“小R科技机器人”很久了,看看后期买个小车,我也让小车变成我的WALL-E(瓦力)。" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": null, 73 | "metadata": { 74 | "collapsed": true 75 | }, 76 | "outputs": [], 77 | "source": [] 78 | } 79 | ], 80 | "metadata": { 81 | "kernelspec": { 82 | "display_name": "Python 3", 83 | "language": "python", 84 | "name": "python3" 85 | }, 86 | "language_info": { 87 | "codemirror_mode": { 88 | "name": "ipython", 89 | "version": 3 90 | }, 91 | "file_extension": ".py", 92 | "mimetype": "text/x-python", 93 | "name": "python", 94 | "nbconvert_exporter": "python", 95 | "pygments_lexer": "ipython3", 96 | "version": "3.7.3" 97 | } 98 | }, 99 | "nbformat": 4, 100 | "nbformat_minor": 1 101 | } 102 | -------------------------------------------------------------------------------- /16.结束了吗?没有啊,下篇更精彩:)/1.下篇会有什么_.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# 你可以愉快的玩耍树莓派了\n", 10 | "到此,您已经完成《动手学树莓派——python上篇》旅程了,可以初步理解操作系统提供的任务服务了,咱们也探索了一番NXEZ“树莓派瑞士军刀扩展板卡”,如果你觉得意犹未尽,可以尝试尝试树莓派实验室(http://shumeipai.nxez.com/) 其他好玩的项目。" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": {}, 16 | "source": [ 17 | "# 打开武林之宝“九阴真经”,开启上乘“武功”的修改\n", 18 | "我们的九阴真经可不止上下卷,是一整套的,满足你从外功到内功的修炼。如果计算机系统是您最爱的“大玩具”,您想深入其中,把它当做您毕生的事业,好的,我来推荐内功心法第一卷了:\n", 19 | "\n", 20 | "(1)《深入理解计算机系统(第三版)》,作者:(美)兰德尔 E.布莱恩特(Randal E.Bryant)等,机械工业出版社出版。\n", 21 | "\n", 22 | "(2)《操作系统:精髓与设计原理(第6版)》,作者:斯托林斯(William Stallings),机械工业出版社出版。\n", 23 | "\n", 24 | "(3)《计算机网络(第5版)》,作者:[美] 特南鲍姆,[美] 韦瑟罗尔 著,清华大学出版社出版。\n", 25 | "\n", 26 | "(4)《计算机网络:系统方法(第5版)》,作者:美 拉里 L 彼得森 Larry L 著,机械工业出版社出版。\n", 27 | "\n", 28 | "(5)《Python学习手册(第5版)》,作者:马克·卢茨(Mark Lutz) 著,机械工业出版社出版。\n", 29 | "\n", 30 | "(6)《Python编程(第4版)》,作者:[美] Mark Lutz(马克·卢茨) 著,中国电力出版社出版。\n", 31 | "\n", 32 | "这套内功心法,可以让您拨开云雾,看到属于你的计算机世界。推荐购买正版图书,尊敬创作者的同时,也可保护您的眼睛。" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "# 还有《动手学树莓派——python下篇》?!\n", 40 | "\n", 41 | "下篇会在4G版树莓派4B上进行,毕竟现在是4B的时代,当然您的树莓派3B+不用吃灰,我同时会在树莓派3B+上做验证,保证最大程度的兼容性。\n", 42 | "\n", 43 | "别小看了树莓派,就像“1.2 成为时代的弄潮儿,不做局外人”节所讲到了,不止有python篇,还有c语言篇、内核驱动篇、内核核心篇...等。\n", 44 | "\n", 45 | "“别扯这么多了,我关心的是《动手学树莓派——python下篇》!”\n", 46 | "\n", 47 | "好的,那我就提前透露,《动手学树莓派——python下篇》包含以下内容:\n", 48 | "\n", 49 | "(1)NXEZ树莓派瑞士军刀扩展板卡,实时时钟的提供方法。\n", 50 | "\n", 51 | "(2)NXEZ树莓派瑞士军刀扩展板卡,拨码开关的提供方法。\n", 52 | "\n", 53 | "(3)到此,扩展板卡的外设都演示完了,是不是感觉很虚,那就看看在python中,我们怎么实现的外设方法。将深入到SAKS SDK中一探LED灯、数码管、蜂鸣器、按键、温度传感器、拨码开关和实时时钟实现方式。\n", 54 | "\n", 55 | "(4)使用git+gitee进行软件过程三库管理(开发库、受控库、产品库),开始真正的软件开发。\n", 56 | "\n", 57 | "(5)我们利用RPi.GPIO包,来一场从python到内核驱动的刺激之旅,瞻仰下您在pyhon中的一个小调用,是如何传递到具体的硬件上的。\n", 58 | "\n", 59 | "(6)文件存储,我们看看如何将我们采集的温度进行记录在树莓派本地的SD卡上,感受下“一切皆文件”的便利。\n", 60 | "\n", 61 | "(7)数据只在本地存储多麻烦啊,每次都要拿回来拷数据!别着急,我们有套接字方法,将数据实时传送,也有FTP服务器,直接拷贝文件。\n", 62 | "\n", 63 | "(8)网络现在用的这么普遍,那不如用树莓派来一场网络应用层API的探索,看看如果使用TCP和UDP进行数据通信。\n", 64 | "\n", 65 | "(9)GUI设计我真没做过,但可以使用B/S模式,让浏览器当我们的图形界面显示,本地、远端都可显示:)。\n", 66 | "\n", 67 | "(10)最激动人心的时刻,我将在树莓派4B上,安装摄像头,用Movidius2加速目标检测,我们看看如果将将别人的模型修改成自己的模型,并用Movidius2加速目标检测速率,让树莓派有一颗聪明的大脑。关注“小R科技机器人”很久了,看看后期买个小车,我也让小车变成我的WALL-E(瓦力)。" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": null, 73 | "metadata": { 74 | "collapsed": true 75 | }, 76 | "outputs": [], 77 | "source": [] 78 | } 79 | ], 80 | "metadata": { 81 | "kernelspec": { 82 | "display_name": "Python 3", 83 | "language": "python", 84 | "name": "python3" 85 | }, 86 | "language_info": { 87 | "codemirror_mode": { 88 | "name": "ipython", 89 | "version": 3 90 | }, 91 | "file_extension": ".py", 92 | "mimetype": "text/x-python", 93 | "name": "python", 94 | "nbconvert_exporter": "python", 95 | "pygments_lexer": "ipython3", 96 | "version": "3.7.3" 97 | } 98 | }, 99 | "nbformat": 4, 100 | "nbformat_minor": 1 101 | } 102 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 动手学树莓派_python篇 2 | 3 | #### 介绍 4 | 系统和软件安装太费劲了吧,跑了个流水灯就吃灰了吧, 5 | 来吧跟我一起来趟树莓派之旅 6 | 本课程使用python快速玩转树莓派,不是单单的例程安装和演示; 7 | 我们可以近距离看看树莓派。 8 | 9 | #### 使用说明 10 | 11 | 1. 参考树莓派安装说明,使用tf卡读卡器烧写就行。 12 | 2. 集成开发环境怎么搭建?想太多了,浏览器会用吧,就是他,其他我还不教来。 13 | 14 | 15 | #### 捐助 16 | 17 | 如果您觉得我们的开源软件对你有所帮助,请扫下方二维码打赏我们一杯咖啡。 18 |  -------------------------------------------------------------------------------- /赠言——我都可以,您一定比我强多了/picture/my_books.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srf1986/easy_raspi_python_one/843e44a349f5518833a8eea5ca18af0819c5999d/赠言——我都可以,您一定比我强多了/picture/my_books.jpg --------------------------------------------------------------------------------