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
// Print job timer
extern stopwatch print_job_timer;
extern Stopwatch print_job_timer;
// Handling multiple extruders pins
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;
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();

View file

@ -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;
}

View file

@ -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