Prusa MINI Firmware overview
Clock Class Reference

#include <Clock.h>

Static Public Member Functions

static uint64_t ticks (uint32_t frequency=Clock::frequency)
 
static uint64_t nanosToTicks (uint64_t ns, uint32_t frequency=Clock::frequency)
 
static uint64_t ticksToNanos (uint64_t tick, uint32_t frequency=Clock::frequency)
 
static void setFrequency (uint32_t freq)
 
static uint64_t nanos ()
 
static uint64_t micros ()
 
static uint64_t millis ()
 
static double seconds ()
 
static void delayCycles (uint64_t cycles)
 
static void delayMicros (uint64_t micros)
 
static void delayMillis (uint64_t millis)
 
static void delaySeconds (double secs)
 
static void setTimeMultiplier (double tm)
 

Detailed Description

Marlin 3D Printer Firmware Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]

Based on Sprinter and grbl. Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Member Function Documentation

◆ ticks()

static uint64_t Clock::ticks ( uint32_t  frequency = Clock::frequency)
static
29  {
30  return (Clock::nanos() - Clock::startup.count()) / (1000000000ULL / frequency);
31  }
Here is the call graph for this function:

◆ nanosToTicks()

static uint64_t Clock::nanosToTicks ( uint64_t  ns,
uint32_t  frequency = Clock::frequency 
)
static
33  {
34  return ns / (1000000000ULL / frequency);
35  }

◆ ticksToNanos()

static uint64_t Clock::ticksToNanos ( uint64_t  tick,
uint32_t  frequency = Clock::frequency 
)
static
38  {
39  return (tick * (1000000000ULL / frequency)) / Clock::time_multiplier;
40  }

◆ setFrequency()

static void Clock::setFrequency ( uint32_t  freq)
static
42  {
43  Clock::frequency = freq;
44  }

◆ nanos()

static uint64_t Clock::nanos ( )
static
47  {
48  auto now = std::chrono::high_resolution_clock::now().time_since_epoch();
49  return (now.count() - Clock::startup.count()) * Clock::time_multiplier;
50  }
Here is the caller graph for this function:

◆ micros()

static uint64_t Clock::micros ( )
static
52  {
53  return Clock::nanos() / 1000;
54  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ millis()

static uint64_t Clock::millis ( )
static
56  {
57  return Clock::micros() / 1000;
58  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ seconds()

static double Clock::seconds ( )
static
60  {
61  return Clock::nanos() / 1000000000.0;
62  }
Here is the call graph for this function:

◆ delayCycles()

static void Clock::delayCycles ( uint64_t  cycles)
static
64  {
65  std::this_thread::sleep_for(std::chrono::nanoseconds( (1000000000L / frequency) * cycles) / Clock::time_multiplier );
66  }
Here is the caller graph for this function:

◆ delayMicros()

static void Clock::delayMicros ( uint64_t  micros)
static
68  {
69  std::this_thread::sleep_for(std::chrono::microseconds( micros ) / Clock::time_multiplier);
70  }
Here is the call graph for this function:

◆ delayMillis()

static void Clock::delayMillis ( uint64_t  millis)
static
72  {
73  std::this_thread::sleep_for(std::chrono::milliseconds( millis ) / Clock::time_multiplier);
74  }
Here is the call graph for this function:

◆ delaySeconds()

static void Clock::delaySeconds ( double  secs)
static
76  {
77  std::this_thread::sleep_for(std::chrono::duration<double, std::milli>(secs * 1000) / Clock::time_multiplier);
78  }

◆ setTimeMultiplier()

static void Clock::setTimeMultiplier ( double  tm)
static
81  {
82  Clock::time_multiplier = tm;
83  }
Clock::millis
static uint64_t millis()
Definition: Clock.h:56
Clock::micros
static uint64_t micros()
Definition: Clock.h:52
L
#define L(CODE)
Definition: macros.h:76
Clock::nanos
static uint64_t nanos()
Definition: Clock.h:47