diff --git a/Makefile b/Makefile index d0bc5e0..bf36ff9 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ COMPILER_PATH = g++ OUTPUT = main CFLAGS = -std=c++14 -O3 LDFLAGS = -OBJECTS = main.o drv/b15f.o drv/plottyfile.o +OBJECTS = main.o drv/b15f.o drv/plottyfile.o drv/dot.o COMPILE = $(COMPILER_PATH) $(CFLAGS) diff --git a/drv/dot.cpp b/drv/dot.cpp new file mode 100644 index 0000000..cdd3eda --- /dev/null +++ b/drv/dot.cpp @@ -0,0 +1,20 @@ +#include "dot.h" + +Dot::Dot(uint16_t x, uint16_t y, DotColor color) : x(x), y(y), color(color) +{ +} + +uint16_t Dot::getX() const +{ + return x; +} + +uint16_t Dot::getY() const +{ + return y; +} + +DotColor Dot::getColor(void) const +{ + return color; +} diff --git a/drv/dot.h b/drv/dot.h new file mode 100644 index 0000000..17f782c --- /dev/null +++ b/drv/dot.h @@ -0,0 +1,26 @@ +#ifndef DOT_H +#define DOT_H + +#include + +enum DotColor +{ + PURPLE = 0, + GREEN = 32, +}; + +class Dot +{ +public: + Dot(uint16_t x, uint16_t y, DotColor color); + uint16_t getX(void) const; + uint16_t getY(void) const; + DotColor getColor(void) const; + +private: + uint16_t x, y; + DotColor color; +}; + + +#endif // DOT_H diff --git a/drv/dot.h.gch b/drv/dot.h.gch new file mode 100644 index 0000000..2f362f8 Binary files /dev/null and b/drv/dot.h.gch differ diff --git a/drv/dot.o b/drv/dot.o new file mode 100644 index 0000000..f814b54 Binary files /dev/null and b/drv/dot.o differ diff --git a/drv/plottyfile.cpp b/drv/plottyfile.cpp index 380e8cc..6137e7b 100644 --- a/drv/plottyfile.cpp +++ b/drv/plottyfile.cpp @@ -1,5 +1,10 @@ #include "plottyfile.h" +void PlottyFile::addDot(Dot& dot) +{ + dots.push_back(dot); +} + void PlottyFile::prepStr(std::string& str, uint8_t len) { if(str.length() > len) @@ -64,20 +69,12 @@ void PlottyFile::writeToFile(std::string filename) while(file.tellp() < 256) file.put(0); - for(uint16_t i = 0; i < 1023; i++) + for(Dot& dot : dots) { - file.put(i >> 8); - file.put(i & 0xFF); - file.put(1); - file.put(0); - } - - for(uint16_t i = 0; i < 1023; i++) - { - file.put((i >> 8) | 128); - file.put(i & 0xFF); - file.put(2); - file.put(0); + file.put((dot.getX() >> 8) | (static_cast(dot.getColor()) << 2)); + file.put(dot.getX() & 0xFF); + file.put(dot.getY() >> 8); + file.put(dot.getY() & 0xFF); } file.close(); diff --git a/drv/plottyfile.h b/drv/plottyfile.h index bae5ed6..a4fc9e9 100644 --- a/drv/plottyfile.h +++ b/drv/plottyfile.h @@ -4,14 +4,19 @@ #include #include #include +#include +#include "dot.h" class PlottyFile { public: + void addDot(Dot& dot); void writeToFile(std::string filename); private: void prepStr(std::string& str, uint8_t len); + std::vector dots; + int8_t command; std::string title; std::string filetype; diff --git a/drv/plottyfile.o b/drv/plottyfile.o index caa1ba7..2ba7902 100644 Binary files a/drv/plottyfile.o and b/drv/plottyfile.o differ diff --git a/gnuplotscript.gp b/gnuplotscript.gp index 5fccc88..78ca98e 100644 --- a/gnuplotscript.gp +++ b/gnuplotscript.gp @@ -6,9 +6,8 @@ set xlabel 'Desc X [Unit X]' set ylabel 'Desc Y [Unit Y]' set xrange [0:5000] set yrange [0:50] -set label at 4995,12 'Desc P [Unit P] = 1' left -set label at 4995,25 'Desc P [Unit P] = 2' left +set label at 4995,49 'Desc P [Unit P] = 1' left unset output set terminal qt unset output -plot "/tmp/tempfile0" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'Desc P [Unit P] = 1' w l,"/tmp/tempfile32" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'Desc P [Unit P] = 2' w l +plot "/tmp/tempfile32" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'Desc P [Unit P] = 1' w l diff --git a/main b/main index 38a175e..e2befaa 100755 Binary files a/main and b/main differ diff --git a/main.cpp b/main.cpp index b1a36b2..904cb3b 100644 --- a/main.cpp +++ b/main.cpp @@ -23,6 +23,13 @@ int main() drv.analogEingabeSequenz(1, &ba[0], 0, 0, &bb[0], 0, 1023, -1, 1023); PlottyFile pf; + + + for(uint16_t i = 0; i < 1023; i++) + { + Dot d(i,i, DotColor::PURPLE); + pf.addDot(d); + } pf.writeToFile("test_plot"); system("./plotty --in test_plot"); diff --git a/main.o b/main.o index c773a0e..f84a9e1 100644 Binary files a/main.o and b/main.o differ diff --git a/test_plot b/test_plot index 4190e63..98f8cce 100644 Binary files a/test_plot and b/test_plot differ