Skip to content

Instantly share code, notes, and snippets.

@wgbartley
Created November 12, 2015 04:49
Show Gist options
  • Save wgbartley/0a7212199ae7dadbfd47 to your computer and use it in GitHub Desktop.
Save wgbartley/0a7212199ae7dadbfd47 to your computer and use it in GitHub Desktop.
Quick NeoPixel test on Bluz
#include "application.h"
#include "pinmap_impl.h"
#include "neopixel.h"
#define STRIP_LENGTH 121
int PIXEL_PIN = PIN_MAP[D2].gpio_pin;
neopixel_strip_t m_strip;
uint8_t j;
uint8_t color[3] = {0, 0, 0};
uint8_t wait = 100;
void setup() {
BLE.stopAdvertising();
neopixel_init(&m_strip, PIXEL_PIN, STRIP_LENGTH);
neopixel_clear(&m_strip);
neopixel_show(&m_strip);
}
void loop() {
HAL_Delay_Milliseconds(wait);
Wheel(j);
for(uint8_t i=0; i<STRIP_LENGTH; i++)
neopixel_set_color(&m_strip, i, color[0]/2, color[1]/2, color[2]/2);
neopixel_show(&m_strip);
j++;
if(j>=255) j = 0;
}
void Wheel(byte WheelPos) {
if(WheelPos < 85) {
color[0] = WheelPos * 3;
color[1] = 255 - WheelPos * 3;
color[2] = 0;
} else if(WheelPos < 170) {
WheelPos -= 85;
color[0] = 255 - WheelPos * 3;
color[1] = 0;
color[2] = WheelPos * 3;
} else {
WheelPos -= 170;
color[0] = 0;
color[1] = WheelPos * 3;
color[2] = 255 - WheelPos * 3;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment