Denk proof backup #5

This commit is contained in:
Blboun3 2023-11-10 14:49:37 +01:00
parent f26155ba17
commit 3d971d9f55
2 changed files with 15 additions and 6 deletions

BIN
app

Binary file not shown.

21
app.cpp
View File

@ -105,7 +105,7 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens
{
const int LEFT_THRESHOLD = -2;
const int RIGHT_THRESHOLD = 2;
const int CORRECTION_MULTIPLIER = 20;
const int CORRECTION_MULTIPLIER = 10;
const int CYCLE_LIMIT = 90;
gyro.resetHard();
@ -146,8 +146,8 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens
// To the left
if (angle < LEFT_THRESHOLD) {
//ev3_speaker_play_tone(NOTE_A5, 250);
int correction = angle - LEFT_THRESHOLD;
motor_powers.lMotorPWR = motor_powers.lMotorPWR + ((int)pow(CORRECTION_MULTIPLIER, correction));//(int)pow(CORRECTION_MULTIPLIER, correction);
int correction = ev3cxx::abs(angle - LEFT_THRESHOLD);
motor_powers.lMotorPWR = motor_powers.rMotorPWR + (correction * CORRECTION_MULTIPLIER);//(int)pow(CORRECTION_MULTIPLIER, correction);
ev3_speaker_play_tone(correction*1000,30);
// Check if the motor is stuck
if(lPower == 0){
@ -158,8 +158,8 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens
// To the right
} else if (angle > RIGHT_THRESHOLD) {
//ev3_speaker_play_tone(NOTE_A4, 250);
int correction = angle - RIGHT_THRESHOLD;
motor_powers.rMotorPWR = motor_powers.rMotorPWR + ((int)pow(CORRECTION_MULTIPLIER, correction));//(int)pow(CORRECTION_MULTIPLIER, correction);//correction * CORRECTION_MULTIPLIER;
int correction = ev3cxx::abs(angle - RIGHT_THRESHOLD);
motor_powers.rMotorPWR = motor_powers.lMotorPWR + (correction * CORRECTION_MULTIPLIER);//(int)pow(CORRECTION_MULTIPLIER, correction);//correction * CORRECTION_MULTIPLIER;
ev3_speaker_play_tone(correction*1000,30);
// Check if the motor is stuck
if(rPower == 0){
@ -183,7 +183,7 @@ void main_task(intptr_t unused)
// Create version info
// version createVersion(int versionID, const char *codename, int major, int minor, int patch, int day, int month, int year, int hour, int minute)
const version VERSION = createVersion(58, "HELGA", 0, 4, 1, 10, 11, 2023, 12, 10);
const version VERSION = createVersion(62, "HELGA", 0, 4, 2, 10, 11, 2023, 14, 40);
// Set-up screen
ev3cxx::display.resetScreen();
@ -192,6 +192,8 @@ void main_task(intptr_t unused)
// Print version information on screen
ev3cxx::display.format(" DOBREMYSL\nVERSION: % .% .% #% \nNAME: % ") % VERSION.major % VERSION.minor % VERSION.patch % VERSION.id % VERSION.codename;
ev3cxx::statusLight.setColor(ev3cxx::StatusLightColor::GREEN);
// Play starting melody
ev3_speaker_set_volume(100);
ev3_speaker_play_tone(NOTE_C5, 400);
@ -234,6 +236,13 @@ void main_task(intptr_t unused)
//turn_left(motors);
bool side_1 = run_short_side(motors, motor_powers, gyro);
ev3_speaker_play_tone(NOTE_C4, 250);
ev3_speaker_play_tone(NOTE_C4, 125);
ev3_speaker_play_tone(NOTE_D4, 250);
ev3_speaker_play_tone(NOTE_C4, 250);
ev3_speaker_play_tone(NOTE_B4, 750);
if(!side_1) {
return;
} else {