Skip to content

Commit 4690e16

Browse files
Merge pull request #303 from runger1101001/dev
fix errors and warnings on SIMPLEFOC_DISABLE_DEBUG
2 parents 04a8a88 + 2252605 commit 4690e16

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/BLDCMotor.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int BLDCMotor::initFOC() {
167167
exit_flag *= alignCurrentSense();
168168
}
169169
}
170-
else SIMPLEFOC_DEBUG("MOT: No current sense.");
170+
else { SIMPLEFOC_DEBUG("MOT: No current sense."); }
171171
}
172172

173173
if(exit_flag){
@@ -252,10 +252,11 @@ int BLDCMotor::alignSensor() {
252252
// check pole pair number
253253
if( fabs(moved*pole_pairs - _2PI) > 0.5f ) { // 0.5f is arbitrary number it can be lower or higher!
254254
SIMPLEFOC_DEBUG("MOT: PP check: fail - estimated pp: ", _2PI/moved);
255-
} else
255+
} else {
256256
SIMPLEFOC_DEBUG("MOT: PP check: OK!");
257+
}
257258

258-
} else SIMPLEFOC_DEBUG("MOT: Skip dir calib.");
259+
} else { SIMPLEFOC_DEBUG("MOT: Skip dir calib."); }
259260

260261
// zero electric angle not known
261262
if(!_isset(zero_electric_angle)){
@@ -276,7 +277,7 @@ int BLDCMotor::alignSensor() {
276277
// stop everything
277278
setPhaseVoltage(0, 0, 0);
278279
_delay(200);
279-
}else SIMPLEFOC_DEBUG("MOT: Skip offset calib.");
280+
} else { SIMPLEFOC_DEBUG("MOT: Skip offset calib."); }
280281
return exit_flag;
281282
}
282283

@@ -305,8 +306,8 @@ int BLDCMotor::absoluteZeroSearch() {
305306
voltage_limit = limit_volt;
306307
// check if the zero found
307308
if(monitor_port){
308-
if(sensor->needsSearch()) SIMPLEFOC_DEBUG("MOT: Error: Not found!");
309-
else SIMPLEFOC_DEBUG("MOT: Success!");
309+
if(sensor->needsSearch()) { SIMPLEFOC_DEBUG("MOT: Error: Not found!"); }
310+
else { SIMPLEFOC_DEBUG("MOT: Success!"); }
310311
}
311312
return !sensor->needsSearch();
312313
}

src/StepperMotor.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ int StepperMotor::initFOC() {
114114
// added the shaft_angle update
115115
sensor->update();
116116
shaft_angle = sensor->getAngle();
117-
}else SIMPLEFOC_DEBUG("MOT: No sensor.");
117+
} else { SIMPLEFOC_DEBUG("MOT: No sensor."); }
118118

119119
if(exit_flag){
120120
SIMPLEFOC_DEBUG("MOT: Ready.");
@@ -177,10 +177,13 @@ int StepperMotor::alignSensor() {
177177
float moved = fabs(mid_angle - end_angle);
178178
if( fabs(moved*pole_pairs - _2PI) > 0.5f ) { // 0.5f is arbitrary number it can be lower or higher!
179179
SIMPLEFOC_DEBUG("MOT: PP check: fail - estimated pp: ", _2PI/moved);
180-
} else
180+
} else {
181181
SIMPLEFOC_DEBUG("MOT: PP check: OK!");
182+
}
182183

183-
}else SIMPLEFOC_DEBUG("MOT: Skip dir calib.");
184+
} else {
185+
SIMPLEFOC_DEBUG("MOT: Skip dir calib.");
186+
}
184187

185188
// zero electric angle not known
186189
if(!_isset(zero_electric_angle)){
@@ -200,7 +203,7 @@ int StepperMotor::alignSensor() {
200203
// stop everything
201204
setPhaseVoltage(0, 0, 0);
202205
_delay(200);
203-
}else SIMPLEFOC_DEBUG("MOT: Skip offset calib.");
206+
} else { SIMPLEFOC_DEBUG("MOT: Skip offset calib."); }
204207
return exit_flag;
205208
}
206209

@@ -229,7 +232,7 @@ int StepperMotor::absoluteZeroSearch() {
229232
// check if the zero found
230233
if(monitor_port){
231234
if(sensor->needsSearch()) SIMPLEFOC_DEBUG("MOT: Error: Not found!");
232-
else SIMPLEFOC_DEBUG("MOT: Success!");
235+
else { SIMPLEFOC_DEBUG("MOT: Success!"); }
233236
}
234237
return !sensor->needsSearch();
235238
}

src/common/base_classes/FOCMotor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ float FOCMotor::electricalAngle(){
8282
// function implementing the monitor_port setter
8383
void FOCMotor::useMonitoring(Print &print){
8484
monitor_port = &print; //operate on the address of print
85+
#ifndef SIMPLEFOC_DISABLE_DEBUG
8586
SimpleFOCDebug::enable(&print);
8687
SIMPLEFOC_DEBUG("MOT: Monitor enabled!");
88+
#endif
8789
}
8890

8991
// utility function intended to be used with serial plotter to monitor motor variables

0 commit comments

Comments
 (0)