Umstellung der Abbremsung auf durchgängig float

This commit is contained in:
2023-05-18 23:12:14 +02:00
parent 349d1d644e
commit a5f5b18a27
2 changed files with 5 additions and 5 deletions

View File

@@ -60,7 +60,7 @@ void Locomotive::Break()
void Locomotive::setSpeed(byte Speed)
{
_currentSpeed = Speed;
_motor.setSpeed(_currentSpeed);
_motor.setSpeed( (int) (_currentSpeed+0.5));
};
void Locomotive::setDirection(MotorDirection dir)
@@ -76,7 +76,7 @@ void Locomotive::loop()
currentMillis = millis();
if (currentMillis - _millisStart >= _delay) //test whether the period has elapsed
{
byte newspeed;
float newspeed;
newspeed = _currentSpeed + _currentAcc;
/* Serial.print("Locomotive.Loop: ");
Serial.print(_currentSpeed);
@@ -109,7 +109,7 @@ void Locomotive::loop()
byte Locomotive::currentSpeed()
{
return _currentSpeed;
return ((byte) (_currentSpeed+0.5));
};
byte Locomotive::getDefaultSpeed()

View File

@@ -22,13 +22,13 @@ class Locomotive
private:
int _accelerate;
int _decelerate;
int _currentAcc;
float _currentAcc;
byte _minSpeed;
byte _maxSpeed;
byte _targetSpeed;
const unsigned int _delay=300;
unsigned long _millisStart;
byte _currentSpeed;
float _currentSpeed;
IMotor& _motor;
};