RadiantRVA
/
rbVectorIQ
share for RS
Fork of rbVectorIQ by
patterns.cpp
- Committer:
- MarkSPA
- Date:
- 2016-12-09
- Revision:
- 6:074f5ec7428c
- Parent:
- 5:1f6311e0fc14
- Child:
- 7:0db51a3107fc
File content as of revision 6:074f5ec7428c:
#include "mbed.h" // remove line if not using mbed #include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include "nrf_delay.h" #include "nrf_gpio.h" #include "neopixel.h" // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(uint8_t WheelPos, neopixel_strip_t m_strip, uint8_t led_to_enable) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return neopixel_set_color(&m_strip, led_to_enable, 255 - WheelPos * 3, 0, WheelPos * 3); } if(WheelPos < 170) { WheelPos -= 85; return neopixel_set_color(&m_strip, 0, led_to_enable, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return neopixel_set_color(&m_strip, led_to_enable, WheelPos * 3, 255 - WheelPos * 3, 0); } void rainbowCycle(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) { uint16_t i, j; uint32_t ret; for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel for(i=0; i< numLEDs; i++) { //neopixel_set_color(&m_strip, i, red, green, blue); //strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); ret = Wheel(i, m_strip, ((i * 256 / numLEDs) + j & 255)); } neopixel_show(&m_strip); wait_ms(delay); } } void candyChase(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) { for (int i=0; i < numLEDs; i++) neopixel_set_color(&m_strip, i, 255,255,255); //turn every pixel white for (int i=0; i < numLEDs-1; i++) { neopixel_set_color(&m_strip, i, 255,255,255); neopixel_set_color(&m_strip, i+1, 255,0,0); //turn on a red pixel and move it neopixel_show(&m_strip); wait_ms(delay); } wait_ms(delay); for (int i=0; i < numLEDs; i++) neopixel_set_color(&m_strip, i, 255,0,0); //turn every pixel red for (int i=0; i < numLEDs-1; i++) { neopixel_set_color(&m_strip, i, 255,0,0); neopixel_set_color(&m_strip, i+1, 255,255,255); //turn on a white pixel and move it neopixel_show(&m_strip); wait_ms(delay); } } void snowflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) { for (int i=0; i < numLEDs; i++) neopixel_set_color(&m_strip, i, 0,0,235); //turn every pixel blue for (int i=0; i < numLEDs-1; i++) { neopixel_set_color(&m_strip, i, 0,0,235); neopixel_set_color(&m_strip, i+1, 255,255,255); //turn on a white pixel and move it neopixel_show(&m_strip); wait_ms(delay); } } void iceflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) { for (int i=0; i < numLEDs; i++) neopixel_set_color(&m_strip, i, 235,235,235); //turn every pixel white int led_to_enable = rand()%numLEDs; neopixel_set_color(&m_strip, led_to_enable, 0, 0, 235); // set random blue neopixel_show(&m_strip); wait_ms(delay); } void xmas(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) { //All green for (int j=0; j<numLEDs; j++) neopixel_set_color(&m_strip, j, 0,255,0); neopixel_show(&m_strip); wait_ms(500); //All red for (int j=0; j<numLEDs; j++) neopixel_set_color(&m_strip, j, 255,0,0); neopixel_show(&m_strip); wait_ms(delay); //Green with a red mover for (int j=0; j<numLEDs; j++) neopixel_set_color(&m_strip, j, 0,255,0); neopixel_show(&m_strip); wait_ms(500); for (int j=0; j<numLEDs; j++) { neopixel_set_color(&m_strip, j, 255,0,0); neopixel_show(&m_strip); wait_ms(delay); } //Red with a green mover for (int j=0; j<numLEDs; j++) neopixel_set_color(&m_strip, j, 255,0,0); neopixel_show(&m_strip); wait_ms(delay); for (int j=0; j<numLEDs; j++) { neopixel_set_color(&m_strip, j, 0,255,0); neopixel_show(&m_strip); wait_ms(delay); } }