mode test
This commit is contained in:
@@ -48,8 +48,10 @@ bool DW640::initialize() {
|
|||||||
printf("No 640 board found\n");
|
printf("No 640 board found\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
// set the default frequency
|
||||||
this->pwm->setFrequency( 100 );
|
setFrequency( 100 );
|
||||||
|
// set the default mode to ININ
|
||||||
|
setMode( DW_ININ );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,3 +61,35 @@ bool DW640::initialize() {
|
|||||||
bool DW640::testConnection() {
|
bool DW640::testConnection() {
|
||||||
return this->pwm->testConnection();
|
return this->pwm->testConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Calculate prescale value based on the specified frequency and write it to the device.
|
||||||
|
* @return Frequency in Hz
|
||||||
|
*/
|
||||||
|
float DW640::getFrequency() {
|
||||||
|
return this->pwm->getFrequency();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Calculate prescale value based on the specified frequency and write it to the device.
|
||||||
|
* @param Frequency in Hz
|
||||||
|
*/
|
||||||
|
void DW640::setFrequency(float frequency) {
|
||||||
|
this->pwm->setFrequency( frequency );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Calculate prescale value based on the specified frequency and write it to the device.
|
||||||
|
* @return Frequency in Hz
|
||||||
|
*/
|
||||||
|
uint8_t DW640::getMode() {
|
||||||
|
return this->mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Calculate prescale value based on the specified frequency and write it to the device.
|
||||||
|
* @param Frequency in Hz
|
||||||
|
*/
|
||||||
|
void DW640::setMode(uint8_t mode) {
|
||||||
|
this->modePin = new PIN( RPI_GPIO_27 );
|
||||||
|
this->modePin->setMode(Pin::GpioModeOutput);
|
||||||
|
this->modePin->write( mode );
|
||||||
|
}
|
||||||
@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "PCA9685.h"
|
#include "PCA9685.h"
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
#define DW640_DEFAULT_ADDRESS 0x60 // 640 default
|
#define DW640_DEFAULT_ADDRESS 0x60 // 640 default
|
||||||
|
|
||||||
@@ -53,8 +54,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#define DW_INTERLEAVE 3
|
#define DW_INTERLEAVE 3
|
||||||
#define DW_MICROSTEP 4
|
#define DW_MICROSTEP 4
|
||||||
|
|
||||||
#define DW_ININ 5
|
#define DW_ININ 0
|
||||||
#define DW_PHASE 6
|
#define DW_PHASE 1
|
||||||
|
|
||||||
class DW640 {
|
class DW640 {
|
||||||
public:
|
public:
|
||||||
@@ -63,11 +64,11 @@ class DW640 {
|
|||||||
bool initialize();
|
bool initialize();
|
||||||
bool testConnection();
|
bool testConnection();
|
||||||
|
|
||||||
// float getFrequency();
|
float getFrequency();
|
||||||
// void setFrequency(float frequency);
|
void setFrequency(float frequency);
|
||||||
|
|
||||||
// float getMode();
|
uint8_t getMode();
|
||||||
// void setMode(float frequency);
|
void setMode(uint8_t mode);
|
||||||
|
|
||||||
// void setPin(uint8_t channel, uint16_t value);
|
// void setPin(uint8_t channel, uint16_t value);
|
||||||
// void setAllPin(uint16_t value);
|
// void setAllPin(uint16_t value);
|
||||||
@@ -101,6 +102,7 @@ class DW640 {
|
|||||||
float frequency;
|
float frequency;
|
||||||
uint8_t mode;
|
uint8_t mode;
|
||||||
PCA9685* pwm;
|
PCA9685* pwm;
|
||||||
|
PIN* modePin;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DW640_H
|
#endif // DW640_H
|
||||||
@@ -27,10 +27,6 @@ int main()
|
|||||||
DW640 dw;
|
DW640 dw;
|
||||||
dw.initialize();
|
dw.initialize();
|
||||||
|
|
||||||
if(dw.testConnection()) {
|
|
||||||
printf("OK %4.f ", 2000);
|
|
||||||
} else {
|
|
||||||
printf("Not Ok %4.f ", 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user