Umstellung der Abbremsung auf durchgängig float
This commit is contained in:
@@ -60,7 +60,7 @@ void Locomotive::Break()
|
|||||||
void Locomotive::setSpeed(byte Speed)
|
void Locomotive::setSpeed(byte Speed)
|
||||||
{
|
{
|
||||||
_currentSpeed = Speed;
|
_currentSpeed = Speed;
|
||||||
_motor.setSpeed(_currentSpeed);
|
_motor.setSpeed( (int) (_currentSpeed+0.5));
|
||||||
};
|
};
|
||||||
|
|
||||||
void Locomotive::setDirection(MotorDirection dir)
|
void Locomotive::setDirection(MotorDirection dir)
|
||||||
@@ -76,7 +76,7 @@ void Locomotive::loop()
|
|||||||
currentMillis = millis();
|
currentMillis = millis();
|
||||||
if (currentMillis - _millisStart >= _delay) //test whether the period has elapsed
|
if (currentMillis - _millisStart >= _delay) //test whether the period has elapsed
|
||||||
{
|
{
|
||||||
byte newspeed;
|
float newspeed;
|
||||||
newspeed = _currentSpeed + _currentAcc;
|
newspeed = _currentSpeed + _currentAcc;
|
||||||
/* Serial.print("Locomotive.Loop: ");
|
/* Serial.print("Locomotive.Loop: ");
|
||||||
Serial.print(_currentSpeed);
|
Serial.print(_currentSpeed);
|
||||||
@@ -109,7 +109,7 @@ void Locomotive::loop()
|
|||||||
|
|
||||||
byte Locomotive::currentSpeed()
|
byte Locomotive::currentSpeed()
|
||||||
{
|
{
|
||||||
return _currentSpeed;
|
return ((byte) (_currentSpeed+0.5));
|
||||||
};
|
};
|
||||||
|
|
||||||
byte Locomotive::getDefaultSpeed()
|
byte Locomotive::getDefaultSpeed()
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ class Locomotive
|
|||||||
private:
|
private:
|
||||||
int _accelerate;
|
int _accelerate;
|
||||||
int _decelerate;
|
int _decelerate;
|
||||||
int _currentAcc;
|
float _currentAcc;
|
||||||
byte _minSpeed;
|
byte _minSpeed;
|
||||||
byte _maxSpeed;
|
byte _maxSpeed;
|
||||||
byte _targetSpeed;
|
byte _targetSpeed;
|
||||||
const unsigned int _delay=300;
|
const unsigned int _delay=300;
|
||||||
unsigned long _millisStart;
|
unsigned long _millisStart;
|
||||||
byte _currentSpeed;
|
float _currentSpeed;
|
||||||
IMotor& _motor;
|
IMotor& _motor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user