spindle: add debug stuff
parent
d7576256c9
commit
11e6dd75c7
|
@ -4,6 +4,7 @@
|
|||
|
||||
#define DEBUG_I2C 0
|
||||
#define DEBUG_PRINT_EVENTS 1
|
||||
#define DEBUG_DISABLE_SPINDLE 1
|
||||
|
||||
// --- pinout
|
||||
|
||||
|
|
|
@ -1,14 +1,30 @@
|
|||
#include <AS5600.h>
|
||||
#include <Wire.h>
|
||||
#include "spindle.h"
|
||||
#include "constants.h"
|
||||
|
||||
AS5600 spindle(&Wire);
|
||||
|
||||
bool setupSpindle() {
|
||||
#if DEBUG_DISABLE_SPINDLE
|
||||
Serial.println("Skipping spindle");
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if (!spindle.begin()) {
|
||||
Serial.println("Could not initialize spindle encoder");
|
||||
return false;
|
||||
} else if (!spindle.detectMagnet()) {
|
||||
}
|
||||
|
||||
if (!validateSpindle()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool validateSpindle() {
|
||||
if (!spindle.detectMagnet()) {
|
||||
Serial.println("Could not detect magnet");
|
||||
return false;
|
||||
} else if (spindle.magnetTooWeak()) {
|
||||
|
@ -25,3 +41,8 @@ bool setupSpindle() {
|
|||
uint16_t getSpindlePosition() {
|
||||
return spindle.readAngle();
|
||||
}
|
||||
|
||||
void spindleDemo() {
|
||||
validateSpindle();
|
||||
Serial.println(getSpindlePosition());
|
||||
}
|
||||
|
|
|
@ -3,3 +3,5 @@
|
|||
bool setupSpindle();
|
||||
/** 0..4095 (12-bit) */
|
||||
uint16_t getSpindlePosition();
|
||||
bool validateSpindle();
|
||||
void spindleDemo();
|
||||
|
|
Loading…
Reference in New Issue