fortschritt plottyfile
This commit is contained in:
parent
0f71e121fa
commit
71b156aa6f
2
Makefile
2
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)
|
||||
|
||||
|
|
20
drv/dot.cpp
Normal file
20
drv/dot.cpp
Normal file
|
@ -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;
|
||||
}
|
26
drv/dot.h
Normal file
26
drv/dot.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef DOT_H
|
||||
#define DOT_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
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
|
BIN
drv/dot.h.gch
Normal file
BIN
drv/dot.h.gch
Normal file
Binary file not shown.
|
@ -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<uint8_t>(dot.getColor()) << 2));
|
||||
file.put(dot.getX() & 0xFF);
|
||||
file.put(dot.getY() >> 8);
|
||||
file.put(dot.getY() & 0xFF);
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
|
|
@ -4,14 +4,19 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <exception>
|
||||
#include <vector>
|
||||
#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<Dot> dots;
|
||||
|
||||
int8_t command;
|
||||
std::string title;
|
||||
std::string filetype;
|
||||
|
|
BIN
drv/plottyfile.o
BIN
drv/plottyfile.o
Binary file not shown.
|
@ -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
|
||||
|
|
7
main.cpp
7
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");
|
||||
|
|
Loading…
Reference in a new issue