3
0
Fork 0

millis gen

This commit is contained in:
Siwat Sirichai 2025-06-10 22:02:30 +07:00
parent 863d9c1cf3
commit 73068f7b1f
2 changed files with 27 additions and 28 deletions

View file

@ -2,7 +2,6 @@
GasolineGenerator::GasolineGenerator() GasolineGenerator::GasolineGenerator()
{ {
} }
/** /**
@ -44,7 +43,7 @@ void GasolineGenerator::initialize(DigitalInputCard* inputCard, DigitalOutputCar
*/ */
void GasolineGenerator::loop() void GasolineGenerator::loop()
{ {
unsigned long currentTime = millis(); unsigned long currentTime = (xTaskGetTickCount() * 1000) / configTICK_RATE_HZ;
switch (state) switch (state)
{ {
@ -93,7 +92,7 @@ void GasolineGenerator::start()
} }
state = GeneratorState::STARTING; state = GeneratorState::STARTING;
startupStartTime = millis(); startupStartTime = (xTaskGetTickCount() * 1000) / configTICK_RATE_HZ;
ignitionStartTime = 0; ignitionStartTime = 0;
isEngineRunning = false; isEngineRunning = false;
starterEngaged = false; starterEngaged = false;
@ -103,7 +102,7 @@ void GasolineGenerator::start()
// Step 2: Power up ignition system // Step 2: Power up ignition system
setIgnitionSystem(true); setIgnitionSystem(true);
ignitionStartTime = millis(); ignitionStartTime = (xTaskGetTickCount() * 1000) / configTICK_RATE_HZ;
} }
/** /**

View file

@ -26,14 +26,14 @@ struct GasolineGeneratorConfig
* @brief Enumeration for the generator states. * @brief Enumeration for the generator states.
* This enum defines the possible states of the gasoline generator. * This enum defines the possible states of the gasoline generator.
*/ */
enum class GeneratorState { enum class GeneratorState
{
STOPPED, STOPPED,
STARTING, STARTING,
RUNNING, RUNNING,
SHUTTING_DOWN SHUTTING_DOWN
}; };
/** /**
* @brief Gasoline Generator class for managing a gasoline-powered generator. * @brief Gasoline Generator class for managing a gasoline-powered generator.
* *