Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of rbVectorIQ by
neopixel.h
00001 /* Copyright (c) 2015 bickster, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00005 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00006 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00007 * furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 #ifndef NEOPIXEL_H 00019 #define NEOPIXEL_H 00020 00021 #include <stdbool.h> 00022 #include <stdint.h> 00023 00024 00025 //These defines are timed specific to a series of if statements and will need to be changed 00026 //to compensate for different writing algorithms than the one in neopixel.c 00027 #define NEOPIXEL_SEND_ONE NRF_GPIO->OUTSET = (1UL << PIN); \ 00028 NRF_GPIO->OUTSET = (1UL << PIN); \ 00029 NRF_GPIO->OUTSET = (1UL << PIN); \ 00030 NRF_GPIO->OUTCLR = (1UL << PIN); 00031 00032 #define NEOPIXEL_SEND_ZERO NRF_GPIO->OUTSET = (1UL << PIN); \ 00033 NRF_GPIO->OUTCLR = (1UL << PIN); \ 00034 NRF_GPIO->OUTCLR = (1UL << PIN); \ 00035 NRF_GPIO->OUTCLR = (1UL << PIN); \ 00036 NRF_GPIO->OUTCLR = (1UL << PIN); 00037 00038 typedef union { 00039 struct { 00040 uint8_t g, r, b; 00041 }simple; 00042 uint8_t grb[3]; 00043 } color_t; 00044 00045 typedef struct { 00046 uint8_t pin_num; 00047 uint16_t num_leds; 00048 color_t *leds; 00049 } neopixel_strip_t; 00050 00051 /** 00052 @brief Initialize GPIO and data location 00053 @param[in] pointer to Strip structure 00054 @param[in] pin number for GPIO 00055 */ 00056 void neopixel_init(neopixel_strip_t *strip, uint8_t pin_num, uint16_t num_leds); 00057 00058 /** 00059 @brief Turn all LEDs off 00060 @param[in] pointer to Strip structure 00061 */ 00062 void neopixel_clear(neopixel_strip_t *strip); 00063 00064 /** 00065 @brief Update strip with structure data 00066 @param[in] pointer to Strip structure 00067 */ 00068 void neopixel_show(neopixel_strip_t *strip); 00069 00070 /** 00071 @brief Write RGB value to LED structure 00072 @param[in] pointer to Strip structure 00073 @param[in] red value 00074 @param[in] green value 00075 @param[in] blue value 00076 @param[in] LED number (starting at 1) 00077 @retval 0 Successful write 00078 @retval 1 LED number is out of bounds 00079 */ 00080 uint8_t neopixel_set_color(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue ); 00081 00082 00083 /** 00084 @brief Write RGB value to LED structure and update LED 00085 @param[in] pointer to Strip structure 00086 @param[in] red value 00087 @param[in] green value 00088 @param[in] blue value 00089 @param[in] LED number (starting at 1) 00090 @retval 0 Successful write 00091 @retval 1 LED number is out of bounds 00092 */ 00093 uint8_t neopixel_set_color_and_show(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue); 00094 00095 /** 00096 @brief Clears structure data 00097 @param[in] pointer to Strip structure 00098 */ 00099 void neopixel_destroy(neopixel_strip_t *strip); 00100 00101 #endif
Generated on Tue Jul 12 2022 21:09:08 by
1.7.2
