This is a very simple guide, reviewing the steps required to get Blinky working on an Mbed OS platform.

Dependencies:   mbed Adafruit_GFX

Committer:
ParkChunMyong
Date:
Thu Jun 13 03:26:42 2019 +0000
Revision:
96:7465ab270e7a
Parent:
95:250afd53b710
first init

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ParkChunMyong 95:250afd53b710 1 /* Copyright (c) 2012 cstyles, MIT License
ParkChunMyong 95:250afd53b710 2 *
ParkChunMyong 95:250afd53b710 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ParkChunMyong 95:250afd53b710 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
ParkChunMyong 95:250afd53b710 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ParkChunMyong 95:250afd53b710 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ParkChunMyong 95:250afd53b710 7 * furnished to do so, subject to the following conditions:
ParkChunMyong 95:250afd53b710 8 *
ParkChunMyong 95:250afd53b710 9 * The above copyright notice and this permission notice shall be included in all copies or
ParkChunMyong 95:250afd53b710 10 * substantial portions of the Software.
ParkChunMyong 95:250afd53b710 11 *
ParkChunMyong 95:250afd53b710 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ParkChunMyong 95:250afd53b710 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ParkChunMyong 95:250afd53b710 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ParkChunMyong 95:250afd53b710 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ParkChunMyong 95:250afd53b710 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ParkChunMyong 95:250afd53b710 17 */
ParkChunMyong 95:250afd53b710 18
ParkChunMyong 95:250afd53b710 19 #ifndef WS2812_H
ParkChunMyong 95:250afd53b710 20 #define WS2812_H
ParkChunMyong 95:250afd53b710 21
ParkChunMyong 95:250afd53b710 22 #include "mbed.h"
ParkChunMyong 95:250afd53b710 23
ParkChunMyong 95:250afd53b710 24 #define FRAME_SIZE 24
ParkChunMyong 95:250afd53b710 25
ParkChunMyong 95:250afd53b710 26 //!Library for the WS2812 RGB LED with integrated controller
ParkChunMyong 95:250afd53b710 27 /*!
ParkChunMyong 95:250afd53b710 28 The WS2812 is controller that is built into a range of LEDs
ParkChunMyong 95:250afd53b710 29 */
ParkChunMyong 95:250afd53b710 30 class WS2812
ParkChunMyong 95:250afd53b710 31 {
ParkChunMyong 95:250afd53b710 32 public:
ParkChunMyong 95:250afd53b710 33 enum BrightnessControl { OFF, GLOBAL, PER_PIXEL };
ParkChunMyong 95:250afd53b710 34
ParkChunMyong 95:250afd53b710 35 /**
ParkChunMyong 95:250afd53b710 36 * Constructor
ParkChunMyong 95:250afd53b710 37 *
ParkChunMyong 95:250afd53b710 38 * @param pin Output pin. Connect to "Din" on the first WS2812 in the strip
ParkChunMyong 95:250afd53b710 39 * @param size Number of LEDs in your strip
ParkChunMyong 95:250afd53b710 40 * @param zeroHigh How many NOPs to insert to ensure TOH is properly generated. See library description for more information.
ParkChunMyong 95:250afd53b710 41 * @param zeroLow How many NOPs to insert to ensure TOL is properly generated. See library description for more information.
ParkChunMyong 95:250afd53b710 42 * @param oneHigh How many NOPs to insert to ensure T1H is properly generated. See library description for more information.
ParkChunMyong 95:250afd53b710 43 * @param oneLow How many NOPs to insert to ensure T1L is properly generated. See library description for more information.
ParkChunMyong 95:250afd53b710 44 *
ParkChunMyong 95:250afd53b710 45 */
ParkChunMyong 95:250afd53b710 46 WS2812(PinName pin, int size, int zeroHigh, int zeroLow, int oneHigh, int oneLow);
ParkChunMyong 95:250afd53b710 47
ParkChunMyong 95:250afd53b710 48 /*!
ParkChunMyong 95:250afd53b710 49 Destroys instance.
ParkChunMyong 95:250afd53b710 50 */
ParkChunMyong 95:250afd53b710 51 ~WS2812();
ParkChunMyong 95:250afd53b710 52
ParkChunMyong 95:250afd53b710 53 /**
ParkChunMyong 95:250afd53b710 54 * Sets the timing parameters for the bit-banged signal
ParkChunMyong 95:250afd53b710 55 *
ParkChunMyong 95:250afd53b710 56 * @param zeroHigh How many NOPs to insert to ensure TOH is properly generated. See library description for more information.
ParkChunMyong 95:250afd53b710 57 * @param zeroLow How many NOPs to insert to ensure TOL is properly generated. See library description for more information.
ParkChunMyong 95:250afd53b710 58 * @param oneHigh How many NOPs to insert to ensure T1H is properly generated. See library description for more information.
ParkChunMyong 95:250afd53b710 59 * @param oneLow How many NOPs to insert to ensure T1L is properly generated. See library description for more information.
ParkChunMyong 95:250afd53b710 60 *
ParkChunMyong 95:250afd53b710 61 */
ParkChunMyong 95:250afd53b710 62 void setDelays(int zeroHigh, int zeroLow, int oneHigh, int oneLow);
ParkChunMyong 95:250afd53b710 63
ParkChunMyong 95:250afd53b710 64 /**
ParkChunMyong 95:250afd53b710 65 * Writes the given buffer to the LED strip with the given offsets.
ParkChunMyong 95:250afd53b710 66 * NOTE: This function is timing critical, therefore interrupts are disabled during the transmission section.
ParkChunMyong 95:250afd53b710 67 *
ParkChunMyong 95:250afd53b710 68 * @param buf Pointer to the PixelArray buffer
ParkChunMyong 95:250afd53b710 69 * @param r_offset The offset where each each pixel pulls its red component. Wraps to beginning if end is reached.
ParkChunMyong 95:250afd53b710 70 * @param g_offset The offset where each each pixel pulls its green component. Wraps to beginning if end is reached.
ParkChunMyong 95:250afd53b710 71 * @param b_offset The offset where each each pixel pulls its blue component. Wraps to beginning if end is reached.
ParkChunMyong 95:250afd53b710 72 *
ParkChunMyong 95:250afd53b710 73 */
ParkChunMyong 95:250afd53b710 74 void write_offsets(int buf[], int r_offset = 0, int g_offset = 0, int b_offset = 0);
ParkChunMyong 95:250afd53b710 75
ParkChunMyong 95:250afd53b710 76
ParkChunMyong 95:250afd53b710 77 /**
ParkChunMyong 95:250afd53b710 78 * Writes the given buffer to the LED strip
ParkChunMyong 95:250afd53b710 79 * NOTE: This function is timing critical, therefore interrupts are disabled during the transmission section.
ParkChunMyong 95:250afd53b710 80 *
ParkChunMyong 95:250afd53b710 81 * @param buf Pointer to the PixelArray buffer
ParkChunMyong 95:250afd53b710 82 *
ParkChunMyong 95:250afd53b710 83 */
ParkChunMyong 95:250afd53b710 84 void write(int buf[]);
ParkChunMyong 95:250afd53b710 85
ParkChunMyong 95:250afd53b710 86 /**
ParkChunMyong 95:250afd53b710 87 * Sets the brightness mode
ParkChunMyong 95:250afd53b710 88 *
ParkChunMyong 95:250afd53b710 89 * @param bc The brightness control. Defaults to OFF. Possible values include OFF, GLOBAL, and PER_PIXEL
ParkChunMyong 95:250afd53b710 90 *
ParkChunMyong 95:250afd53b710 91 */
ParkChunMyong 95:250afd53b710 92 void useII(BrightnessControl bc);
ParkChunMyong 95:250afd53b710 93
ParkChunMyong 95:250afd53b710 94 /**
ParkChunMyong 95:250afd53b710 95 * Sets the global brightness level.
ParkChunMyong 95:250afd53b710 96 *
ParkChunMyong 95:250afd53b710 97 * @param II The brightness level. Possible values include 0 - 255 (0x00 - 0xFF).
ParkChunMyong 95:250afd53b710 98 *
ParkChunMyong 95:250afd53b710 99 */
ParkChunMyong 95:250afd53b710 100 void setII(unsigned char II);
ParkChunMyong 95:250afd53b710 101
ParkChunMyong 95:250afd53b710 102
ParkChunMyong 95:250afd53b710 103
ParkChunMyong 95:250afd53b710 104 private:
ParkChunMyong 95:250afd53b710 105
ParkChunMyong 95:250afd53b710 106 int __size;
ParkChunMyong 95:250afd53b710 107 int __zeroHigh, __zeroLow, __oneHigh, __oneLow;
ParkChunMyong 95:250afd53b710 108 unsigned char __II;
ParkChunMyong 95:250afd53b710 109 BrightnessControl __use_II;
ParkChunMyong 95:250afd53b710 110 bool *__transmitBuf;
ParkChunMyong 95:250afd53b710 111 void __loadBuf(int buf[],int r_offset=0, int g_offset=0, int b_offset=0);
ParkChunMyong 95:250afd53b710 112 PinName __outPin;
ParkChunMyong 95:250afd53b710 113 DigitalOut __gpo;
ParkChunMyong 95:250afd53b710 114 };
ParkChunMyong 95:250afd53b710 115
ParkChunMyong 95:250afd53b710 116 #endif