-
Notifications
You must be signed in to change notification settings - Fork 9
/
printer.h
98 lines (94 loc) · 2.46 KB
/
printer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef PRINTER_H
#define PRINTER_H
#include <QObject>
#include <QTime>
#include <QDebug>
#include <QStringList>
#include <QPoint>
#include <QTextCodec>
#include <QThread>
#include <QTimer>
#include <QVector3D>
#include <QMutex>
#include <QWaitCondition>
#include "qextserialport.h"
#include "qextserialenumerator.h"
//thread class for serial port communication, currently not used
class Printer : public QObject
{
Q_OBJECT
private:
QextSerialPort *portObj;
bool isPrinting;
bool isPaused;
bool monitorTemperature;
QTimer *temperatureTimer;
QTimer *readTimer;
QVector3D curr_pos;
QString inBuffer;
QStringList responseBuffer;
bool writeNext;
double last_bed_temp;
double last_head_temp;
bool connectionActive;
QString checkSum(QString command);
//hold lines that were sent to printer
QStringList sentLines;
//hold lines to be send to printer
QStringList priQuery;
QStringList mainQuery;
int lineNum;
int resendFrom;
public:
explicit Printer(QObject *parent = 0);
bool isConnected();
bool getIsPrinting();
signals:
void write_to_console(QString);
void currentTemp(double,double,double);
void progress(int);
void currentPosition(QVector3D);
void connected(bool);
void newResponce(QString);
void settingTemp1(double);
void settingTemp3(double);
void printFinished(bool);
void clearToSend();
private slots:
void processResponce(QString);
public slots:
//read
void readFromPort();
//write
int writeToPort(QString command,int lineNum=-1, bool calcCheckSum=false);
//connecting to port
bool connectPort(QString port, int baud);
bool disconnectPort();
//slots for printer control
//moving axis
void homeX();
void homeY();
void homeZ();
void homeAll();
//move head x/y
void moveHead(QPoint point, int speed);
//move head Z
void moveHeadZ(double z, int speed,bool relative);
//setting fan speed
void setFan(int percent);
//disable stepper
void disableSteppers();
void loadToBuffer(QStringList buffer, bool clear);
void startPrint();
void pausePrint(bool);
void setMonitorTemperature(bool);
void getTemperature();
void setTemp1(int);
void setTemp3(int);
void extrude(int lenght, int speed);
void retrackt(int lenght, int speed);
void send(QString command);
void send_now(QString command);
void send_next();
};
#endif // PRINTER_H