|
@@ -5,6 +5,8 @@
|
|
* Author: jakubski
|
|
* Author: jakubski
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
+#include <math.h>
|
|
|
|
+
|
|
#include "meas_tasks.h"
|
|
#include "meas_tasks.h"
|
|
#include "adc_buffers.h"
|
|
#include "adc_buffers.h"
|
|
#include "measurements.h"
|
|
#include "measurements.h"
|
|
@@ -337,7 +339,12 @@ void EncoderTask (void* arg) {
|
|
sensorsInfo.pvEncoderX += 360.0 / ENCODER_X_IMP_PER_TURN;
|
|
sensorsInfo.pvEncoderX += 360.0 / ENCODER_X_IMP_PER_TURN;
|
|
} else {
|
|
} else {
|
|
sensorsInfo.pvEncoderX -= 360.0 / ENCODER_X_IMP_PER_TURN;
|
|
sensorsInfo.pvEncoderX -= 360.0 / ENCODER_X_IMP_PER_TURN;
|
|
|
|
+ if(sensorsInfo.pvEncoderX < 0)
|
|
|
|
+ {
|
|
|
|
+ sensorsInfo.pvEncoderX = 360.0 + sensorsInfo.pvEncoderX;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ sensorsInfo.pvEncoderX = fmodf(sensorsInfo.pvEncoderX, 360.0);
|
|
float currentPercentPos = 100 * sensorsInfo.pvEncoderX / MAX_X_AXE_ANGLE;
|
|
float currentPercentPos = 100 * sensorsInfo.pvEncoderX / MAX_X_AXE_ANGLE;
|
|
currentPercentPos = currentPercentPos < 0 ? 0 : currentPercentPos;
|
|
currentPercentPos = currentPercentPos < 0 ? 0 : currentPercentPos;
|
|
sensorsInfo.currentXPosition = currentPercentPos > 100 ? 100 : currentPercentPos;
|
|
sensorsInfo.currentXPosition = currentPercentPos > 100 ? 100 : currentPercentPos;
|
|
@@ -347,7 +354,12 @@ void EncoderTask (void* arg) {
|
|
sensorsInfo.pvEncoderY += 360.0 / ENCODER_Y_IMP_PER_TURN;
|
|
sensorsInfo.pvEncoderY += 360.0 / ENCODER_Y_IMP_PER_TURN;
|
|
} else {
|
|
} else {
|
|
sensorsInfo.pvEncoderY -= 360.0 / ENCODER_Y_IMP_PER_TURN;
|
|
sensorsInfo.pvEncoderY -= 360.0 / ENCODER_Y_IMP_PER_TURN;
|
|
|
|
+ if(sensorsInfo.pvEncoderY < 0)
|
|
|
|
+ {
|
|
|
|
+ sensorsInfo.pvEncoderY = 360.0 + sensorsInfo.pvEncoderY;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ sensorsInfo.pvEncoderY = fmodf(sensorsInfo.pvEncoderY, 360.0);
|
|
float currentPercentPos = 100 * sensorsInfo.pvEncoderY / MAX_X_AXE_ANGLE;
|
|
float currentPercentPos = 100 * sensorsInfo.pvEncoderY / MAX_X_AXE_ANGLE;
|
|
currentPercentPos = currentPercentPos < 0 ? 0 : currentPercentPos;
|
|
currentPercentPos = currentPercentPos < 0 ? 0 : currentPercentPos;
|
|
sensorsInfo.currentXPosition = currentPercentPos > 100 ? 100 : currentPercentPos;
|
|
sensorsInfo.currentXPosition = currentPercentPos > 100 ? 100 : currentPercentPos;
|