Diff
checker
टेक्स्ट
टेक्स्ट
छवियां
दस्तावेज़
Excel
फ़ोल्डर्स
Legal
Enterprise
डेस्कटॉप
मूल्य
साइन इन करें
Diffchecker डेस्कटॉप डाउनलोड करें
टेक्स्ट की तुलना करें
दो टेक्स्ट फ़ाइलों के बीच अंतर ढूंढें
उपकरण
इतिहास
रियल-टाइम एडिटर
रिक्त स्थान छिपाएँ
अपरिवर्तित संक्षिप्त करें
लाइन रैप बंद
लेआउट
विभाजित
संयुक्त
परिवर्तन हाइलाइट करें
स्मार्ट
शब्द
अक्षर
टेक्स्ट शैलियां
दिखावट बदलें
सिंटैक्स हाइलाइटिंग
सिंटैक्स चुनें
अनदेखा करें
टेक्स्ट बदलें
पहले अंतर पर जाएँ
इनपुट संपादित करें
Diffchecker Desktop
Diffchecker चलाने का सबसे सुरक्षित तरीका। Diffchecker Desktop ऐप पाएं: आपके diffs कभी आपके कंप्यूटर से बाहर नहीं जाते!
Desktop पाएं
LED_Remote
बनाया गया
4 वर्ष पहले
Diff कभी समाप्त नहीं होता
साफ़
निर्यात करें
शेयर करें
समझाएं
28 हटाए गए
लाइनें
कुल
हटाया गया
अक्षर
कुल
हटाया गया
इस सुविधा का उपयोग जारी रखने के लिए, अपग्रेड करें
Diff
checker
Pro
मूल्य देखें
227 लाइनें
सभी को कॉपी करें
397 जोड़े गए
लाइनें
कुल
जोड़ा गया
अक्षर
कुल
जोड़ा गया
इस सुविधा का उपयोग जारी रखने के लिए, अपग्रेड करें
Diff
checker
Pro
मूल्य देखें
533 लाइनें
सभी को कॉपी करें
/* =================================================================
/* =================================================================
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* LED Remote
* LED Remote
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* (c) Brooke. 2016
* (c) Brooke. 2016
-2020
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* This file is the firmware to be upload and ran on the photon. It makes use of the particle API.
* This file is the firmware to be upload and ran on the photon. It makes use of the particle API.
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* All original code is under the GPL v3 except where listed.
* All original code is under the GPL v3 except where listed.
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* the Free Software Foundation; either version 3 of the License, or
* the Free Software Foundation; either version 3 of the License, or
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* (at your option) any later version.
* (at your option) any later version.
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* This program is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* GNU General Public License for more details.
* GNU General Public License for more details.
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301
USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301
USA
================================================================= */
================================================================= */
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/* =======================
i
ncludes ================================= */
#include <neopixel.h>
// use for Build IDE
// #include
"neopixel.h
" // use for local build
/* =======================
I
ncludes ================================= */
#include <neopixel.h>
// #include
\
"neopixel.h
\
" // use for local build
/* ======================= Constances====================== */
/* ======================= Constances====================== */
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
SYSTEM_MODE(AUTOMATIC);
SYSTEM_MODE(AUTOMATIC);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
#define PIXEL_PIN
2
#define PIXEL_COUNT
58
#define PIXEL_PIN
6
#define PIXEL_COUNT
120
#define PIXEL_TYPE SK6812RGBW
#define PIXEL_TYPE SK6812RGBW
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
#define BRIGHTNESS 255
#define BRIGHTNESS 255
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
uint8_t setStripBrigtness( String brightnessValue) ;
uint8_t setStripBrigtness( String brightnessValue) ;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
int
setStripColor( String hexValue );
int
setStripColor( String hexValue );
int currentBrightness = 0;
int currentBrightness = 0;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
String currentHex =
"";
String currentHex =
\"\";
uint8_t setStripPower( String powerValue );
int currentPower = 2;
int loopCase = 0;
int loopCase = 0;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
/**
* setup -- Standard Arduino setup() function
* setup -- Standard Arduino setup() function
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
**/
**/
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
void setup (){
void setup (){
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
strip.begin();
strip.begin();
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
strip.show(); // Initialize all pixels to 'off'
strip.show(); // Initialize all pixels to 'off'
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
//Particle Functions for Color and Brightness
//Particle Functions for Color and Brightness
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
Particle.function(
"hex
", setStripColor);
Particle.function(
"bri
", setStripBrigtness);
Particle.function(
\
"hex
\
", setStripColor);
Particle.function(
\
"bri
\
", setStripBrigtness);
Particle.function(\"pwr\", setStripPower);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
//Particle Variable to hold brightness value
:
Particle.variable(
"curBri
", currentBrightness);
//Particle Variable to hold brightness value
. Shoudl return between 0 - 255
Particle.variable(
\
"curBri
\
", currentBrightness);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
//Particle Variable to hold color value
:
Particle.variable(
"curHex
", currentHex);
//Particle Variable to hold color value
. Should return hex or -1 for false
Particle.variable(
\
"curHex
\
", currentHex);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
//Particle Variable to hold power value. Should always return 1 or 2.
Particle.variable(\"curPwr\", currentPower);
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
/**
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* loop -- Standard Arduino loop() function
**/
* loop -- Standard Arduino loop() function
**/
void loop (){
void loop (){
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
switch ( loopCase ) {
switch ( loopCase ) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
case 1:
case 1:
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
setHex(currentHex);
setHex(currentHex);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
break;
break;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
case 2:
case 2:
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
rainbowCycle(20);
rainbowCycle(20);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
break;
break;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
case 3:
case 3:
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
rainbow(20);
rainbow(20);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
delay(20);
delay(20);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
/**
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* getStripColor -- gets the HexValue input from our POST request
* @param hexValue -- gets hex value string from Particle API
* getStripColor -- gets the HexValue input from our POST request
*/
* @param hexValue -- gets hex value string from Particle API
*/
int setStripColor( String hexValue ) {
int setStripColor( String hexValue ) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
if(hexValue.length() == 8){
if(hexValue.length() == 8){
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
currentHex = hexValue;
currentHex = hexValue;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
loopCase = 1;
loopCase = 1;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return 1;
return 1;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
else if( hexValue ==
"rainbow
" ) {
else if( hexValue ==
\
"rainbow
\
" ) {
loopCase = 2;
loopCase = 2;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return 2;
return 2;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
else if ( hexValue ==
"rainbowCycle
" ) {
else if ( hexValue ==
\
"rainbowCycle
\
" ) {
loopCase = 3;
loopCase = 3;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return 3;
return 3;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
else {
else {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return -1;
return -1;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
/**
* setStripBrightness -- Sets the LED strip color based on input of particle function setStripBrigtness
* setStripBrightness -- Sets the LED strip color based on input of particle function setStripBrigtness
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* @param brightnessValue -- 0-255 brightness value for our LED strip.
* @param brightnessValue -- 0-255 brightness value for our LED strip.
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
*/
*/
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
uint8_t setStripBrigtness( String brightnessValue ) {
uint8_t setStripBrigtness( String brightnessValue ) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
uint8_t brightnessAsInt = brightnessValue.toInt();
uint8_t brightnessAsInt = brightnessValue.toInt();
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
if( ( brightnessAsInt <= 255 ) && ( brightnessValue.length() <= 3 ) ){
if( ( brightnessAsInt <= 255 ) && ( brightnessValue.length() <= 3 ) ){
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
for (uint8_t i = 0; i < PIXEL_COUNT; i
++ ){
for (uint8_t i = 0; i < PIXEL_COUNT; i
= i + currentPower ){
strip.setBrightness( brightnessAsInt );
strip.setBrightness( brightnessAsInt );
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
strip.show();
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
strip.show();
currentBrightness = brightnessAsInt;
currentBrightness = brightnessAsInt;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return currentBrightness;
return currentBrightness;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
else {
else {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return 0;
return 0;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
/**
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* convertHex -- converts hexValue into byte to be used in our array RBG > 255
* see: https://arduino.stackexchange.com/a/16446
* setStripPower -- Sets the strip power
* @param char -- gets hex value string from Particle API
*/
* @param powerValue -- Send 1 for all lights and send 0 for just half.
*/
uint8_t setStripPower( String powerValue ) {
if( powerValue.toInt() == 1 ){
currentPower = 1;
return 1;
}
else {
currentPower = 2;
return 0;
}
}
/**
* convertHex -- converts hexValue into byte to be used in our array RBG > 255
* see: https://arduino.stackexchange.com/a/16446
* @param char -- gets hex value string from Particle API
*/
byte convertHex (const char * str){
byte convertHex (const char * str){
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
char c = str [0] - '0';
char c = str [0] - '0';
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
if (c > 9)
if (c > 9)
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
c -= 7;
c -= 7;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
int result = c;
int result = c;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
c = str [1] - '0';
c = str [1] - '0';
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
if (c > 9)
if (c > 9)
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
c -= 7;
c -= 7;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return (result << 4) | c;
return (result << 4) | c;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
/**
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* setHex -- converts hexValue into byte to be used in our array RBG > 255
* @param hexValue HexValue to set strip to.
* setHex -- converts hexValue into byte to be used in our array RBG > 255
*/
* @param hexValue HexValue to set strip to.
*/
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
char setHex( String hexValue ) {
char setHex( String hexValue ) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
const char * hexCharArray = hexValue;
const char * hexCharArray = hexValue;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
byte redValue = convertHex ( & hexCharArray[0] );
byte redValue = convertHex ( & hexCharArray[0] );
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
byte greenValue = convertHex ( & hexCharArray[2] );
byte greenValue = convertHex ( & hexCharArray[2] );
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
byte blueValue = convertHex ( & hexCharArray[4] );
byte blueValue = convertHex ( & hexCharArray[4] );
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
byte whiteValue = convertHex ( & hexCharArray[6] );
byte whiteValue = convertHex ( & hexCharArray[6] );
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
for (int i = 0; i < PIXEL_COUNT; i
++ ){
if( currentPower == 2 ){
for (int i = 1; i < PIXEL_COUNT; i++ ){
strip.setPixelColor(i, 0, 0, 0, 0);
}
}
for (int i = 0; i < PIXEL_COUNT; i
= i + currentPower ){
strip.setPixelColor(i, greenValue, redValue, blueValue, whiteValue);
strip.setPixelColor(i, greenValue, redValue, blueValue, whiteValue);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
strip.show();
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
strip.show();
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
/**
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* rainbowCycle -- Cycles through colors
* @source: https://github.com/adafruit/Adafruit_NeoPixel
* rainbowCycle -- Cycles through colors
* @param wait -- mills between transition, higher is slower. Vaules 0-255
*/
* @source: https://github.com/adafruit/Adafruit_NeoPixel
* @param wait -- mills between transition, higher is slower. Vaules 0-255
*/
void rainbowCycle(uint8_t wait) {
void rainbowCycle(uint8_t wait) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
uint16_t i, j;
uint16_t i, j;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
for(j=0; j<256; j++) { // 5 cycles of all colors on wheel
for(j=0; j<256; j++) { // 5 cycles of all colors on wheel
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
for(i=0; i< strip.numPixels(); i
++
) {
strip.setPixelColor(i, Wheel(((i * 256 /
strip.numPixels()
) + j) & 255));
if( currentPower == 2 ){
for (int i = 1; i < PIXEL_COUNT; i++ ){
strip.setPixelColor(i, 0, 0, 0, 0);
}
}
for(i=0; i< strip.numPixels(); i
= i + currentPower
) {
strip.setPixelColor(i, Wheel(((i * 256 /
PIXEL_COUNT
) + j) & 255));
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
strip.show();
strip.show();
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
delay(wait);
delay(wait);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
/**
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* rainbow -- Cycles through colors
* @source: https://github.com/adafruit/Adafruit_NeoPixel
* rainbow -- Cycles through colors
* @param wait -- mills between transition, higher is slower. Vaules 0-255
*/
* @source: https://github.com/adafruit/Adafruit_NeoPixel
* @param wait -- mills between transition, higher is slower. Vaules 0-255
*/
void rainbow(uint8_t wait) {
void rainbow(uint8_t wait) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
uint16_t i, j;
uint16_t i, j;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
for(j=0; j<256; j++) {
for(j=0; j<256; j++) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
for(i=0; i<strip.numPixels(); i
++
) {
if( currentPower == 2 ){
for (int i = 1; i < PIXEL_COUNT; i++ ){
strip.setPixelColor(i, 0, 0, 0, 0);
}
}
for(i=0; i<strip.numPixels(); i
= i + currentPower
) {
strip.setPixelColor(i, Wheel((i+j) & 255));
strip.setPixelColor(i, Wheel((i+j) & 255));
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
strip.show();
strip.show();
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
delay(wait);
delay(wait);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
/**
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
* Wheel
* Input a value 0 to 255 to get a color value.
* Wheel
* The colours are a transition r - g - b - back to r.
* @source: https://github.com/adafruit/Adafruit_NeoPixel
* Input a value 0 to 255 to get a color value.
* @param byte WheelPos
*/
* The colours are a transition r - g - b - back to r.
* @source: https://github.com/adafruit/Adafruit_NeoPixel
* @param byte WheelPos
*/
uint32_t Wheel(byte WheelPos) {
uint32_t Wheel(byte WheelPos) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
WheelPos = 255 - WheelPos;
WheelPos = 255 - WheelPos;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
if(WheelPos < 85) {
if(WheelPos < 85) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3,0);
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3,0);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
if(WheelPos < 170) {
if(WheelPos < 170) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
WheelPos -= 85;
WheelPos -= 85;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3,0);
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3,0);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
WheelPos -= 170;
WheelPos -= 170;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0,0);
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0,0);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
uint8_t red(uint32_t c) {
uint8_t red(uint32_t c) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return (c >> 8);
return (c >> 8);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
uint8_t green(uint32_t c) {
uint8_t green(uint32_t c) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return (c >> 16);
return (c >> 16);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
uint8_t blue(uint32_t c) {
uint8_t blue(uint32_t c) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return (c);
return (c);
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
}
}
सेव किए गए Diffs
ऑरिजनल टेक्स्ट
फ़ाइल खोलें
/* ================================================================= * LED Remote * (c) Brooke. 2016 * This file is the firmware to be upload and ran on the photon. It makes use of the particle API. * All original code is under the GPL v3 except where listed. * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ================================================================= */ /* ======================= includes ================================= */ #include <neopixel.h> // use for Build IDE // #include "neopixel.h" // use for local build /* ======================= Constances====================== */ SYSTEM_MODE(AUTOMATIC); #define PIXEL_PIN 2 #define PIXEL_COUNT 58 #define PIXEL_TYPE SK6812RGBW #define BRIGHTNESS 255 uint8_t setStripBrigtness( String brightnessValue) ; int setStripColor( String hexValue ); int currentBrightness = 0; String currentHex = ""; int loopCase = 0; Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE); /** * setup -- Standard Arduino setup() function **/ void setup (){ strip.begin(); strip.show(); // Initialize all pixels to 'off' //Particle Functions for Color and Brightness Particle.function("hex", setStripColor); Particle.function("bri", setStripBrigtness); //Particle Variable to hold brightness value: Particle.variable("curBri", currentBrightness); //Particle Variable to hold color value: Particle.variable("curHex", currentHex); } /** * loop -- Standard Arduino loop() function **/ void loop (){ switch ( loopCase ) { case 1: setHex(currentHex); break; case 2: rainbowCycle(20); break; case 3: rainbow(20); } delay(20); } /** * getStripColor -- gets the HexValue input from our POST request * @param hexValue -- gets hex value string from Particle API */ int setStripColor( String hexValue ) { if(hexValue.length() == 8){ currentHex = hexValue; loopCase = 1; return 1; } else if( hexValue == "rainbow" ) { loopCase = 2; return 2; } else if ( hexValue == "rainbowCycle" ) { loopCase = 3; return 3; } else { return -1; } } /** * setStripBrightness -- Sets the LED strip color based on input of particle function setStripBrigtness * @param brightnessValue -- 0-255 brightness value for our LED strip. */ uint8_t setStripBrigtness( String brightnessValue ) { uint8_t brightnessAsInt = brightnessValue.toInt(); if( ( brightnessAsInt <= 255 ) && ( brightnessValue.length() <= 3 ) ){ for (uint8_t i = 0; i < PIXEL_COUNT; i++ ){ strip.setBrightness( brightnessAsInt ); strip.show(); } currentBrightness = brightnessAsInt; return currentBrightness; } else { return 0; } } /** * convertHex -- converts hexValue into byte to be used in our array RBG > 255 * see: https://arduino.stackexchange.com/a/16446 * @param char -- gets hex value string from Particle API */ byte convertHex (const char * str){ char c = str [0] - '0'; if (c > 9) c -= 7; int result = c; c = str [1] - '0'; if (c > 9) c -= 7; return (result << 4) | c; } /** * setHex -- converts hexValue into byte to be used in our array RBG > 255 * @param hexValue HexValue to set strip to. */ char setHex( String hexValue ) { const char * hexCharArray = hexValue; byte redValue = convertHex ( & hexCharArray[0] ); byte greenValue = convertHex ( & hexCharArray[2] ); byte blueValue = convertHex ( & hexCharArray[4] ); byte whiteValue = convertHex ( & hexCharArray[6] ); for (int i = 0; i < PIXEL_COUNT; i++ ){ strip.setPixelColor(i, greenValue, redValue, blueValue, whiteValue); strip.show(); } } /** * rainbowCycle -- Cycles through colors * @source: https://github.com/adafruit/Adafruit_NeoPixel * @param wait -- mills between transition, higher is slower. Vaules 0-255 */ void rainbowCycle(uint8_t wait) { uint16_t i, j; for(j=0; j<256; j++) { // 5 cycles of all colors on wheel for(i=0; i< strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); } strip.show(); delay(wait); } } /** * rainbow -- Cycles through colors * @source: https://github.com/adafruit/Adafruit_NeoPixel * @param wait -- mills between transition, higher is slower. Vaules 0-255 */ void rainbow(uint8_t wait) { uint16_t i, j; for(j=0; j<256; j++) { for(i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, Wheel((i+j) & 255)); } strip.show(); delay(wait); } } /** * Wheel * Input a value 0 to 255 to get a color value. * The colours are a transition r - g - b - back to r. * @source: https://github.com/adafruit/Adafruit_NeoPixel * @param byte WheelPos */ uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3,0); } if(WheelPos < 170) { WheelPos -= 85; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3,0); } WheelPos -= 170; return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0,0); } uint8_t red(uint32_t c) { return (c >> 8); } uint8_t green(uint32_t c) { return (c >> 16); } uint8_t blue(uint32_t c) { return (c); }
परिवर्तित टेक्स्ट
फ़ाइल खोलें
/* ================================================================= * LED Remote * (c) Brooke. 2016-2020 * This file is the firmware to be upload and ran on the photon. It makes use of the particle API. * All original code is under the GPL v3 except where listed. * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ================================================================= */ /* ======================= Includes ================================= */ #include <neopixel.h> // #include \"neopixel.h\" // use for local build /* ======================= Constances====================== */ SYSTEM_MODE(AUTOMATIC); #define PIXEL_PIN 6 #define PIXEL_COUNT 120 #define PIXEL_TYPE SK6812RGBW #define BRIGHTNESS 255 uint8_t setStripBrigtness( String brightnessValue) ; int setStripColor( String hexValue ); int currentBrightness = 0; String currentHex = \"\"; uint8_t setStripPower( String powerValue ); int currentPower = 2; int loopCase = 0; Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE); /** * setup -- Standard Arduino setup() function **/ void setup (){ strip.begin(); strip.show(); // Initialize all pixels to 'off' //Particle Functions for Color and Brightness Particle.function(\"hex\", setStripColor); Particle.function(\"bri\", setStripBrigtness); Particle.function(\"pwr\", setStripPower); //Particle Variable to hold brightness value. Shoudl return between 0 - 255 Particle.variable(\"curBri\", currentBrightness); //Particle Variable to hold color value. Should return hex or -1 for false Particle.variable(\"curHex\", currentHex); //Particle Variable to hold power value. Should always return 1 or 2. Particle.variable(\"curPwr\", currentPower); } /** * loop -- Standard Arduino loop() function **/ void loop (){ switch ( loopCase ) { case 1: setHex(currentHex); break; case 2: rainbowCycle(20); break; case 3: rainbow(20); } delay(20); } /** * getStripColor -- gets the HexValue input from our POST request * @param hexValue -- gets hex value string from Particle API */ int setStripColor( String hexValue ) { if(hexValue.length() == 8){ currentHex = hexValue; loopCase = 1; return 1; } else if( hexValue == \"rainbow\" ) { loopCase = 2; return 2; } else if ( hexValue == \"rainbowCycle\" ) { loopCase = 3; return 3; } else { return -1; } } /** * setStripBrightness -- Sets the LED strip color based on input of particle function setStripBrigtness * @param brightnessValue -- 0-255 brightness value for our LED strip. */ uint8_t setStripBrigtness( String brightnessValue ) { uint8_t brightnessAsInt = brightnessValue.toInt(); if( ( brightnessAsInt <= 255 ) && ( brightnessValue.length() <= 3 ) ){ for (uint8_t i = 0; i < PIXEL_COUNT; i = i + currentPower ){ strip.setBrightness( brightnessAsInt ); } strip.show(); currentBrightness = brightnessAsInt; return currentBrightness; } else { return 0; } } /** * setStripPower -- Sets the strip power * @param powerValue -- Send 1 for all lights and send 0 for just half. */ uint8_t setStripPower( String powerValue ) { if( powerValue.toInt() == 1 ){ currentPower = 1; return 1; } else { currentPower = 2; return 0; } } /** * convertHex -- converts hexValue into byte to be used in our array RBG > 255 * see: https://arduino.stackexchange.com/a/16446 * @param char -- gets hex value string from Particle API */ byte convertHex (const char * str){ char c = str [0] - '0'; if (c > 9) c -= 7; int result = c; c = str [1] - '0'; if (c > 9) c -= 7; return (result << 4) | c; } /** * setHex -- converts hexValue into byte to be used in our array RBG > 255 * @param hexValue HexValue to set strip to. */ char setHex( String hexValue ) { const char * hexCharArray = hexValue; byte redValue = convertHex ( & hexCharArray[0] ); byte greenValue = convertHex ( & hexCharArray[2] ); byte blueValue = convertHex ( & hexCharArray[4] ); byte whiteValue = convertHex ( & hexCharArray[6] ); if( currentPower == 2 ){ for (int i = 1; i < PIXEL_COUNT; i++ ){ strip.setPixelColor(i, 0, 0, 0, 0); } } for (int i = 0; i < PIXEL_COUNT; i = i + currentPower ){ strip.setPixelColor(i, greenValue, redValue, blueValue, whiteValue); } strip.show(); } /** * rainbowCycle -- Cycles through colors * @source: https://github.com/adafruit/Adafruit_NeoPixel * @param wait -- mills between transition, higher is slower. Vaules 0-255 */ void rainbowCycle(uint8_t wait) { uint16_t i, j; for(j=0; j<256; j++) { // 5 cycles of all colors on wheel if( currentPower == 2 ){ for (int i = 1; i < PIXEL_COUNT; i++ ){ strip.setPixelColor(i, 0, 0, 0, 0); } } for(i=0; i< strip.numPixels(); i = i + currentPower) { strip.setPixelColor(i, Wheel(((i * 256 / PIXEL_COUNT ) + j) & 255)); } strip.show(); delay(wait); } } /** * rainbow -- Cycles through colors * @source: https://github.com/adafruit/Adafruit_NeoPixel * @param wait -- mills between transition, higher is slower. Vaules 0-255 */ void rainbow(uint8_t wait) { uint16_t i, j; for(j=0; j<256; j++) { if( currentPower == 2 ){ for (int i = 1; i < PIXEL_COUNT; i++ ){ strip.setPixelColor(i, 0, 0, 0, 0); } } for(i=0; i<strip.numPixels(); i = i + currentPower ) { strip.setPixelColor(i, Wheel((i+j) & 255)); } strip.show(); delay(wait); } } /** * Wheel * Input a value 0 to 255 to get a color value. * The colours are a transition r - g - b - back to r. * @source: https://github.com/adafruit/Adafruit_NeoPixel * @param byte WheelPos */ uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3,0); } if(WheelPos < 170) { WheelPos -= 85; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3,0); } WheelPos -= 170; return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0,0); } uint8_t red(uint32_t c) { return (c >> 8); } uint8_t green(uint32_t c) { return (c >> 16); } uint8_t blue(uint32_t c) { return (c); }
अंतर खोजें