changes for better automatic configuration
This commit is contained in:
parent
dba16cc27e
commit
ee1ed34935
55
src/main.cpp
55
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;i<NUMPIXELS;i++){
|
||||
uint32_t c=strip.Color(0,0,0);
|
||||
strip.setPixelColor(i,c);
|
||||
}
|
||||
|
||||
if (waittime>0){
|
||||
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<NUMPIXELS){
|
||||
selectedpixel=pixelnumber;
|
||||
}else{
|
||||
Serial.println("Error: Value too high!");
|
||||
}
|
||||
}*/
|
||||
}else if (serialstring.startsWith("fx_")){
|
||||
Serial.println("Effect Scanner");
|
||||
if (effect!=NULL){
|
||||
|
@ -419,18 +441,29 @@ void loop_configmode(){
|
|||
if (lastPixelUpdate+PIXELUPDATETIME<loopmillis){
|
||||
lastPixelUpdate=loopmillis;
|
||||
|
||||
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 (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<NUMPIXELS-1){
|
||||
uint32_t c=strip.Color(0,0,0);
|
||||
strip.setPixelColor(selectedpixel+1,c);
|
||||
}
|
||||
}
|
||||
if (selectedpixel<NUMPIXELS-1){
|
||||
uint32_t c=strip.Color(0,0,0);
|
||||
strip.setPixelColor(selectedpixel+1,c);
|
||||
}else if(selectpixelmode==1) {
|
||||
//show only selected pixel as white, everything else off
|
||||
allBlack(0);
|
||||
if (selectedpixel>=0 && selectedpixel<NUMPIXELS){
|
||||
uint32_t c=strip.Color(255,255,255);
|
||||
strip.setPixelColor(selectedpixel,c);
|
||||
}
|
||||
}
|
||||
strip.show();
|
||||
|
|
Loading…
Reference in New Issue