Skip to content

Commit

Permalink
make DCMotor.init() return int indicating success
Browse files Browse the repository at this point in the history
  • Loading branch information
runger1101001 committed Jul 21, 2024
1 parent 11917d8 commit 0252d30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/DCMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ void DCMotor::linkDriver(DCDriver* driver) {
};


void DCMotor::init() {
int DCMotor::init() {
if (!driver || !driver->initialized) {
motor_status = FOCMotorStatus::motor_init_failed;
SIMPLEFOC_DEBUG("MOT: Init not possible, driver not initialized");
return;
return 0;
}
if (!sensor) {
motor_status = FOCMotorStatus::motor_init_failed;
SIMPLEFOC_DEBUG("MOT: Init not possible, sensor not initialized");
return;
return 0;
}

motor_status = FOCMotorStatus::motor_initializing;
Expand Down Expand Up @@ -62,6 +62,7 @@ void DCMotor::init() {
}

motor_status = FOCMotorStatus::motor_ready;
return 1;
};


Expand Down
2 changes: 1 addition & 1 deletion src/DCMotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DCMotor : public FOCMotor {
DCDriver* driver;

/** Motor hardware init function */
void init() override;
int init() override;
/** Motor disable function */
void disable() override;
/** Motor enable function */
Expand Down

0 comments on commit 0252d30

Please sign in to comment.