Permalink
Browse files

polished and veltesting overwork

  • Loading branch information...
1 parent 5988dae commit 9690045d18e6fe51afac5e01595fab26033d5967 Bernhard committed Dec 5, 2011
Showing with 38 additions and 14 deletions.
  1. +10 −6 mainwindow.cpp
  2. +17 −1 tab_raw.cpp
  3. +3 −1 tab_raw.h
  4. +7 −6 tab_veltest.cpp
  5. +1 −0 tab_veltest.h
View
@@ -327,18 +327,19 @@ void MainWindow::slotRead()
QByteArray ba = comport->readAll();
serialBinBuffer.append(ba);
int lastnewlinepos=serialBinBuffer.lastIndexOf('\n');
- qDebug()<<"newline@"<<lastnewlinepos;
+ // qDebug()<<"newline@"<<lastnewlinepos;
if(lastnewlinepos<0)
return; //no newline read yet.
QString readlines=QString(serialBinBuffer.mid(0,lastnewlinepos).append((char)0));
readSinceLastSend.append(readlines);
QStringList lines=readlines.split("\n",QString::SkipEmptyParts);
serialBinBuffer.remove(0,lastnewlinepos);
- tabRaw->edit->insertPlainText(readlines);
+
+ tabRaw->displayText(readlines);
foreach(QString s, lines) //s = linecontent
{
- qDebug()<<"read line:"<<s;
+ //qDebug()<<"read line:"<<s;
if(s.contains("endstop"))
endstopfound=true;
if(s.startsWith("ok") ||s.startsWith("T"))
@@ -435,6 +436,7 @@ void MainWindow::manualSend()
void MainWindow::send(QString text)
{
+ tabRaw->displayTextHtml(QString("<br><b><font color=red>Sending:%0</font></b><br>").arg(text));
if(!comport->isOpen())
return;
QString text2=text.append("\n");
@@ -447,7 +449,9 @@ void MainWindow::send(QString text)
void MainWindow::sendGcode(const QString &text)
{
- qDebug()<<"gcode cue list:"<<sendcodes.size();
+ //qDebug()<<"gcode cue list:"<<sendcodes.size();
+
+
sendcodes<<text;
if(wait_reply)
return;
@@ -463,7 +467,7 @@ void MainWindow::processReply()
return;
QStringList lines = readSinceLastSend.split("\n",QString::SkipEmptyParts);
- qDebug()<<"got reply for command "<<sendcodes[0];
+ //qDebug()<<"got reply for command "<<sendcodes[0];
QString overhang="";
foreach(QString s,lines)
@@ -478,7 +482,7 @@ void MainWindow::processReply()
if(overhang.startsWith("ok"))
{
- qDebug()<<"ack ok:"<<overhang<<endl;
+ //qDebug()<<"ack ok:"<<overhang<<endl;
if(sendcodes.size())
{
sendcodes.removeFirst();
View
@@ -39,4 +39,20 @@ TabRaw::TabRaw(QWidget* parent): QWidget(parent)
layout->addLayout(hlayout);
setLayout(layout);
-}
+}
+
+void TabRaw::displayText(const QString& text)
+{
+ edit->moveCursor(QTextCursor::End);
+ edit->insertPlainText(text);
+ if(!edit->underMouse())
+ edit->ensureCursorVisible();
+}
+
+void TabRaw::displayTextHtml(const QString& text)
+{
+ edit->moveCursor(QTextCursor::End);
+ edit->insertHtml(text);
+ if(!edit->underMouse())
+ edit->ensureCursorVisible();
+}
View
@@ -23,11 +23,13 @@ Q_OBJECT
public:
TabRaw(QWidget *parent = 0);
-
+ void displayText(const QString &text);
+ void displayTextHtml(const QString& text);
QTextEdit *edit;
QLineEdit *sendText;
QPushButton *btClear;
+
public slots:
View
@@ -151,22 +151,23 @@ void TabVeltest::starttest(uint8_t axis)
void TabVeltest::startTestCase(TestCase& tc)
{
float t=tc.v/tc.a;
+
//float x=tc.a*t*t/2.*2; //10mm + full acceleration distance.
float x=200;
qDebug()<<"Test:"<<tc.a<<" "<<tc.v<<endl;
mw->endstopfound=false;
mw->sendGcode(QString("M205 S0 T0"));
- mw->sendGcode(QString("M205 S0 T0 X%0 Z%1").arg(tc.xyjerk).arg(tc.zjerk));
- mw->sendGcode(QString("M202 X%0 Y%1 ").arg(tc.a).arg(tc.a));
+ mw->sendGcode(QString("M205 S0 T0 %0%1 Z%2").arg(AxisChars[tc.axis]).arg(tc.xyjerk).arg(tc.zjerk));
+ mw->sendGcode(QString("M202 %00%1 Y%2 ").arg(AxisChars[tc.axis]).arg(tc.a).arg(tc.a));
mw->sendGcode(QString("M204 S%0 T%1 ").arg(tc.a).arg(tc.a));
- mw->sendGcode(QString("M203 X%0 Y%1 ").arg(tc.v).arg(tc.v));
- mw->sendGcode(QString("G28 X0 "));
+ mw->sendGcode(QString("M203 %00%1 Y%2 ").arg(AxisChars[tc.axis]).arg(tc.v).arg(tc.v));
+ mw->sendGcode(QString("G28 %000 ").arg(AxisChars[tc.axis]));
- mw->sendGcode(QString("G1 X%0 F%1").arg(x).arg(tc.v));
+ mw->sendGcode(QString("G1 %00%1 F%2").arg(AxisChars[tc.axis]).arg(x).arg(tc.v*60));
mw->sendGcode(QString("M400"));
- mw->sendGcode(QString("G1 X1 F%1").arg(tc.v*0.5));
+ mw->sendGcode(QString("G1 %001 F%1").arg(AxisChars[tc.axis]).arg(tc.v*0.5*60));
mw->sendGcode(QString("M400"));
testing=true;
}
View
@@ -20,6 +20,7 @@ class QLabel;
#include "mainwindow.h"
+const char AxisChars[]={'X','Y','Z','E'};
struct TestCase
{
uint8_t axis;

0 comments on commit 9690045

Please sign in to comment.