diff --git a/documentation.docx b/documentation.docx new file mode 100644 index 0000000..709d48d Binary files /dev/null and b/documentation.docx differ diff --git a/documentation.pdf b/documentation.pdf new file mode 100644 index 0000000..efb0ac8 Binary files /dev/null and b/documentation.pdf differ diff --git a/firmware/singleButton.ino b/firmware/singleButton.ino new file mode 100644 index 0000000..d2b6d33 --- /dev/null +++ b/firmware/singleButton.ino @@ -0,0 +1,105 @@ +#include +#include +#include "OneButton.h" + +Adafruit_NeoPixel led(1, 4, NEO_GRB + NEO_KHZ800); +OneButton button(14); + +bool fading = false; +int fadingCounter = 0; + +int common[][3] = {{0, 0, 0}, {255, 255, 0}, {255, 0, 0}, {61, 224, 229}, {0, 255, 0}, {255, 255, 255}}; +int commonCounter = 0; + +int dimmingDirection = true; + +int color[] = {255, 255, 255}; +int saturation = 255; + +struct { + bool fading; + int color[3]; + int saturation; +} flash; + +void setup() { + Serial.begin(115200); + + EEPROM.begin(sizeof(flash)); + EEPROM.get(0, flash); + + color[0] = flash.color[0]; + color[1] = flash.color[1]; + color[2] = flash.color[2]; + + fading = flash.fading; + if(flash.fading == -1) flash.fading = false; + saturation = flash.saturation; + saveConfig(); + + led.begin(); + led.clear(); + + button.attachClick([]() { + //cycle common colours on Single-Click and store Position + if(commonCounter >= 5) commonCounter = 0; else commonCounter++; + Serial.println(commonCounter); + color[0] = common[commonCounter][0]; + color[1] = common[commonCounter][1]; + color[2] = common[commonCounter][2]; + + flash.color[0] = common[commonCounter][0]; + flash.color[1] = common[commonCounter][1]; + flash.color[2] = common[commonCounter][2]; + saveConfig(); + + }); + + button.attachDoubleClick([]() { + //start Fading and store fading-status + fading = !fading; + + flash.fading = fading; + saveConfig(); + }); + + button.attachLongPressStart([]() { + //on each new Longpress reverse the direction the dimming will go + dimmingDirection = !dimmingDirection; + }); + + button.attachDuringLongPress([]() { + //on long press increment or decrement based on direction the saturation value + if(dimmingDirection) { + if(saturation < 255) saturation++; + } else { + if(saturation > 10) saturation--; + } + delay(10); //this delay controls the speed of the dimm-controlls + }); + button.attachLongPressStop([]() { + flash.saturation = saturation; + saveConfig(); + }); +} + +void loop() { + button.tick(); + + if(fading) { + fadingCounter++; + if(fadingCounter >= 65535) fadingCounter = 0; + led.setPixelColor(0, led.ColorHSV(fadingCounter, 255, saturation)); + } else { + led.setPixelColor(0, led.Color(color[0]*(saturation/255.0), color[1]*(saturation/255.0), color[2]*(saturation/255.0))); + } + + + led.show(); + +} + +void saveConfig() { + EEPROM.put(0, flash); + EEPROM.commit(); +} diff --git a/oreLightPaper.pdf b/oreLightPaper.pdf new file mode 100644 index 0000000..753430d Binary files /dev/null and b/oreLightPaper.pdf differ diff --git a/resetEeprom/factoryDefault.ino b/resetEeprom/factoryDefault.ino new file mode 100644 index 0000000..9b97444 --- /dev/null +++ b/resetEeprom/factoryDefault.ino @@ -0,0 +1,28 @@ +#include + +void setup() { + // put your setup code here, to run once: + struct { + bool fading; + int color[3]; + int saturation; + } flash; + EEPROM.begin(sizeof(flash)); + + + flash.color[0] = 0; + flash.color[1] = 0; + flash.color[2] = 0; + + flash.fading = false; + flash.saturation = 255; + + EEPROM.put(0, flash); + EEPROM.commit(); +} + +void loop() { + // put your main code here, to run repeatedly: + + +}