Browse Source

Adherence to the new OOP coding standards

João Brázio 8 years ago
parent
commit
7c7e30f4cc
No account linked to committer's email address
4 changed files with 24 additions and 24 deletions
  1. 1
    1
      Marlin/Marlin.h
  2. 7
    7
      Marlin/Marlin_main.cpp
  3. 12
    12
      Marlin/stopwatch.cpp
  4. 4
    4
      Marlin/stopwatch.h

+ 1
- 1
Marlin/Marlin.h View File

360
 #endif
360
 #endif
361
 
361
 
362
 // Print job timer
362
 // Print job timer
363
-extern stopwatch print_job_timer;
363
+extern Stopwatch print_job_timer;
364
 
364
 
365
 // Handling multiple extruders pins
365
 // Handling multiple extruders pins
366
 extern uint8_t active_extruder;
366
 extern uint8_t active_extruder;

+ 7
- 7
Marlin/Marlin_main.cpp View File

298
 millis_t previous_cmd_ms = 0;
298
 millis_t previous_cmd_ms = 0;
299
 static millis_t max_inactive_time = 0;
299
 static millis_t max_inactive_time = 0;
300
 static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000L;
300
 static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000L;
301
-stopwatch print_job_timer = stopwatch();
301
+Stopwatch print_job_timer = Stopwatch();
302
 static uint8_t target_extruder;
302
 static uint8_t target_extruder;
303
 
303
 
304
 #if ENABLED(AUTO_BED_LEVELING_FEATURE)
304
 #if ENABLED(AUTO_BED_LEVELING_FEATURE)
4119
     #endif
4119
     #endif
4120
 
4120
 
4121
     /**
4121
     /**
4122
-     * We use halve EXTRUDE_MINTEMP here to allow nozzles to be put into hot
4122
+     * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot
4123
      * stand by mode, for instance in a dual extruder setup, without affecting
4123
      * stand by mode, for instance in a dual extruder setup, without affecting
4124
      * the running print timer.
4124
      * the running print timer.
4125
      */
4125
      */
4126
-    if (temp <= (EXTRUDE_MINTEMP/2)) {
4126
+    if (temp <= (EXTRUDE_MINTEMP)/2) {
4127
       print_job_timer.stop();
4127
       print_job_timer.stop();
4128
       LCD_MESSAGEPGM(WELCOME_MSG);
4128
       LCD_MESSAGEPGM(WELCOME_MSG);
4129
     }
4129
     }
4130
     /**
4130
     /**
4131
      * We do not check if the timer is already running because this check will
4131
      * We do not check if the timer is already running because this check will
4132
-     * be done for us inside the stopwatch::start() method thus a running timer
4132
+     * be done for us inside the Stopwatch::start() method thus a running timer
4133
      * will not restart.
4133
      * will not restart.
4134
      */
4134
      */
4135
     else print_job_timer.start();
4135
     else print_job_timer.start();
4273
     #endif
4273
     #endif
4274
 
4274
 
4275
     /**
4275
     /**
4276
-     * We use halve EXTRUDE_MINTEMP here to allow nozzles to be put into hot
4276
+     * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot
4277
      * stand by mode, for instance in a dual extruder setup, without affecting
4277
      * stand by mode, for instance in a dual extruder setup, without affecting
4278
      * the running print timer.
4278
      * the running print timer.
4279
      */
4279
      */
4280
-    if (temp <= (EXTRUDE_MINTEMP/2)) {
4280
+    if (temp <= (EXTRUDE_MINTEMP)/2) {
4281
       print_job_timer.stop();
4281
       print_job_timer.stop();
4282
       LCD_MESSAGEPGM(WELCOME_MSG);
4282
       LCD_MESSAGEPGM(WELCOME_MSG);
4283
     }
4283
     }
4284
     /**
4284
     /**
4285
      * We do not check if the timer is already running because this check will
4285
      * We do not check if the timer is already running because this check will
4286
-     * be done for us inside the stopwatch::start() method thus a running timer
4286
+     * be done for us inside the Stopwatch::start() method thus a running timer
4287
      * will not restart.
4287
      * will not restart.
4288
      */
4288
      */
4289
     else print_job_timer.start();
4289
     else print_job_timer.start();

+ 12
- 12
Marlin/stopwatch.cpp View File

23
 #include "Marlin.h"
23
 #include "Marlin.h"
24
 #include "stopwatch.h"
24
 #include "stopwatch.h"
25
 
25
 
26
-stopwatch::stopwatch() {
26
+Stopwatch::Stopwatch() {
27
    this->reset();
27
    this->reset();
28
  }
28
  }
29
 
29
 
30
-void stopwatch::stop() {
31
-  if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::stop()");
30
+void Stopwatch::stop() {
31
+  if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::stop()");
32
   if (!this->isRunning()) return;
32
   if (!this->isRunning()) return;
33
 
33
 
34
   this->status = STPWTCH_STOPPED;
34
   this->status = STPWTCH_STOPPED;
35
   this->stopTimestamp = millis();
35
   this->stopTimestamp = millis();
36
 }
36
 }
37
 
37
 
38
-void stopwatch::pause() {
39
-  if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::pause()");
38
+void Stopwatch::pause() {
39
+  if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::pause()");
40
   if (!this->isRunning()) return;
40
   if (!this->isRunning()) return;
41
 
41
 
42
   this->status = STPWTCH_PAUSED;
42
   this->status = STPWTCH_PAUSED;
43
   this->stopTimestamp = millis();
43
   this->stopTimestamp = millis();
44
 }
44
 }
45
 
45
 
46
-void stopwatch::start() {
47
-  if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::start()");
46
+void Stopwatch::start() {
47
+  if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::start()");
48
   if (this->isRunning()) return;
48
   if (this->isRunning()) return;
49
 
49
 
50
   if (this->isPaused()) this->accumulator = this->duration();
50
   if (this->isPaused()) this->accumulator = this->duration();
54
   this->startTimestamp = millis();
54
   this->startTimestamp = millis();
55
 }
55
 }
56
 
56
 
57
-void stopwatch::reset() {
58
-  if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("stopwatch::reset()");
57
+void Stopwatch::reset() {
58
+  if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::reset()");
59
 
59
 
60
   this->status = STPWTCH_STOPPED;
60
   this->status = STPWTCH_STOPPED;
61
   this->startTimestamp = 0;
61
   this->startTimestamp = 0;
63
   this->accumulator = 0;
63
   this->accumulator = 0;
64
 }
64
 }
65
 
65
 
66
-bool stopwatch::isRunning() {
66
+bool Stopwatch::isRunning() {
67
   return (this->status == STPWTCH_RUNNING) ? true : false;
67
   return (this->status == STPWTCH_RUNNING) ? true : false;
68
 }
68
 }
69
 
69
 
70
-bool stopwatch::isPaused() {
70
+bool Stopwatch::isPaused() {
71
   return (this->status == STPWTCH_PAUSED) ? true : false;
71
   return (this->status == STPWTCH_PAUSED) ? true : false;
72
 }
72
 }
73
 
73
 
74
-uint16_t stopwatch::duration() {
74
+uint16_t Stopwatch::duration() {
75
   return (((this->isRunning()) ? millis() : this->stopTimestamp)
75
   return (((this->isRunning()) ? millis() : this->stopTimestamp)
76
           - this->startTimestamp) / 1000 + this->accumulator;
76
           - this->startTimestamp) / 1000 + this->accumulator;
77
 }
77
 }

+ 4
- 4
Marlin/stopwatch.h View File

23
 #ifndef STOPWATCH_H
23
 #ifndef STOPWATCH_H
24
 #define STOPWATCH_H
24
 #define STOPWATCH_H
25
 
25
 
26
-enum stopwatch_s {
26
+enum StopwatchStatus {
27
   STPWTCH_STOPPED = 0x0,
27
   STPWTCH_STOPPED = 0x0,
28
   STPWTCH_RUNNING = 0x1,
28
   STPWTCH_RUNNING = 0x1,
29
   STPWTCH_PAUSED  = 0x2
29
   STPWTCH_PAUSED  = 0x2
34
  * @details This class acts as a timer proving stopwatch functionality including
34
  * @details This class acts as a timer proving stopwatch functionality including
35
  * the ability to pause the running time counter.
35
  * the ability to pause the running time counter.
36
  */
36
  */
37
-class stopwatch {
37
+class Stopwatch {
38
   private:
38
   private:
39
-    stopwatch_s status;
39
+    StopwatchStatus status;
40
     uint16_t accumulator;
40
     uint16_t accumulator;
41
     uint32_t startTimestamp;
41
     uint32_t startTimestamp;
42
     uint32_t stopTimestamp;
42
     uint32_t stopTimestamp;
45
     /**
45
     /**
46
      * @brief Class constructor
46
      * @brief Class constructor
47
      */
47
      */
48
-    stopwatch();
48
+    Stopwatch();
49
 
49
 
50
     /**
50
     /**
51
      * @brief Stops the stopwatch
51
      * @brief Stops the stopwatch

Loading…
Cancel
Save