| New file |
| | |
| | | set(COMPONENT_SRCDIRS src |
| | | ) |
| | | |
| | | set(COMPONENT_ADD_INCLUDEDIRS src) |
| | | |
| | | set(COMPONENT_PRIV_INCLUDEDIRS src |
| | | ) |
| | | |
| | | set(COMPONENT_PRIV_REQUIRES arduino) |
| | | |
| | | register_component() |
| | |
| | | |
| | | LED发光二极管控制库 |
| | | |
| | | # LedShow发光二极管控制类使用说明 |
| | | |
| | | <a name="RKKnO"></a> |
| | | ## 引脚定义 |
| | | |
| | | ```cpp |
| | | #define BUTTON_PIN_PIO_LED 10 //M5StickC自带的LED二极管引脚 |
| | | ``` |
| | | |
| | | <a name="FRrD8"></a> |
| | | ## 声明控制类的实列 |
| | | |
| | | ```cpp |
| | | LedShow Ledshow(BUTTON_PIN_PIO_LED); // 声明一个led灯的实例,并传入led GIO的引脚 |
| | | ``` |
| | | |
| | | <a name="Tta1V"></a> |
| | | ## setup初始化 |
| | | |
| | | ```cpp |
| | | Ledshow.init(); // led管理初始化 |
| | | Ledshow.setOff(); // 初始化时关闭LED |
| | | ``` |
| | | |
| | | <a name="4n0I8"></a> |
| | | ## loop或其它地方 |
| | | |
| | | ```cpp |
| | | Ledshow.setOn(); //打开 |
| | | |
| | | |
| | | //获取当前时间,进行二给管闪烁 |
| | | Ledshow.ledflashing(millis(),HOLDTIME_NORMAL); |
| | | |
| | | ``` |
| New file |
| | |
| | | name=LedShow |
| | | version=1.0.1 |
| | | author=phoenix |
| | | maintainer=phoenix <spd260@126.com> |
| | | sentence=Arduino library for wifi LedShow |
| | | paragraph=Arduino library for wifi LedShow. |
| | | category=Sensors |
| | | url=http://git.leon056.com/summary/arduino-libs%2FLedShow.git |
| | | architectures=* |
| New file |
| | |
| | | |
| | | #include "LedShow.h" |
| | | LedShow::LedShow(uint8_t inLedGpio) { |
| | | if (inLedGpio!=NULL) { |
| | | _LedGpio = inLedGpio; |
| | | } |
| | | } |
| | | |
| | | void LedShow::init() { |
| | | pinMode(_LedGpio, OUTPUT); |
| | | } |
| | | void LedShow::setOn() { |
| | | digitalWrite(_LedGpio, LOW); // 开LED |
| | | } |
| | | void LedShow::setOff(){ |
| | | digitalWrite(_LedGpio, HIGH); // 关LED |
| | | } |
| | | |
| | | /// led闪烁控制函数 |
| | | // int ricont=0; |
| | | // int jglast=0; |
| | | // int jgvalue=; |
| | | void LedShow::ledflashing(int inCurtime, int holdTimeTag){ |
| | | |
| | | if (inCurtime - pre_time> holdTimeTag ) //如果达到了指定的时间 |
| | | { |
| | | led_state=!led_state;//改变LED灯的状态 |
| | | pre_time=inCurtime;//将当前时间保存到初始的时间,准备进入下一轮循环 |
| | | } |
| | | digitalWrite(_LedGpio,led_state); |
| | | } |
| | | |
| | | |
| New file |
| | |
| | | /* |
| | | ledShow.h - Library for 控制LED |
| | | Created by phoenix, 2019.07.02. |
| | | |
| | | */ |
| | | |
| | | #ifndef _LedShow_H_ |
| | | #define _LedShow_H_ |
| | | |
| | | #include <Arduino.h> |
| | | #include <Wire.h> |
| | | |
| | | /// led闪烁的时间间隔快慢 |
| | | #define HOLDTIME_QUICKLY 500 |
| | | #define HOLDTIME_NORMAL 1000 |
| | | #define HOLDTIME_SLOW 2000 |
| | | |
| | | |
| | | |
| | | class LedShow |
| | | { |
| | | public: |
| | | LedShow(uint8_t inLedGpio=23); |
| | | void init(); |
| | | void setOn(); |
| | | void setOff(); |
| | | void ledflashing(int inCurtime, int holdTimeTag); |
| | | private: |
| | | uint8_t _LedGpio=10; |
| | | int pre_time=0; |
| | | int led_state=HIGH; //led初始状态为熄灭 |
| | | |
| | | }; |
| | | |
| | | #endif |