spindle: add debug stuff

main
radex 2024-03-17 18:14:33 +01:00
parent d7576256c9
commit 11e6dd75c7
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
3 changed files with 25 additions and 1 deletions

View File

@ -4,6 +4,7 @@
#define DEBUG_I2C 0
#define DEBUG_PRINT_EVENTS 1
#define DEBUG_DISABLE_SPINDLE 1
// --- pinout

View File

@ -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());
}

View File

@ -3,3 +3,5 @@
bool setupSpindle();
/** 0..4095 (12-bit) */
uint16_t getSpindlePosition();
bool validateSpindle();
void spindleDemo();