mirror of
https://github.com/DashyFox/StackSport.git
synced 2025-06-28 05:09:32 +00:00
upd
This commit is contained in:
@ -52,6 +52,10 @@ HardwareInit_t hwSettings = {
|
||||
extern int16_t Vz1;
|
||||
extern int16_t Vz2;
|
||||
|
||||
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
void doShot(Shot *shot) {
|
||||
SetServo(0, shot->rotationHorizontal);
|
||||
SetServo(1, shot->rotationVertical);
|
||||
@ -99,13 +103,10 @@ void startShooting() {
|
||||
void stopShooting() {
|
||||
isShooting = 0;
|
||||
isPause = 0;
|
||||
|
||||
setScrewkSpeed(0);
|
||||
setRollersSpeed(100, 100);
|
||||
setPosDefault();
|
||||
Vz1 = 100;
|
||||
Vz2 = 100;
|
||||
TIM1->CCR1 = 0;
|
||||
TIM1->CCR2 = 0;
|
||||
}
|
||||
|
||||
void doShotForever(uint8_t number) {
|
||||
@ -135,16 +136,18 @@ void setPos(uint8_t axial, uint8_t horizontal, uint8_t vertical) {
|
||||
SetServo(SERVO_VERTICAL, vertical); // Vertical
|
||||
}
|
||||
void setPosDefault() {
|
||||
SetServo(0, 90); // Axial
|
||||
SetServo(1, 90); // Horizontal
|
||||
SetServo(2, 90); // Vertical
|
||||
SetServo(SERVO_AXIAL, hwSettings.servos[SERVO_AXIAL].def); // Axial
|
||||
SetServo(SERVO_HORIZONTAL, hwSettings.servos[SERVO_HORIZONTAL].def); // Horizontal
|
||||
SetServo(SERVO_VERTICAL, hwSettings.servos[SERVO_VERTICAL].def); // Vertical
|
||||
}
|
||||
|
||||
// 0 .. 100
|
||||
void setScrewkSpeed(uint8_t speed) {
|
||||
|
||||
if(speed && speed < hwSettings.motors.speed_Screw_min)
|
||||
speed = hwSettings.motors.speed_Screw_min;
|
||||
// if(speed < 0) speed = 0;
|
||||
if(speed > 100) speed = 100;
|
||||
|
||||
speed = map(speed, 0, 100, hwSettings.motors.speed_Screw_min, 100);
|
||||
|
||||
TIM1->CCR1 = 0;
|
||||
TIM1->CCR2 = (uint16_t)(40 * speed);
|
||||
@ -153,6 +156,18 @@ void setScrewkSpeed(uint8_t speed) {
|
||||
//(-v) 0 .. 100(stop) .. 200(+v)
|
||||
void setRollersSpeed(uint8_t up, uint8_t down) {
|
||||
|
||||
if(up < 100){
|
||||
up = map(up, 0, 100, 0, 100-hwSettings.motors.speed_Screw_min);
|
||||
} else {
|
||||
up = map(up, 0, 100, 0, 100+hwSettings.motors.speed_Screw_min);
|
||||
}
|
||||
|
||||
if(down < 100){
|
||||
map(down, 0, 100, 0, 100-hwSettings.motors.speed_Screw_min);
|
||||
} else {
|
||||
map(down, 0, 100, 0, 100+hwSettings.motors.speed_Screw_min);
|
||||
}
|
||||
|
||||
Vz1 = 200-up; // invert
|
||||
Vz2 = down;
|
||||
}
|
||||
|
Reference in New Issue
Block a user