fortschritt plottyfile
This commit is contained in:
parent
0f71e121fa
commit
71b156aa6f
13 changed files with 71 additions and 17 deletions
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.
BIN
drv/dot.o
Normal file
BIN
drv/dot.o
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.
Loading…
Add table
Add a link
Reference in a new issue