From ee1ed3493521a71abde1a5ec3e0a8b04090f9ccf Mon Sep 17 00:00:00 2001 From: Fisch Date: Sun, 13 Dec 2020 01:12:37 +0100 Subject: [PATCH] changes for better automatic configuration --- src/main.cpp | 55 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 11f0551..525a64f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ void resetHeightmap(); void printHeightmapRaw(); void interpolateHeightValues(); void previewHeightmap(int waittime); +void allBlack(int waittime); void spawnWagon(); void spawnWagon(float pos, float wagonlength,float startvel, float startacc, float mass, uint8_t wheelcolor); void checkSerial(); @@ -64,6 +65,7 @@ uint8_t maxid=0; bool configmode=false; int selectedpixel=-1; //-1 = none +uint8_t selectpixelmode=0; uint8_t wagoncount=0; @@ -223,6 +225,18 @@ void previewHeightmap(int waittime){ } } +void allBlack(int waittime){ + for (int i=0;i0){ + strip.show(); + delay(waittime); + } +} + void spawnWagon(){ @@ -309,6 +323,11 @@ void checkSerial(){ }else if (serialstring.equals("debug")){ strip.setBrightness(BRIGHTNESS_DEBUG); configmode=true; + selectpixelmode=0; + }else if (serialstring.equals("debug_dark")){ + strip.setBrightness(BRIGHTNESS_DEBUG); + configmode=true; + selectpixelmode=1; //show only selected color, everything else off }else if (serialstring.equals("print")){ printHeightmapRaw(); }else if (serialstring.equals("save")){ @@ -393,11 +412,14 @@ void checkSerial(){ Serial.print("show pixel "); Serial.print(pixelnumber); + selectedpixel=pixelnumber; + + /* //ignore max and min. all black with px=-1 if (pixelnumber=0){ - uint32_t c=strip.Color(255,255,255); - strip.setPixelColor(selectedpixel,c); - if (selectedpixel>=1){ - uint32_t c=strip.Color(0,0,0); - strip.setPixelColor(selectedpixel-1,c); + if (selectpixelmode==0) { + //show heightmap as color and selected pixel white + previewHeightmap(0); + if (selectedpixel>=0){ + uint32_t c=strip.Color(255,255,255); + strip.setPixelColor(selectedpixel,c); + if (selectedpixel>=1){ + uint32_t c=strip.Color(0,0,0); + strip.setPixelColor(selectedpixel-1,c); + } + if (selectedpixel=0 && selectedpixel