MakeBlock Drive Updated Updated library for MakeBlock Ranger

Loading...
Searching...
No Matches
MeMegaPiDCMotor.h
Go to the documentation of this file.
1
41#ifndef MeMegaPiDCMotor_H
42#define MeMegaPiDCMotor_H
43
44#include <stdint.h>
45#include <stdbool.h>
46#include <Arduino.h>
47#include "MeConfig.h"
48
49 typedef struct
50{
51 uint8_t dc_dir_h1;
52 uint8_t dc_dir_h2;
53 uint8_t pwm_pin; //PWM
54} megapi_dc_type;
55
56 extern megapi_dc_type megapi_dc_Port[14]; // megapi_dc_Port[0] is nonsense
57
63 class MeMegaPiDCMotor
64{
65 public:
72 MeMegaPiDCMotor(void);
73
79 MeMegaPiDCMotor(uint8_t port);
80
91 MeMegaPiDCMotor(uint8_t dc_dir_h1,uint8_t dc_dir_h2,uint8_t pwm_pin);
92
107 void reset(uint8_t port);
108
127 void setpin(uint8_t dc_dir_h1,uint8_t dc_dir_h2,uint8_t pwm_pin);
128
143 void run(int16_t speed);
144
157 void stop(void);
158 private:
159 volatile uint8_t _dc_dir_h1;
160 volatile uint8_t _dc_dir_h2;
161 volatile uint8_t _dc_pwm_pin;
162 volatile int16_t last_speed;
163};
164#endif //MeMegaPiDCMotor_H
165
MeConfig.h
Configuration file of library.
MeMegaPiDCMotor
Driver for Me Megapi DC motor device.
Definition MeMegaPiDCMotor.h:64
MeMegaPiDCMotor::reset
void reset(uint8_t port)
Definition MeMegaPiDCMotor.cpp:207
MeMegaPiDCMotor::stop
void stop(void)
Definition MeMegaPiDCMotor.cpp:309
MeMegaPiDCMotor::MeMegaPiDCMotor
MeMegaPiDCMotor(void)
Definition MeMegaPiDCMotor.cpp:51
MeMegaPiDCMotor::setpin
void setpin(uint8_t dc_dir_h1, uint8_t dc_dir_h2, uint8_t pwm_pin)
Definition MeMegaPiDCMotor.cpp:236
MeMegaPiDCMotor::run
void run(int16_t speed)
Definition MeMegaPiDCMotor.cpp:261
megapi_dc_type
Definition MeMegaPiDCMotor.h:50