LED_Remote

建立於 差異永不過期
36 刪除
227 行
401 新增
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




================================================================= */
================================================================= */


/* ======================= includes ================================= */

#include <neopixel.h> // use for Build IDE

// #include "neopixel.h" // use for local build
/* ======================= Includes ================================= */

#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;