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 printHeightmapRaw();
|
||||||
void interpolateHeightValues();
|
void interpolateHeightValues();
|
||||||
void previewHeightmap(int waittime);
|
void previewHeightmap(int waittime);
|
||||||
|
void allBlack(int waittime);
|
||||||
void spawnWagon();
|
void spawnWagon();
|
||||||
void spawnWagon(float pos, float wagonlength,float startvel, float startacc, float mass, uint8_t wheelcolor);
|
void spawnWagon(float pos, float wagonlength,float startvel, float startacc, float mass, uint8_t wheelcolor);
|
||||||
void checkSerial();
|
void checkSerial();
|
||||||
|
@ -64,6 +65,7 @@ uint8_t maxid=0;
|
||||||
|
|
||||||
bool configmode=false;
|
bool configmode=false;
|
||||||
int selectedpixel=-1; //-1 = none
|
int selectedpixel=-1; //-1 = none
|
||||||
|
uint8_t selectpixelmode=0;
|
||||||
|
|
||||||
uint8_t wagoncount=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(){
|
void spawnWagon(){
|
||||||
|
@ -309,6 +323,11 @@ void checkSerial(){
|
||||||
}else if (serialstring.equals("debug")){
|
}else if (serialstring.equals("debug")){
|
||||||
strip.setBrightness(BRIGHTNESS_DEBUG);
|
strip.setBrightness(BRIGHTNESS_DEBUG);
|
||||||
configmode=true;
|
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")){
|
}else if (serialstring.equals("print")){
|
||||||
printHeightmapRaw();
|
printHeightmapRaw();
|
||||||
}else if (serialstring.equals("save")){
|
}else if (serialstring.equals("save")){
|
||||||
|
@ -393,11 +412,14 @@ void checkSerial(){
|
||||||
Serial.print("show pixel ");
|
Serial.print("show pixel ");
|
||||||
Serial.print(pixelnumber);
|
Serial.print(pixelnumber);
|
||||||
|
|
||||||
|
selectedpixel=pixelnumber;
|
||||||
|
|
||||||
|
/* //ignore max and min. all black with px=-1
|
||||||
if (pixelnumber<NUMPIXELS){
|
if (pixelnumber<NUMPIXELS){
|
||||||
selectedpixel=pixelnumber;
|
selectedpixel=pixelnumber;
|
||||||
}else{
|
}else{
|
||||||
Serial.println("Error: Value too high!");
|
Serial.println("Error: Value too high!");
|
||||||
}
|
}*/
|
||||||
}else if (serialstring.startsWith("fx_")){
|
}else if (serialstring.startsWith("fx_")){
|
||||||
Serial.println("Effect Scanner");
|
Serial.println("Effect Scanner");
|
||||||
if (effect!=NULL){
|
if (effect!=NULL){
|
||||||
|
@ -419,18 +441,29 @@ void loop_configmode(){
|
||||||
if (lastPixelUpdate+PIXELUPDATETIME<loopmillis){
|
if (lastPixelUpdate+PIXELUPDATETIME<loopmillis){
|
||||||
lastPixelUpdate=loopmillis;
|
lastPixelUpdate=loopmillis;
|
||||||
|
|
||||||
previewHeightmap(0);
|
|
||||||
|
|
||||||
if (selectedpixel>=0){
|
if (selectpixelmode==0) {
|
||||||
uint32_t c=strip.Color(255,255,255);
|
//show heightmap as color and selected pixel white
|
||||||
strip.setPixelColor(selectedpixel,c);
|
previewHeightmap(0);
|
||||||
if (selectedpixel>=1){
|
if (selectedpixel>=0){
|
||||||
uint32_t c=strip.Color(0,0,0);
|
uint32_t c=strip.Color(255,255,255);
|
||||||
strip.setPixelColor(selectedpixel-1,c);
|
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){
|
}else if(selectpixelmode==1) {
|
||||||
uint32_t c=strip.Color(0,0,0);
|
//show only selected pixel as white, everything else off
|
||||||
strip.setPixelColor(selectedpixel+1,c);
|
allBlack(0);
|
||||||
|
if (selectedpixel>=0 && selectedpixel<NUMPIXELS){
|
||||||
|
uint32_t c=strip.Color(255,255,255);
|
||||||
|
strip.setPixelColor(selectedpixel,c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strip.show();
|
strip.show();
|
||||||
|
|
Loading…
Reference in New Issue