Bladeren bron

Not working anymore

Emil 3 jaren geleden
bovenliggende
commit
0e6c6599c8
6 gewijzigde bestanden met toevoegingen van 141 en 3 verwijderingen
  1. 30 0
      src/Animations.cpp
  2. 27 0
      src/Animations.h
  3. 33 0
      src/LightCluster.cpp
  4. 34 0
      src/LightCluster.h
  5. 5 3
      src/main.cpp
  6. 12 0
      src/main.h

+ 30 - 0
src/Animations.cpp

@@ -0,0 +1,30 @@
+//
+// Created by emilr on 2022-04-13.
+//
+
+#include "Animations.h"
+#include "main.h"
+
+int * Animations::runAnimationByNumber(int animation) {
+
+};
+int * Animations::setupAnimationByNumber(int animation) {
+
+};
+
+
+Animations::Animations(int *setupLights) {
+
+}
+
+
+
+void Animations::rainbowFill() {
+    for (int light = 0; light < numLights; light++) {
+        lights[light] = leds.ColorHSV(((light * 360 / 10) + animationI) * 360, 255, 255);
+    }
+}
+
+void Animations::setupRainbowFill() {
+    animationDelayMS = 100;
+}

+ 27 - 0
src/Animations.h

@@ -0,0 +1,27 @@
+//
+// Created by emilr on 2022-04-13.
+//
+
+#ifndef UNTITLED_ANIMATIONS_H
+#define UNTITLED_ANIMATIONS_H
+
+
+class Animations {
+public:
+    int * runAnimationByNumber(int animation);
+    int * setupAnimationByNumber(int animation);
+
+    int animationDelayMS;
+
+    Animations(int setupLights[]);
+private:
+    void rainbowFill();
+    void setupRainbowFill();
+
+    int animationI;
+    int numLights;
+    int lights[];
+};
+
+
+#endif //UNTITLED_ANIMATIONS_H

+ 33 - 0
src/LightCluster.cpp

@@ -0,0 +1,33 @@
+//
+// Created by emilr on 2022-04-13.
+//
+
+#include "LightCluster.h"
+#include "Animations.h"
+
+void LightCluster::runAnimation() {
+
+}
+
+void LightCluster::runSetup() {
+
+}
+
+void LightCluster::changeAnimation() {
+
+}
+
+LightCluster::LightCluster(int *lights, int animation) {
+    for (int i = 0; i < sizeof(lights); i++) {
+        mappedLightTable[i] = lights[i];
+    }
+    animationNumber = animation;
+    numLights = sizeof(lights);
+
+    LocalAnimation = Animations(mappedLightTable);
+    runSetup();
+}
+
+bool LightCluster::shouldRun() {
+    return false;
+}

+ 34 - 0
src/LightCluster.h

@@ -0,0 +1,34 @@
+//
+// Created by emilr on 2022-04-13.
+//
+
+#include "Animations.h"
+
+#ifndef UNTITLED_LIGHTCLUSTER_H
+#define UNTITLED_LIGHTCLUSTER_H
+
+
+class LightCluster {
+public:
+    int numLights;
+    int animationNumber;
+
+    void runAnimation();
+    void changeAnimation();
+    bool shouldRun();
+
+    LightCluster(int *lights, int animation);
+
+
+
+private:
+    long lastRun;
+    Animations LocalAnimation;
+
+    void runSetup();
+
+    int mappedLightTable[];
+};
+
+
+#endif //UNTITLED_LIGHTCLUSTER_H

+ 5 - 3
src/main.cpp

@@ -1,11 +1,13 @@
 #include <Arduino.h>
-#include "../.pio/libdeps/esp32doit-devkit-v1/Adafruit NeoPixel/Adafruit_NeoPixel.h"
+#include "main.h"
+#include "LightCluster.h"
 
 #define LED_PIN    4
 #define NUM_LEDS 10
 
 Adafruit_NeoPixel leds(NUM_LEDS, LED_PIN, NEO_WRGB + NEO_KHZ800);
 
+LightCluster clusters[] = {};
 
 void setup() {
     // write your initialization code here
@@ -21,7 +23,7 @@ void loop() {
     delay(1000);
     for (int i = 0; i < 360; i++) {
         for (int light = 0; light < NUM_LEDS; light++) {
-            leds.setPixelColor(light, leds.ColorHSV(((light*360/10)+i)*360, 255, 255));
+            leds.setPixelColor(light, leds.ColorHSV(((light * 360 / 10) + i) * 360, 255, 255));
         }
         leds.show();
         delay(200);
@@ -49,4 +51,4 @@ void loop() {
         leds.show();
         delay(1000);
     }
-}
+}

+ 12 - 0
src/main.h

@@ -0,0 +1,12 @@
+//
+// Created by emilr on 2022-04-13.
+//
+#include "../.pio/libdeps/esp32doit-devkit-v1/Adafruit NeoPixel/Adafruit_NeoPixel.h"
+
+
+extern Adafruit_NeoPixel leds;
+
+#ifndef UNTITLED_MAIN_H
+#define UNTITLED_MAIN_H
+
+#endif //UNTITLED_MAIN_H