ball read: fix major bug in reading ballSeen

docs
EmaMaker 2021-01-11 15:40:21 +01:00
parent 732298b7db
commit 69284cb009
1 changed files with 4 additions and 2 deletions

View File

@ -11,7 +11,7 @@ DataSourceBall :: DataSourceBall(HardwareSerial* ser_, int baud) : DataSource(se
void DataSourceBall :: postProcess(){ void DataSourceBall :: postProcess(){
if((value & 0x01) == 1){ if((value & 0x01) == 1){
distance = value; distance = value;
ballSeen = distance > 1; ballSeen = distance == 255 ? 0 : 1;
}else{ }else{
angle = value * 2; angle = value * 2;
} }
@ -26,7 +26,9 @@ void DataSourceBall :: test(){
if(ballSeen){ if(ballSeen){
DEBUG.print(angle); DEBUG.print(angle);
DEBUG.print(" | "); DEBUG.print(" | ");
DEBUG.println(distance); DEBUG.print(distance);
DEBUG.print(" | ");
DEBUG.println(ballSeen);
}else{ }else{
DEBUG.println("Not seeing ball"); DEBUG.println("Not seeing ball");
} }