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.
main.cpp
00001 /* 00002 00003 Neopixel LED controller for mbed LPC1114 (RAMdaccha) 00004 00005 2014/12/13 by morecat_lab 00006 00007 This program depends on neopixel library. 00008 http://developer.mbed.org/users/JacobBramley/code/PixelArray/ 00009 00010 */ 00011 #include "mbed.h" 00012 #include "neopixel.h" 00013 #include "LAMd.h" 00014 00015 neopixel::Pixel pattern[] = { 00016 {0x55, 0, 0xff}, // magenta 00017 {0, 0, 0xff}, // blue 00018 {0xaf, 0xaf, 0xaf}, // white 00019 {0, 0xff, 0xff}, // cyan 00020 {0xaf, 0xaf, 0}, // yellow 00021 {0, 0xff, 0}, // greem 00022 {0x2f, 0, 0}, // red 00023 }; 00024 00025 #define MAX_PATTERN (sizeof pattern / sizeof (struct neopixel::Pixel)) 00026 #define MAX_INDEX (MAX_PATTERN *256) 00027 #define NLED (4) 00028 #define ONE_COLOR 00029 00030 void generate(neopixel::Pixel * out, uint32_t index, uintptr_t val) { 00031 #ifdef ONE_COLOR 00032 uint32_t pat1 = val / 256; 00033 #else 00034 uint32_t pat1 = val / 256 + index; 00035 #endif 00036 uint32_t pat2; 00037 uint32_t seq = val % 256; 00038 00039 if (pat1 >= MAX_PATTERN) { 00040 pat1 = 0; 00041 } 00042 pat2 = pat1 + 1; 00043 if (pat2 >= MAX_PATTERN) { 00044 pat2 = 0; 00045 } 00046 out->red = (pattern[pat1].red * (256-seq) + pattern[pat2].red * seq) /256; 00047 out->green = (pattern[pat1].green * (256-seq) + pattern[pat2].green * seq) /256; 00048 out->blue = (pattern[pat1].blue * (256-seq) + pattern[pat2].blue * seq) /256; 00049 } 00050 00051 00052 int main() { 00053 DigitalIn(D3, PullDown); 00054 neopixel::PixelArray array(D3); 00055 00056 uint32_t val = 0; 00057 while (1) { 00058 if ((++val) >= MAX_INDEX) { 00059 val = 0; 00060 } 00061 array.update(generate, NLED, val); 00062 wait_ms(10); 00063 } 00064 }
Generated on Wed Jul 13 2022 04:57:23 by
