Prusa MINI Firmware overview
SLine Struct Reference

#include <gcode_thumb_decoder.h>

Collaboration diagram for SLine:

Public Member Functions

 SLine ()
 
void AppendByte (uint8_t b)
 
void Reset ()
 
 operator const char * () const
 
bool IsBeginThumbnail () const
 
bool IsEndThumbnail () const
 

Public Attributes

uint8_t size
 
size_t expectedLineSize
 
uint8_t l [MAX+1]
 

Static Public Attributes

static const size_t MAX = 80
 

Constructor & Destructor Documentation

◆ SLine()

SLine::SLine ( )
33  {
34  Reset();
35  }
Here is the call graph for this function:

Member Function Documentation

◆ AppendByte()

void SLine::AppendByte ( uint8_t  b)
36  {
37  if (size < MAX) {
38  l[size++] = b;
39  l[size] = 0; // prepare termination
40  }
42  }
Here is the caller graph for this function:

◆ Reset()

void SLine::Reset ( )
43  {
44  size = 0;
45  expectedLineSize = 0;
46  l[0] = l[MAX] = 0;
47  }
Here is the caller graph for this function:

◆ operator const char *()

SLine::operator const char * ( ) const
48  {
49  return (const char *)(l);
50  }

◆ IsBeginThumbnail()

bool SLine::IsBeginThumbnail ( ) const
3  {
4  static const char thumbnailBegin[] = "; thumbnail begin "; // pozor na tu mezeru na konci
5  // pokud zacina radka na ; thumbnail, lze se tim zacit zabyvat
6  // nemuzu pouzivat zadne pokrocile algoritmy, musim vystacit se strcmp
7  const char *lc = (const char *)l; // jen quli debuggeru, abych do toho videl...
8  // ta -1 na size ma svuj vyznam - chci, aby strncmp NEporovnavalo ten null
9  // znak na konci, cili abych se nemusel srat s tim, ze vstupni string je
10  // delsi, cili aby to emulovalo chovani boost::starts_with()
11  if (!strncmp(lc, thumbnailBegin,
12  std::min(sizeof(l), sizeof(thumbnailBegin)) - 1)) {
13  // zacatek thumbnailu
14  unsigned int x, y;
15  unsigned long bytes;
16  lc = lc + sizeof(thumbnailBegin) - 1;
17  int ss = sscanf(lc, "%ux%u %lu", &x, &y, &bytes);
18  if (ss == 3) { // 3 uspesne prectene itemy - rozliseni
19  // je to platny zacatek thumbnailu, je to ten muj?
20  if (x == 220 && y == 124) {
21  // je to ten muj, ktery chci
22  return true;
23  }
24  }
25  }
26  return false;
27 }
Here is the caller graph for this function:

◆ IsEndThumbnail()

bool SLine::IsEndThumbnail ( ) const
29  {
30  static const char thumbnailEnd[] = "; thumbnail end";
31  // proc -1 viz. vysvetleni v LineIsBeginThumbnail
32  return !strncmp((const char *)l, thumbnailEnd,
33  std::min(sizeof(l), sizeof(thumbnailEnd)) - 1);
34 }
Here is the caller graph for this function:

Member Data Documentation

◆ MAX

const size_t SLine::MAX = 80
static

◆ size

uint8_t SLine::size

◆ expectedLineSize

size_t SLine::expectedLineSize

◆ l

uint8_t SLine::l[MAX+1]
SLine::size
uint8_t size
Definition: gcode_thumb_decoder.h:28
SLine::l
uint8_t l[MAX+1]
Definition: gcode_thumb_decoder.h:32
SLine::expectedLineSize
size_t expectedLineSize
Definition: gcode_thumb_decoder.h:30
min
#define min(a, b)
Definition: wiring_constants.h:36
SLine::Reset
void Reset()
Definition: gcode_thumb_decoder.h:43
SLine::MAX
static const size_t MAX
Definition: gcode_thumb_decoder.h:27
createSpeedLookupTable.b
list b
Definition: createSpeedLookupTable.py:30