 #define PIN 2      // Actually 04 on Makerfocus D1 Mini
 #define TRIG_PIN 1 // Actually TX on Makerfocus D1 Mini
 #define ECHO_PIN 0 // Actually D3 on Makerfocus D1 Mini
-#define FADE_TIME 1
-#define TUNING 9 // Tunes range-finding to cm distance between pixels
-#define FPS 50
-#define NUM_PIXELS 50
-#define TRAIL_LENGTH 11
+#define FADE_TIME 100
+#define TUNING 5 // Tunes range-finding to cm distance between pixels
+#define DELAY 2500
+#define NUM_PIXELS 100
+#define ADJACENT_PIXELS 16
 
-Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
+Adafruit_NeoPixel strip =
+    Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
 
+char *UP = "UP";
+char *DOWN = "DOWN";
+char *NOOP = "NOOP";
+char *direction = UP;
 int colors[NUM_PIXELS];
-int trailingPixels[TRAIL_LENGTH];
-int trailingIndex = 0;
-int trailLength = sizeof(trailingPixels) / sizeof(trailingPixels[0]);
+int pixel = 0;
 
 void setup() {
   Serial.begin(9600);
   pinMode(TRIG_PIN, OUTPUT);
   pinMode(ECHO_PIN, INPUT);
 
-  #if defined(__AVR_ATtiny85__)
-    if (F_CPU == 16000000)
-      clock_prescale_set(clock_div_1);
-  #endif
+#if defined(__AVR_ATtiny85__)
+  if (F_CPU == 16000000)
+    clock_prescale_set(clock_div_1);
+#endif
 
   initColors();
 

  distance = (duration / 2) * 0.0344;

  int8_t pixel = floor(distance) / TUNING;
  simUpsideDownTouch(pixel);
  colorWipe(pixel);
}

void colorWipe(uint8_t pixel) {
  bool alreadyLit = false;    
  for(const int &i : trailingPixels) {
    if (trailingPixels[i] == pixel || pixel > strip.numPixels()) {
      alreadyLit = true;
    }
  }
  if (!alreadyLit) {
    trailingPixels[trailingIndex] = pixel;

    trailingIndex++;
    if (trailingIndex > trailLength) {
      trailingIndex = 0; 
    }
  }

  for (uint8_t i = 0; i < strip.numPixels(); i++) {
    bool leaveLit = false;
    for(const int &i : trailingPixels) {
      if (trailingPixels[i] == pixel) {
        leaveLit = true;
      }
    }

    if (!leaveLit) {
      strip.setPixelColor(i, 0);
    }
  }
}


#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
