Detected people approaching if the distance is < 6 feet then LEDs blinking RED otherwise LEDs light green.
Dependencies: mbed X_NUCLEO_53L1A1_mbed WS2812
LED_WS2812/Pixel/PixelArray.h@2:28ca549860f6, 2020-11-01 (annotated)
- Committer:
- elab
- Date:
- Sun Nov 01 20:24:31 2020 +0000
- Revision:
- 2:28ca549860f6
- Parent:
- 0:ea8694e55809
deleted main.txt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elab | 0:ea8694e55809 | 1 | /* Copyright (c) 2012 cstyles, MIT License |
elab | 0:ea8694e55809 | 2 | * |
elab | 0:ea8694e55809 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
elab | 0:ea8694e55809 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
elab | 0:ea8694e55809 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
elab | 0:ea8694e55809 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
elab | 0:ea8694e55809 | 7 | * furnished to do so, subject to the following conditions: |
elab | 0:ea8694e55809 | 8 | * |
elab | 0:ea8694e55809 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
elab | 0:ea8694e55809 | 10 | * substantial portions of the Software. |
elab | 0:ea8694e55809 | 11 | * |
elab | 0:ea8694e55809 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
elab | 0:ea8694e55809 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
elab | 0:ea8694e55809 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
elab | 0:ea8694e55809 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
elab | 0:ea8694e55809 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
elab | 0:ea8694e55809 | 17 | */ |
elab | 0:ea8694e55809 | 18 | |
elab | 0:ea8694e55809 | 19 | #ifndef PixelArray_H |
elab | 0:ea8694e55809 | 20 | #define PixelArray_H |
elab | 0:ea8694e55809 | 21 | |
elab | 0:ea8694e55809 | 22 | #include "mbed.h" |
elab | 0:ea8694e55809 | 23 | |
elab | 0:ea8694e55809 | 24 | //!Library for the WS2812 RGB LED with integrated controller |
elab | 0:ea8694e55809 | 25 | /*! |
elab | 0:ea8694e55809 | 26 | PixelArray |
elab | 0:ea8694e55809 | 27 | */ |
elab | 0:ea8694e55809 | 28 | class PixelArray |
elab | 0:ea8694e55809 | 29 | { |
elab | 0:ea8694e55809 | 30 | public: |
elab | 0:ea8694e55809 | 31 | //!Creates an instance of the class. |
elab | 0:ea8694e55809 | 32 | /*! |
elab | 0:ea8694e55809 | 33 | Pixel Array |
elab | 0:ea8694e55809 | 34 | */ |
elab | 0:ea8694e55809 | 35 | PixelArray(int); |
elab | 0:ea8694e55809 | 36 | |
elab | 0:ea8694e55809 | 37 | /*! |
elab | 0:ea8694e55809 | 38 | Destroys instance. |
elab | 0:ea8694e55809 | 39 | */ |
elab | 0:ea8694e55809 | 40 | ~PixelArray(); |
elab | 0:ea8694e55809 | 41 | |
elab | 0:ea8694e55809 | 42 | int* getBuf(); |
elab | 0:ea8694e55809 | 43 | |
elab | 0:ea8694e55809 | 44 | void SetAll(unsigned int); |
elab | 0:ea8694e55809 | 45 | void SetAllI(unsigned char); |
elab | 0:ea8694e55809 | 46 | void SetAllR(unsigned char); |
elab | 0:ea8694e55809 | 47 | void SetAllG(unsigned char); |
elab | 0:ea8694e55809 | 48 | void SetAllB(unsigned char); |
elab | 0:ea8694e55809 | 49 | |
elab | 0:ea8694e55809 | 50 | // location, value |
elab | 0:ea8694e55809 | 51 | void Set(int, unsigned int); |
elab | 0:ea8694e55809 | 52 | void SetI(int, unsigned char); |
elab | 0:ea8694e55809 | 53 | void SetR(int, unsigned char); |
elab | 0:ea8694e55809 | 54 | void SetG(int, unsigned char); |
elab | 0:ea8694e55809 | 55 | void SetB(int, unsigned char); |
elab | 0:ea8694e55809 | 56 | |
elab | 0:ea8694e55809 | 57 | unsigned int Get(int); |
elab | 0:ea8694e55809 | 58 | unsigned int GetI(int); |
elab | 0:ea8694e55809 | 59 | unsigned int GetR(int); |
elab | 0:ea8694e55809 | 60 | unsigned int GetG(int); |
elab | 0:ea8694e55809 | 61 | unsigned int GetB(int); |
elab | 0:ea8694e55809 | 62 | |
elab | 0:ea8694e55809 | 63 | private: |
elab | 0:ea8694e55809 | 64 | |
elab | 0:ea8694e55809 | 65 | int *pbuf; |
elab | 0:ea8694e55809 | 66 | int pbufsize; |
elab | 0:ea8694e55809 | 67 | |
elab | 0:ea8694e55809 | 68 | void __set_pixel_component(int index, int channel, int value); |
elab | 0:ea8694e55809 | 69 | void __set_pixel(int index, int value); |
elab | 0:ea8694e55809 | 70 | |
elab | 0:ea8694e55809 | 71 | int __get_pixel_component(int index, int channel); |
elab | 0:ea8694e55809 | 72 | int __get_pixel(int index); |
elab | 0:ea8694e55809 | 73 | |
elab | 0:ea8694e55809 | 74 | }; |
elab | 0:ea8694e55809 | 75 | |
elab | 0:ea8694e55809 | 76 | #endif |
elab | 0:ea8694e55809 | 77 |