//!!!!!!!!!!!!!
//For compile in file
//C:\Users\Izhak\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.13\platform
//Mast change ++11 to ++14
//!!!!!!!!!!!!!!!
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library
#include <Adafruit_NeoPixel.h>
//#include "cie1931.hpp"
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 6 // On Trinket or Gemma, suggest changing this to 1
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 9 // Pop6ular NeoPixel ring size
// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800);
//constexpr Cie1931<260, 248> cie1931_green; //max 230
//constexpr Cie1931<260, 275> cie1931_red; //max 255
//constexpr Cie1931<260, 216> cie1931_blue; //max 200
const int buttonPin = 7; // the number of the pushbutton pin
int buttonState; // the current reading from the input pin
int lastButtonState;
int ledMode; //LED mode
// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 20; // the debounce time; increase if the output flickers
int work_flag = 0;
int cur_light_led_up = 4;
int cur_led = 0;
int lastChangeBrightLedTime = 0;
int CHANGEBRIGHTLEDDELAY=100;
int direction = 1;
#define DELAYVAL 5 // Time (in milliseconds) to pause between pixels
void setup() {
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
pixels.setBrightness(255);
pinMode(buttonPin, INPUT);
ledMode = 0;
buttonState = LOW;
work_flag=0;
}
void CIE1931_white(int start = 0, int step = 40)
{
//printf("//White gradient\n");
for (int i = start; i < 300; i+=step)
{
pixels.setPixelColor((i-start)/step, pixels.Color(100, 0, 10, 0));
}
}
void loop() {
pixels.clear(); // Set all pixel colors to 'off'
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
if (reading == LOW) {
work_flag = 0;
// reset the debouncing timer
lastDebounceTime = millis();
}
if ((work_flag == 0) and ((millis() - lastDebounceTime) > debounceDelay)) {
// whatever the reading is at, it's been there for longer than the debounce
// delay, so take it as the actual current state:
// if the button state has changed:
ledMode = (ledMode+1)%3;
work_flag = 1;
}
switch(ledMode){
case 0 :
CIE1931_white(30, 25);
break;
case 1 :
CIE1931_white(30, 25);
break;
case 2 :
CIE1931_white(30, 25);
break;
default :
//pixels.setPixelColor(cur_led_upd, pixels.Color(0, 0, 0, 0));
break;
}
pixels.show(); // Send the updated pixel colors to the hardware.
delay(50); // Pause before next pass through loop
}