Make car mass configurable at runtime
Replace the compile‑time CAR_MASS constant with a runtime‑settable _member _carMass. Add Engine::setCarMass, default it to 1200 kg, and use it in the acceleration calculation. Prompt the user for the car mass on startup via Serial and update the enable/disable messages.
This commit is contained in:
@@ -13,7 +13,6 @@ constexpr float GEAR_RATIO[6] = {
|
||||
|
||||
constexpr float FINAL_DRIVE = 3.74f; // przekładnia różnicowa
|
||||
constexpr float WHEEL_RADIUS = 0.30f; // m
|
||||
constexpr float CAR_MASS = 1200.0f; // kg
|
||||
constexpr float RPM_IDLE = 800.0f; // obroty jałowe
|
||||
constexpr float RPM_MAX = 7000.0f; // maksymalne obroty
|
||||
|
||||
@@ -31,6 +30,8 @@ public:
|
||||
|
||||
void begin();
|
||||
|
||||
void setCarMass(float mass) { _carMass = mass; }
|
||||
|
||||
void update(float dt, uint8_t gearIdx);
|
||||
|
||||
int getRPM() const;
|
||||
@@ -46,6 +47,7 @@ private:
|
||||
|
||||
float _engineRPM = EngineConsts::RPM_IDLE;
|
||||
float _speedMs = 0.0f;
|
||||
float _carMass = 1200.0f;
|
||||
|
||||
float readNormalized(uint8_t pin) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user