partial
parent
4695c3ff01
commit
1bc9b09427
|
@ -0,0 +1 @@
|
||||||
|
node_modules/*
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include <WS2812.h>
|
||||||
|
#include <DigiCDC.h>
|
||||||
|
|
||||||
|
#define LEDCount 37
|
||||||
|
#define outputPin 1
|
||||||
|
WS2812 LED(LEDCount);
|
||||||
|
cRGB value;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
SerialUSB.begin();
|
||||||
|
LED.setOutput(outputPin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (SerialUSB.available() > 1 && SerialUSB.read() == 0x10) {
|
||||||
|
byte command = SerialUSB.read();
|
||||||
|
if (command == 0x11) {
|
||||||
|
LED.sync();
|
||||||
|
|
||||||
|
SerialUSB.write(0x1f);
|
||||||
|
}
|
||||||
|
else if (command == 0x12) {
|
||||||
|
while (SerialUSB.available() < 4) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int pos = SerialUSB.read();
|
||||||
|
value.r = SerialUSB.read();
|
||||||
|
value.g = SerialUSB.read();
|
||||||
|
value.b = SerialUSB.read();
|
||||||
|
|
||||||
|
LED.set_crgb_at(pos, value);
|
||||||
|
|
||||||
|
SerialUSB.write(0x1f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SerialUSB.write(0x1e);
|
||||||
|
}
|
||||||
|
SerialUSB.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"name": "USBStrip",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "USBStrip",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node index.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/ambrosechua/USBStrip.git"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.12.4",
|
||||||
|
"serialport": "^2.0.5"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,112 +0,0 @@
|
||||||
#include <Adafruit_NeoPixel.h>
|
|
||||||
|
|
||||||
#define PIN 6
|
|
||||||
#define NUMPIXELS 37
|
|
||||||
|
|
||||||
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
|
||||||
|
|
||||||
int delayval = 16;
|
|
||||||
|
|
||||||
bool off = false;
|
|
||||||
int brightness = 255;
|
|
||||||
int hue = 168;
|
|
||||||
int mode = 1;
|
|
||||||
|
|
||||||
int counter = 0;
|
|
||||||
|
|
||||||
uint32_t Wheel(byte WheelPos) {
|
|
||||||
WheelPos = 255 - WheelPos;
|
|
||||||
if(WheelPos < 85) {
|
|
||||||
return pixels.Color((255 - WheelPos * 3) * brightness / 255, 0, WheelPos * 3 * brightness / 255);
|
|
||||||
}
|
|
||||||
if(WheelPos < 170) {
|
|
||||||
WheelPos -= 85;
|
|
||||||
return pixels.Color(0, WheelPos * 3 * brightness / 255, (255 - WheelPos * 3) * brightness / 255);
|
|
||||||
}
|
|
||||||
WheelPos -= 170;
|
|
||||||
return pixels.Color(WheelPos * 3 * brightness / 255, (255 - WheelPos * 3) * brightness / 255, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
Serial.begin(9600);
|
|
||||||
pixels.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
|
|
||||||
if (off) {
|
|
||||||
|
|
||||||
for (int i = 0; i < NUMPIXELS; i++){
|
|
||||||
pixels.setPixelColor(i, pixels.Color(0,0,0));
|
|
||||||
}
|
|
||||||
pixels.show();
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
if (mode == 1) {
|
|
||||||
for (int i = 0; i < NUMPIXELS; i++){
|
|
||||||
pixels.setPixelColor(i, pixels.Color(0,0,brightness));
|
|
||||||
}
|
|
||||||
pixels.show();
|
|
||||||
}
|
|
||||||
else if (mode == 2) {
|
|
||||||
for (int i = 0; i < NUMPIXELS; i++){
|
|
||||||
pixels.setPixelColor(i, Wheel((i * 2 + counter / 2) % 256));
|
|
||||||
}
|
|
||||||
pixels.show();
|
|
||||||
}
|
|
||||||
else if (mode == 3) {
|
|
||||||
for (int i = 0; i < NUMPIXELS; i++){
|
|
||||||
pixels.setPixelColor(i, Wheel(hue % 256));
|
|
||||||
}
|
|
||||||
pixels.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
counter++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
delay(delayval);
|
|
||||||
|
|
||||||
while (Serial.available() > 0) {
|
|
||||||
|
|
||||||
int command = Serial.parseInt();
|
|
||||||
int value = Serial.parseInt();
|
|
||||||
|
|
||||||
if (Serial.read() == '\n') {
|
|
||||||
Serial.print("Command: ");
|
|
||||||
Serial.println(command);
|
|
||||||
Serial.print("Value: ");
|
|
||||||
Serial.println(value);
|
|
||||||
switch (command) {
|
|
||||||
|
|
||||||
case 0:
|
|
||||||
off = (value == 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
brightness = constrain(value, 0, 255);
|
|
||||||
Serial.print("Brightness: ");
|
|
||||||
Serial.println(brightness);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
mode = constrain(value, 1, 3);
|
|
||||||
Serial.print("Mode: ");
|
|
||||||
Serial.println(brightness);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
hue = constrain(value, 0, 255);
|
|
||||||
Serial.print("Hue: ");
|
|
||||||
Serial.println(hue);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue