cleaup+comments

This commit is contained in:
Lurkars 2020-12-30 19:19:27 +01:00
parent 0376723a95
commit fc3b8e329f

View File

@ -1,5 +1,9 @@
// #define NEOPIXEL // uncomment next line if you want to use NEOPIXEL (3 pins) instead of APA102 (4 pins)
// #define TEST_STRIPES //#define NEOPIXEL
// uncomment next line for image test modus, this will change the segments every 1/2 second
//#define TEST_STRIPES
#include "images.h"
#ifdef NEOPIXEL #ifdef NEOPIXEL
#include <Adafruit_NeoPixel.h> #include <Adafruit_NeoPixel.h>
@ -9,21 +13,31 @@
#include <APA102.h> #include <APA102.h>
#endif #endif
#include "images.h" // CONFIGURE please configure next lines depending on your stripe arragmentment
#define HALL_PIN 2 // digital pin of hall sensor
#define ROUND_COUNT 1 // how many rounds to take time (minimum 1)
#define HALL_PIN 2 #define NUM_SEGMENTS 360 // how much segements to divide image (gives an angle precision of 360 / NUM_SEGMENTS)
#define ROUND_COUNT 2 #define LED_COUNT 26 // how many LEDs on one stripe
#define LED_STRIPES 4 // how many LEDs stripes on wheel
// Define which pins to use. int strip_matrix_offset[LED_STRIPES] = {0, 0, (NUM_SEGMENTS / 2), (NUM_SEGMENTS / 2)}; // given offset in segments for stripe
#define LED_DATA_PIN 10 bool strip_matrix_invert[LED_STRIPES] = {false, true, false, true}; // set LEDs in revert order for stripe
#define LED_CLOCK_PIN 11 // \CONFIGURE
#define NUM_SEGMENTS 360
#define LED_COUNT 26
#define LED_STRIPES 4
int strip_matrix_offset[LED_STRIPES] = {0, 0, (NUM_SEGMENTS / 2), (NUM_SEGMENTS / 2)}; // LED stripes
bool strip_matrix_invert[LED_STRIPES] = {false, true, false, true}; #ifdef NEOPIXEL
#define LED_PIN 6 // data pin for neopixel LED stripe
#define BRIGHTNESS 10 // brightness for LED strip [0-255]
Adafruit_NeoPixel ledStrip(LED_COUNT *LED_STRIPES, LED_PIN, NEO_GRB + NEO_KHZ800);
#else
#define LED_DATA_PIN 10 // data pin for LED strip
#define LED_CLOCK_PIN 11 // clock pin for LED strip
APA102<LED_DATA_PIN, LED_CLOCK_PIN> ledStrip;
#define BRIGHTNESS 1 // brightness for LED strip [0-31]
rgb_color color_buffer[LED_COUNT * LED_STRIPES]; // color buffer to write to LED stripe
#endif
float passed = 0; float passed = 0;
int current_image_index = 0; int current_image_index = 0;
@ -33,17 +47,6 @@ uint8_t *current_pixels;
int current_state = 0; int current_state = 0;
// Create an object for writing to the LED strip.
#ifdef NEOPIXEL
#define LED_PIN 6
#define BRIGHTNESS 10
Adafruit_NeoPixel ledStrip(LED_COUNT *LED_STRIPES, LED_PIN, NEO_GRB + NEO_KHZ800);
#else
APA102<LED_DATA_PIN, LED_CLOCK_PIN> ledStrip;
#define BRIGHTNESS 1
rgb_color color_buffer[LED_COUNT * LED_STRIPES];
#endif
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
@ -63,9 +66,8 @@ void loop()
float start = micros(); float start = micros();
int count = 0; int count = 0;
bool change = false; bool change = false;
while (count < ROUND_COUNT) while (count <= ROUND_COUNT)
{ {
// check HALL if turned
if (digitalRead(HALL_PIN) == LOW) if (digitalRead(HALL_PIN) == LOW)
{ {
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(LED_BUILTIN, HIGH);
@ -81,7 +83,6 @@ void loop()
change = false; change = false;
} }
// calc led for last turn
float current_diff = micros() - start; float current_diff = micros() - start;
#ifndef TEST_STRIPES #ifndef TEST_STRIPES