From 7c7e30f4cc8088b3c54347e656f7e433fb3b61af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Br=C3=A1zio?= Date: Thu, 7 Apr 2016 12:41:09 +0100 Subject: [PATCH] Adherence to the new OOP coding standards --- Marlin/Marlin.h | 2 +- Marlin/Marlin_main.cpp | 14 +++++++------- Marlin/stopwatch.cpp | 24 ++++++++++++------------ Marlin/stopwatch.h | 8 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 9142e2a2d..1e77b3c4e 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -360,7 +360,7 @@ extern bool axis_homed[3]; // axis[n].is_homed #endif // Print job timer -extern stopwatch print_job_timer; +extern Stopwatch print_job_timer; // Handling multiple extruders pins extern uint8_t active_extruder; diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 2f5f0ac9b..85cfd02c9 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -298,7 +298,7 @@ const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42 millis_t previous_cmd_ms = 0; static millis_t max_inactive_time = 0; static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000L; -stopwatch print_job_timer = stopwatch(); +Stopwatch print_job_timer = Stopwatch(); static uint8_t target_extruder; #if ENABLED(AUTO_BED_LEVELING_FEATURE) @@ -4119,17 +4119,17 @@ inline void gcode_M104() { #endif /** - * We use halve EXTRUDE_MINTEMP here to allow nozzles to be put into hot + * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot * stand by mode, for instance in a dual extruder setup, without affecting * the running print timer. */ - if (temp <= (EXTRUDE_MINTEMP/2)) { + if (temp <= (EXTRUDE_MINTEMP)/2) { print_job_timer.stop(); LCD_MESSAGEPGM(WELCOME_MSG); } /** * We do not check if the timer is already running because this check will - * be done for us inside the stopwatch::start() method thus a running timer + * be done for us inside the Stopwatch::start() method thus a running timer * will not restart. */ else print_job_timer.start(); @@ -4273,17 +4273,17 @@ inline void gcode_M109() { #endif /** - * We use halve EXTRUDE_MINTEMP here to allow nozzles to be put into hot + * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot * stand by mode, for instance in a dual extruder setup, without affecting * the running print timer. */ - if (temp <= (EXTRUDE_MINTEMP/2)) { + if (temp <= (EXTRUDE_MINTEMP)/2) { print_job_timer.stop(); LCD_MESSAGEPGM(WELCOME_MSG); } /** * We do not check if the timer is already running because this check will - * be done for us inside the stopwatch::start() method thus a running timer + * be done for us inside the Stopwatch::start() method thus a running timer * will not restart. */ else print_job_timer.start(); diff --git a/Marlin/stopwatch.cpp b/Marlin/stopwatch.cpp index fec11348a..5bc0a280f 100644 --- a/Marlin/stopwatch.cpp +++ b/Marlin/stopwatch.cpp @@ -23,28 +23,28 @@ #include "Marlin.h" #include "stopwatch.h" -stopwatch::stopwatch() { +Stopwatch::Stopwatch() { this->reset(); } -void stopwatch::stop() { - if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::stop()"); +void Stopwatch::stop() { + if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::stop()"); if (!this->isRunning()) return; this->status = STPWTCH_STOPPED; this->stopTimestamp = millis(); } -void stopwatch::pause() { - if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::pause()"); +void Stopwatch::pause() { + if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::pause()"); if (!this->isRunning()) return; this->status = STPWTCH_PAUSED; this->stopTimestamp = millis(); } -void stopwatch::start() { - if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::start()"); +void Stopwatch::start() { + if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::start()"); if (this->isRunning()) return; if (this->isPaused()) this->accumulator = this->duration(); @@ -54,8 +54,8 @@ void stopwatch::start() { this->startTimestamp = millis(); } -void stopwatch::reset() { - if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::reset()"); +void Stopwatch::reset() { + if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::reset()"); this->status = STPWTCH_STOPPED; this->startTimestamp = 0; @@ -63,15 +63,15 @@ void stopwatch::reset() { this->accumulator = 0; } -bool stopwatch::isRunning() { +bool Stopwatch::isRunning() { return (this->status == STPWTCH_RUNNING) ? true : false; } -bool stopwatch::isPaused() { +bool Stopwatch::isPaused() { return (this->status == STPWTCH_PAUSED) ? true : false; } -uint16_t stopwatch::duration() { +uint16_t Stopwatch::duration() { return (((this->isRunning()) ? millis() : this->stopTimestamp) - this->startTimestamp) / 1000 + this->accumulator; } diff --git a/Marlin/stopwatch.h b/Marlin/stopwatch.h index d537b4dcc..d6ef8a744 100644 --- a/Marlin/stopwatch.h +++ b/Marlin/stopwatch.h @@ -23,7 +23,7 @@ #ifndef STOPWATCH_H #define STOPWATCH_H -enum stopwatch_s { +enum StopwatchStatus { STPWTCH_STOPPED = 0x0, STPWTCH_RUNNING = 0x1, STPWTCH_PAUSED = 0x2 @@ -34,9 +34,9 @@ enum stopwatch_s { * @details This class acts as a timer proving stopwatch functionality including * the ability to pause the running time counter. */ -class stopwatch { +class Stopwatch { private: - stopwatch_s status; + StopwatchStatus status; uint16_t accumulator; uint32_t startTimestamp; uint32_t stopTimestamp; @@ -45,7 +45,7 @@ class stopwatch { /** * @brief Class constructor */ - stopwatch(); + Stopwatch(); /** * @brief Stops the stopwatch