Prusa MINI Firmware overview
Bresenham< T, Cfg > Class Template Reference

#include <bresenham.h>

Collaboration diagram for Bresenham< T, Cfg >:

Public Member Functions

 Bresenham (const T &inDivisor=1, const int8_t &inDir=1, const T &inDividend=1, const T &inValue=0)
 
 Bresenham (const T &inDivisor, const int8_t(&inDir)[Cfg::SIZE], const T(&inDividend)[Cfg::SIZE], const T(&inValue)[Cfg::SIZE]={0})
 
 Bresenham (const T &inDivisor, const int8_t &inDir, const T(&inDividend)[Cfg::SIZE], const T(&inValue)[Cfg::SIZE]={0})
 

Static Public Member Functions

static FORCE_INLINE void init (const uint8_t index, const T &inDivisor=1, const int8_t &inDir=1, const T &inDividend=1, const T &inValue=0)
 
static FORCE_INLINE void init (const T &inDivisor, const int8_t(&inDir)[Cfg::SIZE], const T(&inDividend)[Cfg::SIZE], const T(&inValue)[Cfg::SIZE]={0})
 
static FORCE_INLINE void init (const T &inDivisor, const int8_t &inDir, const T(&inDividend)[Cfg::SIZE], const T(&inValue)[Cfg::SIZE]={0})
 
static FORCE_INLINE void reinit (const uint8_t index, const int8_t &inDir=1, const T &inDividend=1, const T &inValue=0)
 
static FORCE_INLINE void prime (const uint8_t index)
 
static FORCE_INLINE void prime ()
 
static FORCE_INLINE void back (const uint8_t index)
 
static FORCE_INLINE bool tick1 (const uint8_t index)
 
static FORCE_INLINE void tick (const uint8_t index)
 
static FORCE_INLINE void tick1 () _O3
 
static FORCE_INLINE void tick () _O3
 
static void report (const uint8_t index)
 
static void report ()
 

Static Public Attributes

static T divisor
 
static T value [Cfg::SIZE]
 
static T dir [Cfg::SIZE]
 
static T dividend [Cfg::SIZE]
 
static T counter [Cfg::SIZE]
 

Constructor & Destructor Documentation

◆ Bresenham() [1/3]

template<typename T , typename Cfg >
Bresenham< T, Cfg >::Bresenham ( const T &  inDivisor = 1,
const int8_t &  inDir = 1,
const T &  inDividend = 1,
const T &  inValue = 0 
)
50  {
51  for (uint8_t i = 0; i < Cfg::SIZE; i++) init(i, inDivisor, inDir, inDividend, inValue);
52  }
Here is the call graph for this function:

◆ Bresenham() [2/3]

template<typename T , typename Cfg >
Bresenham< T, Cfg >::Bresenham ( const T &  inDivisor,
const int8_t(&)  inDir[Cfg::SIZE],
const T(&)  inDividend[Cfg::SIZE],
const T(&)  inValue[Cfg::SIZE] = {0} 
)
55  {0}) {
56  init(inDivisor, inDir, inDividend, inValue);
57  }

◆ Bresenham() [3/3]

template<typename T , typename Cfg >
Bresenham< T, Cfg >::Bresenham ( const T &  inDivisor,
const int8_t &  inDir,
const T(&)  inDividend[Cfg::SIZE],
const T(&)  inValue[Cfg::SIZE] = {0} 
)
60  {0}) {
61  init(inDivisor, inDir, inDividend, inValue);
62  }

Member Function Documentation

◆ init() [1/3]

template<typename T , typename Cfg >
static FORCE_INLINE void Bresenham< T, Cfg >::init ( const uint8_t  index,
const T &  inDivisor = 1,
const int8_t &  inDir = 1,
const T &  inDividend = 1,
const T &  inValue = 0 
)
static
65  {
66  divisor = inDivisor;
67  dir[index] = inDir;
68  dividend[index] = inDividend;
69  value[index] = inValue;
70  prime(index);
71  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init() [2/3]

template<typename T , typename Cfg >
static FORCE_INLINE void Bresenham< T, Cfg >::init ( const T &  inDivisor,
const int8_t(&)  inDir[Cfg::SIZE],
const T(&)  inDividend[Cfg::SIZE],
const T(&)  inValue[Cfg::SIZE] = {0} 
)
static
74  {0}) {
75  divisor = inDivisor;
76  for (uint8_t i = 0; i < Cfg::SIZE; i++) {
77  dir[i] = inDir[i];
78  dividend[i] = inDividend[i];
79  value[i] = inValue[i];
80  }
81  prime();
82  }

◆ init() [3/3]

template<typename T , typename Cfg >
static FORCE_INLINE void Bresenham< T, Cfg >::init ( const T &  inDivisor,
const int8_t &  inDir,
const T(&)  inDividend[Cfg::SIZE],
const T(&)  inValue[Cfg::SIZE] = {0} 
)
static
85  {0}) {
86  divisor = inDivisor;
87  for (uint8_t i = 0; i < Cfg::SIZE; i++) {
88  dir[i] = inDir;
89  dividend[i] = inDividend[i];
90  value[i] = inValue[i];
91  }
92  prime();
93  }

◆ reinit()

template<typename T , typename Cfg >
static FORCE_INLINE void Bresenham< T, Cfg >::reinit ( const uint8_t  index,
const int8_t &  inDir = 1,
const T &  inDividend = 1,
const T &  inValue = 0 
)
static
96  {
97  dir[index] = inDir;
98  dividend[index] = inDividend;
99  value[index] = inValue;
100  prime();
101  }
Here is the call graph for this function:

◆ prime() [1/2]

template<typename T , typename Cfg >
static FORCE_INLINE void Bresenham< T, Cfg >::prime ( const uint8_t  index)
static
103 { counter[index] = -(divisor / 2); }

◆ prime() [2/2]

template<typename T , typename Cfg >
static FORCE_INLINE void Bresenham< T, Cfg >::prime ( )
static
104 { for (uint8_t i = 0; i < Cfg::SIZE; i++) prime(i); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ back()

template<typename T , typename Cfg >
static FORCE_INLINE void Bresenham< T, Cfg >::back ( const uint8_t  index)
static
106 { counter[index] -= divisor; }
Here is the caller graph for this function:

◆ tick1() [1/2]

template<typename T , typename Cfg >
static FORCE_INLINE bool Bresenham< T, Cfg >::tick1 ( const uint8_t  index)
static
108  {
109  counter[index] += dividend[index];
110  return counter[index] > 0;
111  }

◆ tick() [1/2]

template<typename T , typename Cfg >
static FORCE_INLINE void Bresenham< T, Cfg >::tick ( const uint8_t  index)
static
113  {
114  if (tick1(index)) { value[index] += dir[index]; back(index); }
115  }
Here is the call graph for this function:

◆ tick1() [2/2]

template<typename T , typename Cfg >
static FORCE_INLINE void Bresenham< T, Cfg >::tick1 ( )
static
117 { for (uint8_t i = 0; i < Cfg::SIZE; i++) (void)tick1(i); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tick() [2/2]

template<typename T , typename Cfg >
static FORCE_INLINE void Bresenham< T, Cfg >::tick ( )
static
119 { for (uint8_t i = 0; i < Cfg::SIZE; i++) (void)tick(i); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ report() [1/2]

template<typename T , typename Cfg >
static void Bresenham< T, Cfg >::report ( const uint8_t  index)
static
121  {
122  if (index < Cfg::SIZE) {
123  SERIAL_ECHOPAIR("bresenham ", int(index), " : (", dividend[index], "/", divisor, ") ");
124  if (counter[index] >= 0) SERIAL_CHAR(' ');
125  if (labs(counter[index]) < 100) { SERIAL_CHAR(' '); if (labs(counter[index]) < 10) SERIAL_CHAR(' '); }
126  SERIAL_ECHO(counter[index]);
127  SERIAL_ECHOLNPAIR(" ... ", value[index]);
128  }
129  }

◆ report() [2/2]

template<typename T , typename Cfg >
static void Bresenham< T, Cfg >::report ( )
static
131 { for (uint8_t i = 0; i < Cfg::SIZE; i++) report(i); }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ divisor

template<typename T , typename Cfg >
T Bresenham< T, Cfg >::divisor
static

◆ value

template<typename T , typename Cfg >
T Bresenham< T, Cfg >::value[Cfg::SIZE]
static

◆ dir

template<typename T , typename Cfg >
T Bresenham< T, Cfg >::dir[Cfg::SIZE]
static

◆ dividend

template<typename T , typename Cfg >
T Bresenham< T, Cfg >::dividend[Cfg::SIZE]
static

◆ counter

template<typename T , typename Cfg >
T Bresenham< T, Cfg >::counter[Cfg::SIZE]
static
SERIAL_CHAR
#define SERIAL_CHAR(x)
Definition: serial.h:69
SERIAL_ECHO
#define SERIAL_ECHO(x)
Definition: serial.h:70
SERIAL_ECHOPAIR
#define SERIAL_ECHOPAIR(V...)
Definition: serial.h:114
Bresenham::dividend
static T dividend[Cfg::SIZE]
Definition: bresenham.h:43
i
uint8_t i
Definition: screen_test_graph.c:72
Bresenham::value
static T value[Cfg::SIZE]
Definition: bresenham.h:43
Bresenham::counter
static T counter[Cfg::SIZE]
Definition: bresenham.h:43
Bresenham::tick
static FORCE_INLINE void tick() _O3
Definition: bresenham.h:119
Bresenham::tick1
static FORCE_INLINE void tick1() _O3
Definition: bresenham.h:117
Bresenham::divisor
static T divisor
Definition: bresenham.h:43
Bresenham::dir
static T dir[Cfg::SIZE]
Definition: bresenham.h:43
SERIAL_ECHOLNPAIR
#define SERIAL_ECHOLNPAIR(V...)
Definition: serial.h:144
uint8_t
const uint8_t[]
Definition: 404_html.c:3
Bresenham::report
static void report()
Definition: bresenham.h:131
Bresenham::back
static FORCE_INLINE void back(const uint8_t index)
Definition: bresenham.h:106
Bresenham::prime
static FORCE_INLINE void prime()
Definition: bresenham.h:104
Bresenham::init
static FORCE_INLINE void init(const uint8_t index, const T &inDivisor=1, const int8_t &inDir=1, const T &inDividend=1, const T &inValue=0)
Definition: bresenham.h:65