-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: version 4.6.2 fix the motor bug
- Loading branch information
Showing
8 changed files
with
101 additions
and
149 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
Basic_Development/New_Car_Control/Encoder_Base/DC_MotoTest.cpp
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,28 @@ | ||
/** | ||
* | ||
* @author FENN MAI | ||
* @date 06/05/2024 | ||
* @version Basic 4.0 | ||
* @brief 编码电机初次测试 | ||
*/ | ||
|
||
#ifndef _ENCODER_H_ | ||
#define _ENCODER_H_ | ||
#ifndef ENCODER_H | ||
#define ENCODER_H | ||
|
||
#include <pigpio.h> | ||
|
||
typedef void (*encoderCallback_t)(int); | ||
typedef void (*encoderCallback_t)(int direction); | ||
|
||
class Encoder { | ||
public: | ||
Encoder(int gpioA, int gpioB, encoderCallback_t callback = nullptr); | ||
~Encoder(); | ||
int32_t getPosition(); | ||
int getPosition(); | ||
void reset(); | ||
int getDirection(); // 新增方法,获取方向 | ||
int getDirection(); | ||
|
||
private: | ||
int gpioA, gpioB; | ||
int32_t position; | ||
int lastGpio; | ||
int position; | ||
int direction; | ||
int levA, levB; | ||
int lastGpio; | ||
encoderCallback_t callback; | ||
int direction; // 记录方向 | ||
|
||
static void _pulseEx(int gpio, int level, uint32_t tick, void *user); | ||
void _pulse(int gpio, int level, uint32_t tick); | ||
static void _pulseEx(int gpio, int level, uint32_t tick, void *user); | ||
}; | ||
|
||
#endif | ||
#endif // ENCODER_H |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters