Commented out all logging lines as it was using too much RAM

This commit is contained in:
Mark van Renswoude 2020-02-02 12:32:12 +01:00
parent b9f5394d53
commit b446d0fa98
5 changed files with 28 additions and 28 deletions

View File

@ -13,11 +13,11 @@
every loop. Only turn on when required.
At the time of writing, turning both on uses more RAM
than the ATMega328P has.
Due to RAM/flash constraints, most logging lines have
been commented out as it would take up around 1.5k of RAM
and 4k of flash otherwise, which we don't have.
Uncomment those lines as required.
Turning DebugLog off saves around 1k of RAM and 3k of flash.
Turning VerboseLog off saves around 300 bytes of RAM and 1k of flash.
*/
//#define DebugLog
//#define VerboseLog

View File

@ -12,7 +12,7 @@ ControlManager Control = ControlManager();
VL53L0XInitResult ControlManager::init()
{
dln("[ CONTROL ] Initializing");
//dln("[ CONTROL ] Initializing");
Wire.begin();
this->heightSensor.setTimeout(500);
@ -36,14 +36,14 @@ ControlUpdateResult ControlManager::update()
: VL53L0XRangeNotReady;
vl("[ CONTROL ] Update: asyncReading = "); vl(asyncReading); vl(", measurement = "); vl(measurement);
vl(", moveDirection = "); vl((uint8_t)this->moveDirection); vl(", stabilizationStart = "); vln(this->stabilizationStart);
//vl("[ CONTROL ] Update: asyncReading = "); vl(asyncReading); vl(", measurement = "); vl(measurement);
//vl(", moveDirection = "); vl((uint8_t)this->moveDirection); vl(", stabilizationStart = "); vln(this->stabilizationStart);
bool moving = this->moveDirection != MoveDirection::None && this->stabilizationStart == 0;
if (!moving && this->stabilizationStart == 0)
{
vl("[ CONTROL ] Idle");
//vl("[ CONTROL ] Idle");
return ControlUpdateResult::Idle;
}
@ -55,7 +55,7 @@ ControlUpdateResult ControlManager::update()
if (motorIsOvercurrent())
{
dln("[ CONTROL ] Overcurrent detected!");
//dln("[ CONTROL ] Overcurrent detected!");
this->moveStop();
return ControlUpdateResult::Overcurrent;
@ -65,7 +65,7 @@ ControlUpdateResult ControlManager::update()
// Read sensor
if (!asyncReading)
{
vln("[ CONTROL ] Starting async read");
//vln("[ CONTROL ] Starting async read");
heightSensor.asyncStartReadRangeSingleMillimeters();
}
@ -77,7 +77,7 @@ ControlUpdateResult ControlManager::update()
measurement = VL53L0XRangeTimeout;
dl("[ CONTROL ] Measurement: "); dln(measurement);
//dl("[ CONTROL ] Measurement: "); dln(measurement);
this->lastMeasurement = measurement != VL53L0XRangeTimeout ? measurement : 0;
}
@ -103,7 +103,7 @@ ControlUpdateResult ControlManager::update()
// While moving, allow incidental invalid results
if (CurrentTime - lastValidMeasurement >= Config::HeightMeasurementAbortTimeout)
{
dln("[ CONTROL ] Timeout while moving!");
//dln("[ CONTROL ] Timeout while moving!");
this->moveStop();
return ControlUpdateResult::SensorError;
@ -123,7 +123,7 @@ ControlUpdateResult ControlManager::update()
// Pre-move stabilization
if (this->stabilized())
{
dln("[ CONTROL ] Pre-move stabilization successful");
//dln("[ CONTROL ] Pre-move stabilization successful");
// Sensor looks good, let's go!
motorStart(this->moveDirection == MoveDirection::Up ? MotorDirection::Up : MotorDirection::Down);
@ -131,7 +131,7 @@ ControlUpdateResult ControlManager::update()
}
else if (CurrentTime - this->stabilizationStart >= Config::HeightMeasurementDeltaStableMoveTimeout)
{
dln("[ CONTROL ] Timeout in pre-move stabilization!");
//dln("[ CONTROL ] Timeout in pre-move stabilization!");
// Timeout expired, abort the move
this->stabilizationStart = 0;
@ -147,7 +147,7 @@ ControlUpdateResult ControlManager::update()
void ControlManager::stabilizeStart()
{
dln("[ CONTROL ] Starting stabilization");
//dln("[ CONTROL ] Starting stabilization");
this->stabilizationStart = CurrentTime;
this->stabilizeTargetMeasurement = 0;
@ -177,7 +177,7 @@ bool ControlManager::stabilized()
if (this->stabilizeCount >= Config::HeightMeasurementDeltaStableCount)
{
dln("[ CONTROL ] Stable");
//dln("[ CONTROL ] Stable");
this->stabilizationStart = 0;
return true;
}
@ -195,16 +195,16 @@ bool ControlManager::stabilized()
void ControlManager::moveStart(uint16_t height)
{
dl("[ CONTROL ] Starting move to: "); dln(height);
//dl("[ CONTROL ] Starting move to: "); dln(height);
if (height < Settings.Height.Minimum)
{
dl("[ CONTROL ] Target is below minimum, changing to: "); dln(Settings.Height.Minimum);
//dl("[ CONTROL ] Target is below minimum, changing to: "); dln(Settings.Height.Minimum);
height = Settings.Height.Minimum;
}
else if (height > Settings.Height.Maximum)
{
dl("[ CONTROL ] Target is above maximum, changing to: "); dln(Settings.Height.Maximum);
//dl("[ CONTROL ] Target is above maximum, changing to: "); dln(Settings.Height.Maximum);
height = Settings.Height.Maximum;
}
@ -218,7 +218,7 @@ void ControlManager::moveStart(uint16_t height)
void ControlManager::moveStop()
{
dln("[ CONTROL ] Stopping move");
//dln("[ CONTROL ] Stopping move");
motorStop();
this->moveDirection = MoveDirection::None;
@ -253,7 +253,7 @@ bool ControlManager::targetReached()
if (currentHeight - this->moveTargetHeight <= Config::HeightMeasurementDeltaOnTarget)
this->currentMeasurement = this->moveTargetHeight - Settings.Height.Offset;
dln("[ CONTROL ] Target reached");
//dln("[ CONTROL ] Target reached");
return true;
}
break;
@ -265,7 +265,7 @@ bool ControlManager::targetReached()
if (this->moveTargetHeight - currentHeight <= Config::HeightMeasurementDeltaOnTarget)
this->currentMeasurement = this->moveTargetHeight - Settings.Height.Offset;
dln("[ CONTROL ] Target reached");
//dln("[ CONTROL ] Target reached");
return true;
}
break;

View File

@ -23,7 +23,7 @@ void motorInit()
void motorStart(MotorDirection direction)
{
dl("[ MOTOR ] Starting in direction: "); dln((uint8_t)direction);
//dl("[ MOTOR ] Starting in direction: "); dln((uint8_t)direction);
digitalWrite(Config::MotorPinDirection, direction == MotorDirection::Up ? HIGH : LOW);
digitalWrite(Config::MotorPinSleep, HIGH);
@ -33,7 +33,7 @@ void motorStart(MotorDirection direction)
void motorStop()
{
dln("[ MOTOR ] Stopping");
//dln("[ MOTOR ] Stopping");
digitalWrite(Config::MotorPinPWM, LOW);
digitalWrite(Config::MotorPinSleep, LOW);

View File

@ -25,7 +25,7 @@ bool ManualScreen::nextPage()
Control.moveStart(this->height);
this->screenManager->show<MoveScreen>();
return true;
return false;
}

View File

@ -207,19 +207,19 @@ void loop()
if (buttons[0].fell())
{
dln("[ MAIN ] Button pressed: Top");
//dln("[ MAIN ] Button pressed: Top");
screenManager.button(Button::Top);
}
if (buttons[1].fell())
{
dln("[ MAIN ] Button pressed: Middle");
//dln("[ MAIN ] Button pressed: Middle");
screenManager.button(Button::Middle);
}
if (buttons[2].fell())
{
dln("[ MAIN ] Button pressed: Bottom");
//dln("[ MAIN ] Button pressed: Bottom");
screenManager.button(Button::Bottom);
}