1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 13:56:24 +00:00

Adherence to the new OOP coding standards

This commit is contained in:
João Brázio 2016-04-07 12:41:09 +01:00
parent e48d0263bf
commit 7c7e30f4cc
No known key found for this signature in database
GPG Key ID: F62CFD37DFFDB540
4 changed files with 24 additions and 24 deletions

View File

@ -360,7 +360,7 @@ extern bool axis_homed[3]; // axis[n].is_homed
#endif #endif
// Print job timer // Print job timer
extern stopwatch print_job_timer; extern Stopwatch print_job_timer;
// Handling multiple extruders pins // Handling multiple extruders pins
extern uint8_t active_extruder; extern uint8_t active_extruder;

View File

@ -298,7 +298,7 @@ const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
millis_t previous_cmd_ms = 0; millis_t previous_cmd_ms = 0;
static millis_t max_inactive_time = 0; static millis_t max_inactive_time = 0;
static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000L; 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; static uint8_t target_extruder;
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if ENABLED(AUTO_BED_LEVELING_FEATURE)
@ -4119,17 +4119,17 @@ inline void gcode_M104() {
#endif #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 * stand by mode, for instance in a dual extruder setup, without affecting
* the running print timer. * the running print timer.
*/ */
if (temp <= (EXTRUDE_MINTEMP/2)) { if (temp <= (EXTRUDE_MINTEMP)/2) {
print_job_timer.stop(); print_job_timer.stop();
LCD_MESSAGEPGM(WELCOME_MSG); LCD_MESSAGEPGM(WELCOME_MSG);
} }
/** /**
* We do not check if the timer is already running because this check will * 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. * will not restart.
*/ */
else print_job_timer.start(); else print_job_timer.start();
@ -4273,17 +4273,17 @@ inline void gcode_M109() {
#endif #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 * stand by mode, for instance in a dual extruder setup, without affecting
* the running print timer. * the running print timer.
*/ */
if (temp <= (EXTRUDE_MINTEMP/2)) { if (temp <= (EXTRUDE_MINTEMP)/2) {
print_job_timer.stop(); print_job_timer.stop();
LCD_MESSAGEPGM(WELCOME_MSG); LCD_MESSAGEPGM(WELCOME_MSG);
} }
/** /**
* We do not check if the timer is already running because this check will * 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. * will not restart.
*/ */
else print_job_timer.start(); else print_job_timer.start();

View File

@ -23,28 +23,28 @@
#include "Marlin.h" #include "Marlin.h"
#include "stopwatch.h" #include "stopwatch.h"
stopwatch::stopwatch() { Stopwatch::Stopwatch() {
this->reset(); this->reset();
} }
void stopwatch::stop() { void Stopwatch::stop() {
if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::stop()"); if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::stop()");
if (!this->isRunning()) return; if (!this->isRunning()) return;
this->status = STPWTCH_STOPPED; this->status = STPWTCH_STOPPED;
this->stopTimestamp = millis(); this->stopTimestamp = millis();
} }
void stopwatch::pause() { void Stopwatch::pause() {
if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::pause()"); if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::pause()");
if (!this->isRunning()) return; if (!this->isRunning()) return;
this->status = STPWTCH_PAUSED; this->status = STPWTCH_PAUSED;
this->stopTimestamp = millis(); this->stopTimestamp = millis();
} }
void stopwatch::start() { void Stopwatch::start() {
if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::start()"); if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::start()");
if (this->isRunning()) return; if (this->isRunning()) return;
if (this->isPaused()) this->accumulator = this->duration(); if (this->isPaused()) this->accumulator = this->duration();
@ -54,8 +54,8 @@ void stopwatch::start() {
this->startTimestamp = millis(); this->startTimestamp = millis();
} }
void stopwatch::reset() { void Stopwatch::reset() {
if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::reset()"); if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::reset()");
this->status = STPWTCH_STOPPED; this->status = STPWTCH_STOPPED;
this->startTimestamp = 0; this->startTimestamp = 0;
@ -63,15 +63,15 @@ void stopwatch::reset() {
this->accumulator = 0; this->accumulator = 0;
} }
bool stopwatch::isRunning() { bool Stopwatch::isRunning() {
return (this->status == STPWTCH_RUNNING) ? true : false; return (this->status == STPWTCH_RUNNING) ? true : false;
} }
bool stopwatch::isPaused() { bool Stopwatch::isPaused() {
return (this->status == STPWTCH_PAUSED) ? true : false; return (this->status == STPWTCH_PAUSED) ? true : false;
} }
uint16_t stopwatch::duration() { uint16_t Stopwatch::duration() {
return (((this->isRunning()) ? millis() : this->stopTimestamp) return (((this->isRunning()) ? millis() : this->stopTimestamp)
- this->startTimestamp) / 1000 + this->accumulator; - this->startTimestamp) / 1000 + this->accumulator;
} }

View File

@ -23,7 +23,7 @@
#ifndef STOPWATCH_H #ifndef STOPWATCH_H
#define STOPWATCH_H #define STOPWATCH_H
enum stopwatch_s { enum StopwatchStatus {
STPWTCH_STOPPED = 0x0, STPWTCH_STOPPED = 0x0,
STPWTCH_RUNNING = 0x1, STPWTCH_RUNNING = 0x1,
STPWTCH_PAUSED = 0x2 STPWTCH_PAUSED = 0x2
@ -34,9 +34,9 @@ enum stopwatch_s {
* @details This class acts as a timer proving stopwatch functionality including * @details This class acts as a timer proving stopwatch functionality including
* the ability to pause the running time counter. * the ability to pause the running time counter.
*/ */
class stopwatch { class Stopwatch {
private: private:
stopwatch_s status; StopwatchStatus status;
uint16_t accumulator; uint16_t accumulator;
uint32_t startTimestamp; uint32_t startTimestamp;
uint32_t stopTimestamp; uint32_t stopTimestamp;
@ -45,7 +45,7 @@ class stopwatch {
/** /**
* @brief Class constructor * @brief Class constructor
*/ */
stopwatch(); Stopwatch();
/** /**
* @brief Stops the stopwatch * @brief Stops the stopwatch