-
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.
Merge pull request #4 from Witty-Wizard/3-feature-implement-motor-con…
…trol-logic-for-h-bridge Added : Implementation for HBridge Control of Motor
- Loading branch information
Showing
8 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
compile: | ||
platforms: | ||
- esp32 |
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,12 +1,15 @@ | ||
#include "DriveMaster.h" | ||
|
||
DriveMaster::DriveMaster(int pin) : _pin(pin) {} | ||
DriveMaster::DriveMaster(int pin) : _pin(pin), _dir_pin(-1) {} | ||
|
||
DriveMaster::DriveMaster(int pin, int dir_pin) : _pin(pin), _dir_pin(dir_pin) {} | ||
|
||
DriveMaster::~DriveMaster() {} | ||
|
||
void DriveMaster::begin() {} | ||
|
||
void DriveMaster::write(uint16_t value, bool telemetery) {} | ||
void DriveMaster::write(int16_t value) {} | ||
|
||
void DriveMaster::sendCommand(uint16_t value) {} | ||
void DriveMaster::sendValue(uint16_t value) {} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <HBridge.h> | ||
|
||
HBridge::HBridge(int pin, int dir_pin) : DriveMaster(pin, dir_pin) | ||
{ | ||
} | ||
|
||
void HBridge::begin() | ||
{ | ||
pinMode(_pin, OUTPUT); | ||
pinMode(_dir_pin, OUTPUT); | ||
} | ||
|
||
void HBridge::write(int16_t value) | ||
{ | ||
value = value % 256; | ||
if (value >= 0) | ||
{ | ||
digitalWrite(_dir_pin, LOW); | ||
} | ||
else | ||
{ | ||
digitalWrite(_dir_pin, HIGH); | ||
value = 255 + value; | ||
} | ||
analogWrite(_pin, value); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* @file HBridge.h | ||
* @brief Header file for the HBridge class. | ||
*/ | ||
|
||
#pragma once | ||
#ifndef HBRIDGE_H | ||
#define HBRIDGE_H | ||
|
||
#include "DriveMaster.h" | ||
|
||
class HBridge : public DriveMaster{ | ||
private: | ||
|
||
public: | ||
explicit HBridge(int pin, int dir_pin); | ||
void begin() override; | ||
void write(int16_t value) override; | ||
}; | ||
|
||
#endif |
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