Logic Analyzer RPi
Logic Analyzer for the Raspberry Pi
 All Classes Files Functions Variables Pages
binary.h
1 //#include <stdio.h>
2 //#include <string.h>
3 //#include <stdlib.h>
4 //#include <mgl/mgl_fltk.h>
5 #include <mgl/mgl_zb.h>
6 //#include <unistd.h>
7 
8 #ifndef DEBUG_H
9 #define DEBUG_H
10 #include "debug.h"
11 #endif
12 
13 #ifndef LOGIC_INPUT
14 #define LOGIC_INPUT
15 #include "logic_input.h"
16 #endif
17 
18 #ifndef TRANSITION
19 #define TRANSITION
20 #include "transition.h"
21 #endif
22 
24 
25 class binary : public mglDraw
26 {
27 public:
29  binary(uint32_t nbit=0);
31 
35  binary(const binary &source, uint32_t index_start=0, uint32_t index_end=0);
37 
41  binary(const binary &source, float t_start, float t_end=0);
43  ~binary();
45 
50  void init(logic_input *data, transition *clk, uint8_t pin, char transition_direction='u');
52 
55  uint32_t Get_nbad(uint32_t index_start, uint32_t index_end=0);
57 
61  uint32_t Get(uint32_t index_start, uint32_t index_end=0);
63 
70  void sprint(char value[2], uint32_t bit);
72 
74  int Draw(mglGraph *gr);
76  /*Checks for self assignment*/
77  binary& operator = (const binary source)
78  {
79  if(this!=&source)
80  {
81  this->nbit=source.nbit;
82  this->npin=source.npin;
83  this->t=source.t;
84  if(source.nbit>0)
85  {
86  this->bits=new uint8_t[this->nbit];
87  for (uint32_t bit=0;bit<this->nbit;bit++)
88  {
89  this->bits[bit]=source.bits[bit];
90  }
91  }
92  }
93  return *this;
94  }
95 //private:
97  uint8_t *bits;
99  mglData t;
101  uint32_t nbit;
103 
104  uint8_t npin;
106 
107  uint8_t pin;
108 };