178178#define STEPPER_GET_DISTANCE_TO_GO 52
179179#define STEPPER_GET_TARGET_POSITION 53
180180#define GET_FEATURES 54
181+ #define SONAR_SCAN_OFF 55
182+ #define SONAR_SCAN_ON 56
181183
182184
183185/* Command Forward References*/
@@ -297,6 +299,10 @@ extern void stepper_is_running();
297299
298300extern void get_features ();
299301
302+ extern void sonar_disable ();
303+
304+ extern void sonar_enable ();
305+
300306// When adding a new command update the command_table.
301307// The command length is the number of bytes that follow
302308// the command byte itself, and does not include the command
@@ -370,6 +376,8 @@ command_descriptor command_table[] =
370376 {&stepper_get_distance_to_go},
371377 (&stepper_get_target_position),
372378 (&get_features),
379+ (&sonar_disable),
380+ (&sonar_enable),
373381};
374382
375383
@@ -405,6 +413,7 @@ byte command_buffer[MAX_COMMAND_LENGTH];
405413#define STEPPER_RUNNING_REPORT 18
406414#define STEPPER_RUN_COMPLETE_REPORT 19
407415#define FEATURES 20
416+
408417#define DEBUG_PRINT 99
409418
410419#ifdef I2C_ENABLED
@@ -420,6 +429,8 @@ byte spi_report_message[64];
420429
421430bool stop_reports = false ; // a flag to stop sending all report messages
422431
432+ bool sonar_reporting_enabled = true ; // flag to start and stop sonar reporing
433+
423434// Input pin reporting control sub commands (modify_reporting)
424435#define REPORTING_DISABLE_ALL 0
425436#define REPORTING_ANALOG_ENABLE 1
@@ -434,7 +445,7 @@ bool stop_reports = false; // a flag to stop sending all report messages
434445
435446// firmware version - update this when bumping the version
436447#define FIRMWARE_MAJOR 5
437- #define FIRMWARE_MINOR 1
448+ #define FIRMWARE_MINOR 2
438449#define FIRMWARE_PATCH 1
439450
440451
@@ -1074,6 +1085,14 @@ void sonar_new()
10741085#endif
10751086}
10761087
1088+ void sonar_disable (){
1089+ sonar_reporting_enabled = false ;
1090+ }
1091+
1092+ void sonar_enable (){
1093+ sonar_reporting_enabled = true ;
1094+ }
1095+
10771096/* **********************************
10781097 DHT adding a new device
10791098 **********************************/
@@ -2039,7 +2058,9 @@ void loop()
20392058 scan_analog_inputs ();
20402059
20412060#ifdef SONAR_ENABLED
2042- scan_sonars ();
2061+ if (sonar_reporting_enabled ){
2062+ scan_sonars ();
2063+ }
20432064#endif
20442065
20452066#ifdef DHT_ENABLED
0 commit comments