diff --git a/src/Dozer/Dozer.ino b/src/Dozer/Dozer.ino index 9690625..4d77b9f 100644 --- a/src/Dozer/Dozer.ino +++ b/src/Dozer/Dozer.ino @@ -8,11 +8,11 @@ #include #include -#define MIN_SPEED 130 +#define MIN_SPEED 90 #define DEFAULT_SPEED 180 #define MAX_SPEED 255 -#define DIAGONAL_THRESHOLD 80 +#define DIAGONAL_THRESHOLD 30 #define DEBUG false @@ -86,7 +86,7 @@ // _________________________________________________ _________________________________________________ ___________________ // // top bottom stby top bottom stby from to // // _______________________ _______________________ _______ _______________________ _______________________ _______ _______ ________________ // -Mecanum mecanum(INA2_1, INA1_1, PWMA_1, INB1_1, INB2_1, PWMB_1, STBY_1, INA1_2, INA2_2, PWMA_2, INB2_2, INB1_2, PWMB_2, STBY_2, 0, 511, 0, DEFAULT_SPEED); // +Mecanum mecanum(INA2_1, INA1_1, PWMA_1, INB1_1, INB2_1, PWMB_1, STBY_1, INA1_2, INA2_2, PWMA_2, INB2_2, INB1_2, PWMB_2, STBY_2, 0, 255, 0, DEFAULT_SPEED); // #include Mecaside left(Left, 255); @@ -102,7 +102,7 @@ LedRGB bluetoothLed(RGBA_1, RGBB_1, RGBC_1, true); LedRGB led2(RGBA_2, RGBB_2, RGBC_2, true); Digit digit(DIGITB, DIGITA, 7); -SingleServo rackServo(SERVO_2, 130, 80); +SingleServo rackServo(SERVO_3, 100, 140); StepperMotor rackStepper(STEP, DIR, LMTS_1, false, false, 3000, 2); /*, LMTS_2 */ @@ -237,34 +237,34 @@ void loop() { const int joystickY = bluetooth.message.get(JOYSTICK_LEFT_Y); if (joystickY > 255 && speedStatus != 1) { #if DEBUG - Serial.println("boost"); #endif + Serial.println("boost"); mecanum.setMaxSpeed(MAX_SPEED); speedStatus = 1; } else if (joystickY == 255 && speedStatus != 0) { #if DEBUG - Serial.println("default"); #endif + Serial.println("default"); mecanum.setMaxSpeed(DEFAULT_SPEED); speedStatus = 0; } else if (joystickY < 255 && speedStatus != 2) { #if DEBUG - Serial.println("slow"); #endif + Serial.println("slow"); mecanum.setMaxSpeed(MIN_SPEED); speedStatus = 2; } } // Simple { - left.move(constrain((-(bluetooth.message.get(JOYSTICK_RIGHT_X) - 255) + (bluetooth.message.get(JOYSTICK_LEFT_X) - 255)) + 255, 0, 512)); - right.move(constrain((-(bluetooth.message.get(JOYSTICK_RIGHT_X) - 255) - (bluetooth.message.get(JOYSTICK_LEFT_X) - 255)) + 255, 0, 512)); + left.move(constrain((-(bluetooth.message.get(JOYSTICK_RIGHT_X) - 255) + (bluetooth.message.get(JOYSTICK_LEFT_X) - 255)), -255, 255)); + right.move(constrain((-(bluetooth.message.get(JOYSTICK_RIGHT_X) - 255) - (bluetooth.message.get(JOYSTICK_LEFT_X) - 255)), -255, 255)); } // Others { - mecanum.sideway(bluetooth.message.get(JOYSTICK_RIGHT_Y)); + mecanum.sideway(bluetooth.message.get(JOYSTICK_RIGHT_Y) - 255); if (abs(bluetooth.message.get(JOYSTICK_RIGHT_X) - 255) > DIAGONAL_THRESHOLD && abs(bluetooth.message.get(JOYSTICK_RIGHT_Y) - 255) > DIAGONAL_THRESHOLD) { - mecanum.diagonal(bluetooth.message.get(JOYSTICK_RIGHT_X), bluetooth.message.get(JOYSTICK_RIGHT_Y)); + mecanum.diagonal(bluetooth.message.get(JOYSTICK_RIGHT_X) - 255, bluetooth.message.get(JOYSTICK_RIGHT_Y) - 255); } } } diff --git a/test/BluetoothTest/BluetoothTest.ino b/test/BluetoothTest/BluetoothTest.ino index d538b75..6f69b1c 100644 --- a/test/BluetoothTest/BluetoothTest.ino +++ b/test/BluetoothTest/BluetoothTest.ino @@ -3,7 +3,7 @@ #define NUM_VALUES 9 int sizes[NUM_VALUES] = { 1, 4, 8, 9, 9, 1, 9, 9, 1 }; -Bluetooth bluetooth(&Serial1, sizes, NUM_VALUES); +Bluetooth bluetooth(&Serial1, sizes, NUM_VALUES, '.'); void setup() { Serial1.begin(9600);