//Misc Projects/GCodeInterface/IOWidget.h |
---|
File deleted |
//Misc Projects/GCodeInterface/Icon.rc |
---|
File deleted |
//Misc Projects/GCodeInterface/SerialWidget.h |
---|
File deleted |
//Misc Projects/GCodeInterface/Resources/arrow_right.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/arrow_right.png |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/Resources/arrow_up.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/arrow_up.png |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/Resources/download.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/download.png |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/Resources/arrow_down.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/arrow_down.png |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/Resources/Icon_32.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/Icon_32.bmp |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/Resources/Icon_64.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/Icon_64.bmp |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/Resources/upload.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/upload.png |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/Resources/Icon_16.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/Icon_16.bmp |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/Resources/arrow_left.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/arrow_left.png |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/Resources/close.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/close.png |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/Resources/Icon.ico |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/GCodeInterface/Resources/Icon.ico |
---|
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
//Misc Projects/GCodeInterface/MacroWidget.cpp |
---|
File deleted |
//Misc Projects/GCodeInterface/SerialHelper.h |
---|
File deleted |
//Misc Projects/GCodeInterface/main.cpp |
---|
File deleted |
//Misc Projects/GCodeInterface/GlobalDefines.h |
---|
File deleted |
//Misc Projects/GCodeInterface/MacroWidget.h |
---|
File deleted |
//Misc Projects/GCodeInterface/GCodeInterface.pro |
---|
File deleted |
//Misc Projects/GCodeInterface/IOWidget.cpp |
---|
File deleted |
//Misc Projects/GCodeInterface/SerialWidget.cpp |
---|
File deleted |
//Misc Projects/GCodeInterface/MainWindow.cpp |
---|
File deleted |
//Misc Projects/GCodeInterface/MainWindow.h |
---|
File deleted |
//Misc Projects/GCodeInterface/SerialHelper.cpp |
---|
File deleted |
//Misc Projects/GCodeInterface/PasteController.cpp |
---|
File deleted |
//Misc Projects/GCodeInterface/PasteController.h |
---|
File deleted |
//Misc Projects/GCodeInterface/Resources.qrc |
---|
File deleted |
//Misc Projects/GCodeInterface/GCodeInterface.pro.user |
---|
File deleted |
//Misc Projects/PcMarlinInterface/GCodeInterface.pro |
---|
0,0 → 1,35 |
#------------------------------------------------- |
# |
# Project created by QtCreator 2015-01-02T06:41:32 |
# |
#------------------------------------------------- |
QT += core gui serialport |
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets |
TARGET = PcMarlinInterface |
TEMPLATE = app |
SOURCES += main.cpp \ |
MainWindow.cpp \ |
SerialHelper.cpp \ |
MacroWidget.cpp \ |
SerialWidget.cpp \ |
IOWidget.cpp \ |
PasteController.cpp |
HEADERS += GlobalDefines.h \ |
MainWindow.h \ |
SerialHelper.h \ |
MacroWidget.h \ |
SerialWidget.h \ |
IOWidget.h \ |
PasteController.h |
RESOURCES += Resources.qrc |
RC_FILE = Icon.rc |
FORMS += |
//Misc Projects/PcMarlinInterface/GCodeInterface.pro.user |
---|
0,0 → 1,257 |
<?xml version="1.0" encoding="UTF-8"?> |
<!DOCTYPE QtCreatorProject> |
<!-- Written by QtCreator 3.3.0, 2015-06-25T15:18:35. --> |
<qtcreator> |
<data> |
<variable>EnvironmentId</variable> |
<value type="QByteArray">{22bd4f67-ea17-48ee-8299-171e5aa125c2}</value> |
</data> |
<data> |
<variable>ProjectExplorer.Project.ActiveTarget</variable> |
<value type="int">0</value> |
</data> |
<data> |
<variable>ProjectExplorer.Project.EditorSettings</variable> |
<valuemap type="QVariantMap"> |
<value type="bool" key="EditorConfiguration.AutoIndent">true</value> |
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> |
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value> |
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> |
<value type="QString" key="language">Cpp</value> |
<valuemap type="QVariantMap" key="value"> |
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value> |
</valuemap> |
</valuemap> |
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> |
<value type="QString" key="language">QmlJS</value> |
<valuemap type="QVariantMap" key="value"> |
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value> |
</valuemap> |
</valuemap> |
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> |
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value> |
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> |
<value type="int" key="EditorConfiguration.IndentSize">4</value> |
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value> |
<value type="int" key="EditorConfiguration.MarginColumn">80</value> |
<value type="bool" key="EditorConfiguration.MouseHiding">true</value> |
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value> |
<value type="int" key="EditorConfiguration.PaddingMode">1</value> |
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> |
<value type="bool" key="EditorConfiguration.ShowMargin">false</value> |
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> |
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> |
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> |
<value type="int" key="EditorConfiguration.TabSize">8</value> |
<value type="bool" key="EditorConfiguration.UseGlobal">true</value> |
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> |
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> |
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value> |
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> |
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value> |
</valuemap> |
</data> |
<data> |
<variable>ProjectExplorer.Project.PluginSettings</variable> |
<valuemap type="QVariantMap"/> |
</data> |
<data> |
<variable>ProjectExplorer.Project.Target.0</variable> |
<valuemap type="QVariantMap"> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.0 MSVC2013 64bit</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.4.0 MSVC2013 64bit</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.54.win64_msvc2013_64_kit</value> |
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Kevin/Documents/Code/QT/build-GCodeInterface-Desktop_Qt_5_4_0_MSVC2013_64bit-Debug</value> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> |
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value> |
</valuemap> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> |
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
</valuemap> |
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
</valuemap> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> |
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
</valuemap> |
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
</valuemap> |
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> |
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
</valuemap> |
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> |
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Kevin/Documents/Code/QT/build-GCodeInterface-Desktop_Qt_5_4_0_MSVC2013_64bit-Release</value> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> |
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value> |
</valuemap> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> |
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
</valuemap> |
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
</valuemap> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> |
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
</valuemap> |
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
</valuemap> |
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
</valuemap> |
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value> |
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
</valuemap> |
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
</valuemap> |
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
<value type="int">0</value> |
<value type="int">1</value> |
<value type="int">2</value> |
<value type="int">3</value> |
<value type="int">4</value> |
<value type="int">5</value> |
<value type="int">6</value> |
<value type="int">7</value> |
<value type="int">8</value> |
<value type="int">9</value> |
<value type="int">10</value> |
<value type="int">11</value> |
<value type="int">12</value> |
<value type="int">13</value> |
<value type="int">14</value> |
</valuelist> |
<value type="int" key="PE.EnvironmentAspect.Base">2</value> |
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">GCodeInterface</value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Kevin/Documents/Code/QT/GCodeInterface/GCodeInterface.pro</value> |
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">GCodeInterface.pro</value> |
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value> |
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value> |
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> |
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
</valuemap> |
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
</valuemap> |
</data> |
<data> |
<variable>ProjectExplorer.Project.TargetCount</variable> |
<value type="int">1</value> |
</data> |
<data> |
<variable>ProjectExplorer.Project.Updater.FileVersion</variable> |
<value type="int">18</value> |
</data> |
<data> |
<variable>Version</variable> |
<value type="int">18</value> |
</data> |
</qtcreator> |
//Misc Projects/PcMarlinInterface/GlobalDefines.h |
---|
0,0 → 1,40 |
#ifndef GLOBALDEFINES |
#define GLOBALDEFINES |
#include <QApplication> |
#include <QMainWindow> |
#include <QTextEdit> |
#include <QLineEdit> |
#include <QPushButton> |
#include <QDockWidget> |
#include <QLabel> |
#include <QToolButton> |
#include <QSpinBox> |
#include <QSlider> |
#include <QComboBox> |
#include <QGroupBox> |
#include <QGridLayout> |
#include <QHBoxLayout> |
#include <QSignalMapper> |
#include <QEvent> |
#include <QKeyEvent> |
#include <QAction> |
#include <QStatusBar> |
#include <QRegularExpression> |
#include <QRegularExpressionMatch> |
#include <QQueue> |
#include <QTextStream> |
#include <QTime> |
#include <QTimer> |
#include <QFileDialog> |
#include <QFileInfo> |
#include <QXmlStreamWriter> |
#include <QXmlStreamReader> |
#define STATUS_TIMEOUT_MS 3000 |
#endif // GLOBALDEFINES |
//Misc Projects/PcMarlinInterface/IOWidget.cpp |
---|
0,0 → 1,103 |
#include "IOWidget.h" |
IOWidget::IOWidget(QWidget *parent) : QWidget(parent) |
{ |
// Serial data UI |
textData = new QTextEdit(); |
textData->setCurrentFont(QFont("Consolas", 8)); |
textData->append("Waiting for serial connection... "); |
textData->setMinimumSize(400, 100); |
textData->setReadOnly(true); |
textTransmit = new QLineEdit(); |
textTransmit->setEnabled(false); |
textTransmit->setFont(QFont("Consolas", 8)); |
btnTransmit = new QPushButton("&Send"); |
btnTransmit->setEnabled(false); |
btnClear = new QPushButton("Clear"); |
QHBoxLayout *transmitLayout = new QHBoxLayout(); |
transmitLayout->addWidget(textTransmit); |
transmitLayout->addWidget(btnTransmit); |
transmitLayout->addWidget(btnClear); |
QVBoxLayout *dataLayout = new QVBoxLayout(); |
dataLayout->addWidget(textData); |
dataLayout->addLayout(transmitLayout); |
setLayout(dataLayout); |
connect(btnTransmit, SIGNAL(clicked()), this, SLOT(PreprocessTransmit())); |
connect(textTransmit, SIGNAL(returnPressed()), btnTransmit, SIGNAL(clicked())); |
connect(btnClear, SIGNAL(clicked()), this, SLOT(ClearBtn())); |
// EnableTransmit(false); |
textTransmit->setEnabled(false); |
btnTransmit->setEnabled(false); |
lastTransmit = true; |
} |
IOWidget::~IOWidget() |
{ |
} |
void IOWidget::PreprocessTransmit(QByteArray data) |
{ |
QString str; |
if (data.isEmpty()) { |
str = textTransmit->text(); |
textTransmit->setText(""); |
} else { |
str = QString(data); |
} |
QTime curTime = QTime::currentTime(); |
QStringList cmds = str.split('\n', QString::SkipEmptyParts); |
for (int i = 0; i < cmds.size(); i++) { |
emit TransmitByteArray((cmds[i] + '\n').toUtf8()); |
textData->setTextColor(Qt::darkBlue); |
textData->append(curTime.toString("[HH:mm:ss:zzz]: ") + cmds[i]); |
} |
textData->moveCursor(QTextCursor::End); |
textData->ensureCursorVisible(); |
// Save a flag indicating last activity was a transmit |
lastTransmit = true; |
} |
void IOWidget::ProcessReceivedByte(QByteArray data) |
{ |
textData->setTextColor(Qt::darkRed); |
QTime curTime = QTime::currentTime(); |
QString timeString = "\n" + curTime.toString("[HH:mm:ss:zzz]: "); |
if (data.endsWith('\n')) data.remove(data.size()-1, 1); |
data.replace('\n', timeString); |
if (lastTransmit) { |
textData->insertPlainText(timeString + QString(data)); |
} else { |
textData->insertPlainText(QString(data)); |
} |
textData->moveCursor(QTextCursor::End); |
textData->ensureCursorVisible(); |
lastTransmit = false; |
} |
void IOWidget::ClearBtn() |
{ |
textData->clear(); |
} |
void IOWidget::EnableTransmit(bool enable) |
{ |
textData->setTextColor(Qt::black); |
if (enable) { |
textTransmit->setEnabled(true); |
btnTransmit->setEnabled(true); |
textData->insertPlainText("connected!"); |
} else { |
textTransmit->setEnabled(false); |
btnTransmit->setEnabled(false); |
textData->append("Serial disconnected."); |
textData->append("Waiting for serial connection... "); |
} |
textData->moveCursor(QTextCursor::End); |
textData->ensureCursorVisible(); |
} |
//Misc Projects/PcMarlinInterface/MacroWidget.cpp |
---|
0,0 → 1,400 |
#include "MacroWidget.h" |
MacroWidget::MacroWidget(QWidget *parent) : QWidget(parent) |
{ |
sigmapTransmit = new QSignalMapper(); |
sigmapKeybind = new QSignalMapper(); |
btnExport = new QPushButton("Export"); |
btnImport = new QPushButton("Import"); |
btnAddMacro = new QPushButton("&Add"); |
btnRemoveMacro = new QPushButton("&Remove"); |
btnClear = new QPushButton("&Clear"); |
currKeyBindInfo = QPair<QPushButton*,int>(NULL, 0); |
mainLayout = new QGridLayout(); |
count = 0; |
connected = false; |
lastKnownFilePath = "."; |
ioLayout = new QHBoxLayout(); |
ioLayout->addWidget(btnAddMacro); |
ioLayout->addWidget(btnRemoveMacro); |
ioLayout->addWidget(btnClear); |
ioLayout->addWidget(btnExport); |
ioLayout->addWidget(btnImport); |
ioLayout->addStretch(); |
mainLayout->addLayout(ioLayout, 0, 0, 1, 2); |
for (int i = 0; i < MACRO_DEFAULT_COUNT; i++) { |
AddEntry(); |
} |
setLayout(mainLayout); |
connect(btnAddMacro, SIGNAL(clicked()), this, SLOT(AddEntry())); |
connect(btnRemoveMacro, SIGNAL(clicked()), this, SLOT(RemoveEntry())); |
connect(btnClear, SIGNAL(clicked()), this, SLOT(Clear())); |
connect(btnExport, SIGNAL(clicked()), this, SLOT(WriteToFile())); |
connect(btnImport, SIGNAL(clicked()), this, SLOT(ReadFromFile())); |
connect(sigmapTransmit, SIGNAL(mapped(QWidget*)), this, SLOT(InitTransmit(QWidget*))); |
connect(sigmapKeybind, SIGNAL(mapped(int)), this, SLOT(KeybindPrompt(int))); |
// Register global event process for keyboard shortcut handling |
qApp->installEventFilter(this); |
} |
MacroWidget::~MacroWidget() |
{ |
} |
QSize MacroWidget::sizeHint() const |
{ |
return this->minimumSizeHint(); |
} |
void MacroWidget::EnableTransmit(bool enable) |
{ |
if (enable) { |
connected = true; |
for (int i = 0; i < btnSendList.size(); i++) { |
btnSendList[i]->setEnabled(true); |
} |
} else { |
connected = false; |
for (int i = 0; i < btnSendList.size(); i++) { |
btnSendList[i]->setEnabled(false); |
} |
} |
} |
void MacroWidget::InitTransmit(QWidget *t) |
{ |
if (connected) { |
QTextEdit *text = qobject_cast<QTextEdit*>(t); |
emit TransmitText(text->toPlainText().toUtf8()); |
} |
} |
void MacroWidget::KeybindPrompt(int id) |
{ |
QPushButton *btn = qobject_cast<QPushButton*>(sigmapKeybind->mapping(id)); |
// Check to make sure we arn't processing another key first |
if (currKeyBindInfo.first != NULL) { |
currKeyBindInfo.first->setText("Hotkey: None"); |
currKeyBindInfo.first->setDown(false); |
currKeyBindInfo.first->removeEventFilter(this); |
} |
// Mark and save button as waiting for key sequence |
btn->setDown(true); |
btn->setText("Waiting for Key.."); |
currKeyBindInfo = QPair<QPushButton*,int>(btn, id); |
// Remove current keybinding for this macro |
int index = registeredKeyMacroIDs.indexOf(id); |
if (index >= 0) { |
registeredKeySequences.removeAt(index); |
registeredKeyMacroIDs.removeAt(index); |
} |
// Inspect all following keyboard events |
btn->installEventFilter(this); |
} |
void MacroWidget::AddEntry() |
{ |
count++; |
// Create new layout/widgets |
QLineEdit *lineEdit = new QLineEdit(QString("Macro %1").arg(count)); |
lineEdit->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); |
lineEdit->setMinimumWidth(100); |
lineEdit->setAlignment(Qt::AlignCenter); |
nameList.append(lineEdit); |
QTextEdit *textEdit = new QTextEdit(); |
textEdit->setMinimumHeight(50); |
textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
textEdit->setWordWrapMode(QTextOption::NoWrap); |
textEdit->setFont(QFont("Consolas", 8)); |
textEdit->setAcceptRichText(false); |
textEdit->setTabChangesFocus(true); |
valueList.append(textEdit); |
QPushButton *keyButton = new QPushButton("Hotkey: None"); |
keyButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
btnKeyList.append(keyButton); |
QPushButton *pushButton = new QPushButton("Send Macro"); |
pushButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
pushButton->setEnabled(connected); |
btnSendList.append(pushButton); |
QVBoxLayout *tmpLayout = new QVBoxLayout(); |
tmpLayout->addWidget(lineEdit); |
tmpLayout->addWidget(keyButton); |
tmpLayout->addWidget(pushButton); |
// Add layout/widgets to main layout |
mainLayout->addLayout(tmpLayout, count, 0); |
mainLayout->addWidget(textEdit, count, 1); |
mainLayout->setColumnStretch(1, 1); |
// Associate KeyButton with its corresponding ID |
sigmapKeybind->setMapping(keyButton, count-1); |
connect(keyButton, SIGNAL(clicked()), sigmapKeybind, SLOT(map())); |
// Associate PushButton with its corresponding TextEdit |
sigmapTransmit->setMapping(pushButton, textEdit); |
connect(pushButton, SIGNAL(clicked()), sigmapTransmit, SLOT(map())); |
QLayoutItem *item = mainLayout->itemAtPosition(1, 1); |
int height = item->widget()->height() + mainLayout->verticalSpacing(); |
QDockWidget *parent = qobject_cast<QDockWidget*>(this->parent()); |
if (parent->isFloating()) |
parent->resize(parent->width(), parent->height() + height); |
btnRemoveMacro->setEnabled(true); |
} |
void MacroWidget::RemoveEntry() |
{ |
// Remove and delete layout/widgets at last macro slot |
QLayoutItem *item = mainLayout->itemAtPosition(count, 0); |
while(!item->isEmpty()) |
delete item->layout()->takeAt(0)->widget(); |
delete item; |
item = mainLayout->itemAtPosition(count, 1); |
delete item->widget(); |
item = mainLayout->itemAtPosition(1, 1); |
int height = item->widget()->height() + mainLayout->verticalSpacing(); |
// Unmap and remove widgets from lists |
QPushButton *pushButton = btnSendList.back(); |
sigmapTransmit->removeMappings(pushButton); |
QPushButton *keyButton = btnKeyList.back(); |
sigmapKeybind->removeMappings(keyButton); |
nameList.pop_back(); |
valueList.pop_back(); |
btnSendList.pop_back(); |
btnKeyList.pop_back(); |
int index = registeredKeyMacroIDs.indexOf(count-1); |
if (index >= 0) { |
registeredKeySequences.removeAt(index); |
registeredKeyMacroIDs.removeAt(index); |
} |
count--; |
QDockWidget *parent = qobject_cast<QDockWidget*>(this->parent()); |
if (parent->isFloating()) |
parent->resize(parent->width(), parent->height() - height); |
if (count == 1) |
btnRemoveMacro->setEnabled(false); |
} |
void MacroWidget::Clear() |
{ |
for (int i = 0; i < count; i++) { |
nameList[i]->setText(QString("Macro %1").arg(i+1)); |
valueList[i]->clear(); |
btnKeyList[i]->setText("Hotkey: None"); |
} |
registeredKeyMacroIDs.clear(); |
registeredKeySequences.clear(); |
} |
void MacroWidget::WriteToFile() |
{ |
QString file = QFileDialog::getSaveFileName(this, "Settings XML File", lastKnownFilePath, "XML File (*.xml)"); |
QCoreApplication::processEvents(); // Wait for dialog to close |
if (file.size() == 0) return; |
// If file was selected, save directory for next time |
QFileInfo fileInfo = QFileInfo(file); |
lastKnownFilePath = fileInfo.absolutePath(); |
if (file.size() != 0) |
QFile::remove(file); |
QFile inputFile(file); |
if (!inputFile.open(QIODevice::ReadWrite | QIODevice::Text)) return; |
QXmlStreamWriter stream(&inputFile); |
stream.setAutoFormatting(true); |
stream.writeStartDocument(); |
stream.writeStartElement("Settings"); |
stream.writeStartElement("Macro"); |
for (int i = 0; i < count; i++) { |
stream.writeStartElement("Macro_Entry"); |
stream.writeAttribute("Name", nameList[i]->text()); |
stream.writeTextElement("Value", valueList[i]->toPlainText()); |
int index = registeredKeyMacroIDs.indexOf(i); |
if (index >= 0) { |
stream.writeTextElement("Keybinding", registeredKeySequences[index].toString()); |
} else { |
stream.writeTextElement("Keybinding", ""); |
} |
stream.writeEndElement(); // Macro Entry |
} |
stream.writeEndElement(); // Macro |
stream.writeEndElement(); // Settings |
stream.writeEndDocument(); |
inputFile.close(); |
} |
void MacroWidget::ReadFromFile() |
{ |
int counter = 0; |
QString file = QFileDialog::getOpenFileName(this, "Settings XML File", lastKnownFilePath, "XML File (*.xml)"); |
QCoreApplication::processEvents(); // Wait for dialog to close |
if (file.size() == 0) return; |
Clear(); |
// If file was selected, save directory for next time |
QFileInfo fileInfo = QFileInfo(file); |
lastKnownFilePath = fileInfo.absolutePath(); |
QFile inputFile(file); |
if (!inputFile.open(QIODevice::ReadWrite | QIODevice::Text)) return; |
QXmlStreamReader stream(&inputFile); |
// Parse the XML file till we reach the end (or errors) |
while (!stream.atEnd() && !stream.hasError()) { |
QXmlStreamReader::TokenType token = stream.readNext(); |
// Ignore StartDocument |
if (token == QXmlStreamReader::StartDocument) continue; |
// Parse StartElements |
if (token == QXmlStreamReader::StartElement) { |
// Ignore elements <Settings> and <Macro> |
if (stream.name() == "Settings") continue; |
if (stream.name() == "Macro") continue; |
// Parse element <Macro_Entry> |
if (stream.name() == "Macro_Entry") { |
QString name, value, keybinding; |
// Read and save attribute value |
QXmlStreamAttributes attr = stream.attributes(); |
if (attr.hasAttribute("Name")) |
name = attr.value("Name").toString(); |
stream.readNext(); |
// Loop in this element to find all sub-elements |
while (!(stream.tokenType() == QXmlStreamReader::EndElement && stream.name() == "Macro_Entry")) { |
// Parse and save element value |
if (stream.tokenType() == QXmlStreamReader::StartElement) { |
if (stream.name() == "Value") { |
stream.readNext(); |
value = stream.text().toString(); |
} |
if (stream.name() == "Keybinding") { |
stream.readNext(); |
keybinding = stream.text().toString(); |
} |
} |
stream.readNext(); |
} |
// Write values to GUI |
if (counter == count) |
AddEntry(); |
nameList[counter]->setText(name); |
valueList[counter]->setText(value); |
if (keybinding != "") { |
registeredKeySequences.append(QKeySequence(keybinding)); |
registeredKeyMacroIDs.append(counter); |
btnKeyList[counter]->setText("Hotkey: " + keybinding); |
} |
counter++; |
} |
} |
} |
} |
bool MacroWidget::eventFilter(QObject *obj, QEvent *event) |
{ |
// Only process keyboard events |
if (event->type() == QEvent::KeyPress) { |
QKeyEvent *keyevent = static_cast<QKeyEvent*>(event); |
QKeySequence seq = keyevent->modifiers() + keyevent->key(); |
if ((keyevent->key() >= 0x21 && keyevent->key() <= 0x2F) || |
(keyevent->key() >= 0x3A && keyevent->key() <= 0x40) || |
(keyevent->key() >= 0x5E && keyevent->key() <= 0x7E) ) { |
seq = keyevent->key(); |
} |
if (connected) { |
// First check if key sequence matches any saved ones |
if (!registeredKeySequences.isEmpty()) { |
int index = registeredKeySequences.indexOf(seq); |
if (index >= 0) { |
InitTransmit(valueList[registeredKeyMacroIDs[index]]); |
return true; |
} |
} |
} |
// Then save key sequence if needed |
if (currKeyBindInfo.first != NULL) { |
// Ignore modifier keys and locks |
if (keyevent->key() == Qt::Key_Shift || keyevent->key() == Qt::Key_Control || |
keyevent->key() == Qt::Key_Meta || keyevent->key() == Qt::Key_Alt || |
keyevent->key() == Qt::Key_AltGr || keyevent->key() == Qt::Key_CapsLock || |
keyevent->key() == Qt::Key_NumLock || keyevent->key() == Qt::Key_ScrollLock) |
return true; |
// Reset on ESC key |
if (keyevent->key() == Qt::Key_Escape) { |
currKeyBindInfo.first->setText("Hotkey: None"); |
currKeyBindInfo.first->setDown(false); |
currKeyBindInfo.first->removeEventFilter(this); |
currKeyBindInfo = QPair<QPushButton*, int>(NULL, 0); |
return true; |
} |
// Otherwise save key sequence if it doesnt already exist |
if (!registeredKeySequences.contains(seq)) { |
registeredKeySequences.append(seq); |
registeredKeyMacroIDs.append(currKeyBindInfo.second); |
currKeyBindInfo.first->setText("Hotkey: " + seq.toString()); |
currKeyBindInfo.first->setDown(false); |
currKeyBindInfo.first->removeEventFilter(this); |
currKeyBindInfo = QPair<QPushButton*, int>(NULL, 0); |
return true; |
} |
} |
} |
return QWidget::eventFilter(obj, event); |
} |
//Misc Projects/PcMarlinInterface/MainWindow.cpp |
---|
0,0 → 1,107 |
#include "MainWindow.h" |
MainWindow::MainWindow(QWidget *parent) : |
QMainWindow(parent) |
{ |
// Set central widget |
centralWidget = new QWidget(); |
setCentralWidget(centralWidget); |
// Misc button group |
groupOther = new QGroupBox("Other"); |
btnMacro = new QPushButton("&Macros"); |
btnPaste = new QPushButton("&Paste"); |
ToggleGroupLayout(false); |
// Initialize serial widget |
serialWidget = new SerialWidget(); |
groupSerialInit = new QGroupBox("Serial Connection"); |
QGridLayout *serialInitLayout = new QGridLayout(); |
serialInitLayout->setContentsMargins(0, 0, 0, 0); |
serialInitLayout->addWidget(serialWidget); |
groupSerialInit->setLayout(serialInitLayout); |
connect(serialWidget, SIGNAL(UpdateStatus(QString)), this, SLOT(UpdateSerialStatus(QString))); |
// Initialize data widget |
ioWidget = new IOWidget(); |
groupSerialData = new QGroupBox("Data"); |
QGridLayout *serialDataLayout = new QGridLayout(); |
serialDataLayout->setContentsMargins(0, 0, 0, 0); |
serialDataLayout->addWidget(ioWidget); |
groupSerialData->setLayout(serialDataLayout); |
connect(serialWidget, SIGNAL(ReceivedByte(QByteArray)), ioWidget, SLOT(ProcessReceivedByte(QByteArray))); |
connect(serialWidget, SIGNAL(Connected(bool)), ioWidget, SLOT(EnableTransmit(bool))); |
connect(ioWidget, SIGNAL(TransmitByteArray(QByteArray)), serialWidget, SIGNAL(TransmitByteArray(QByteArray))); |
// Initialize macro widget |
macroDockWidget = new QDockWidget("Macro Controller", this); |
macroWidget = new MacroWidget(macroDockWidget); |
macroDockWidget->setWidget(macroWidget); |
macroDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); |
macroDockWidget->hide(); |
addDockWidget(Qt::RightDockWidgetArea, macroDockWidget); |
connect(macroWidget, SIGNAL(TransmitText(QByteArray)), ioWidget, SLOT(PreprocessTransmit(QByteArray))); |
connect(serialWidget, SIGNAL(Connected(bool)), macroWidget, SLOT(EnableTransmit(bool))); |
// Initialize paste controller widget |
pasteDockWidget = new QDockWidget("Paste Controller", this); |
pasteWidget = new PasteController(pasteDockWidget); |
pasteDockWidget->setWidget(pasteWidget); |
pasteDockWidget->setFloating(true); |
pasteDockWidget->hide(); |
connect(serialWidget, SIGNAL(Connected(bool)), pasteWidget, SLOT(EnableTransmit(bool))); |
connect(pasteWidget, SIGNAL(TransmitData(QByteArray)), ioWidget, SLOT(PreprocessTransmit(QByteArray))); |
connect(serialWidget, SIGNAL(ReceivedByte(QByteArray)), pasteWidget, SLOT(ProcessData(QByteArray))); |
// Connect local widgets |
connect(btnMacro, SIGNAL(clicked()), macroDockWidget->toggleViewAction(), SLOT(trigger())); |
connect(btnPaste, SIGNAL(clicked()), pasteDockWidget->toggleViewAction(), SLOT(trigger())); |
// Main layout |
QGridLayout *mainLayout = new QGridLayout(); |
mainLayout->addWidget(groupSerialInit, 0, 0, 1, 1, Qt::AlignLeft); |
mainLayout->addWidget(groupOther, 0, 1, 1, 1, Qt::AlignLeft); |
mainLayout->addWidget(groupSerialData, 1, 0, 1, 2); |
mainLayout->setColumnStretch(0, 0); |
mainLayout->setColumnStretch(1, 1); |
centralWidget->setLayout(mainLayout); |
connect(serialWidget, SIGNAL(Connected(bool)), this, SLOT(ToggleGroupLayout(bool))); |
setWindowTitle("Marlin Controller"); |
setWindowIcon(QIcon(":/External/Resources/Icon_16.bmp")); |
labelSerialStatus = new QLabel("Disconnected"); |
statusBar()->addPermanentWidget(labelSerialStatus); |
} |
MainWindow::~MainWindow() |
{ |
} |
void MainWindow::UpdateStatus(QString string) |
{ |
statusBar()->showMessage(string, STATUS_TIMEOUT_MS); |
} |
void MainWindow::UpdateSerialStatus(QString string) |
{ |
labelSerialStatus->setText(string); |
} |
void MainWindow::ToggleGroupLayout(bool toggle) |
{ |
QGridLayout *layout = qobject_cast<QGridLayout*>(groupOther->layout()); |
if (layout == NULL) layout = new QGridLayout(); |
layout->removeWidget(btnMacro); |
layout->removeWidget(btnPaste); |
if (toggle) { |
layout->addWidget(btnMacro, 0, 0); |
layout->addWidget(btnPaste, 0, 1); |
} else { |
layout->addWidget(btnMacro, 0, 0); |
layout->addWidget(btnPaste, 1, 0); |
} |
groupOther->setLayout(layout); |
groupOther->repaint(); |
} |
//Misc Projects/PcMarlinInterface/MainWindow.h |
---|
0,0 → 1,57 |
#ifndef MAINWINDOW_H |
#define MAINWINDOW_H |
#include "GlobalDefines.h" |
#include "SerialWidget.h" |
#include "MacroWidget.h" |
#include "IOWidget.h" |
#include "PasteController.h" |
#include "GerberParser.h" |
class MainWindow : public QMainWindow |
{ |
Q_OBJECT |
public: |
MainWindow(QWidget *parent = 0); |
~MainWindow(); |
public slots: |
void UpdateStatus(QString string); |
void UpdateSerialStatus(QString string); |
void ToggleGroupLayout(bool); |
signals: |
void Serial_TransmitByteArray(QByteArray data); |
protected: |
private: |
QWidget *centralWidget; |
// Serial controller + UI |
SerialWidget *serialWidget; |
QGroupBox *groupSerialInit; |
QPushButton *btnSerialConnect; |
// Serial data |
IOWidget *ioWidget; |
QGroupBox *groupSerialData; |
QGroupBox *groupOther; |
// Macro controller + UI |
MacroWidget *macroWidget; |
QDockWidget *macroDockWidget; |
QPushButton *btnMacro; |
// Paste controller + UI |
PasteController *pasteWidget; |
QDockWidget *pasteDockWidget; |
QPushButton *btnPaste; |
// Status bar |
QLabel *labelSerialStatus; |
}; |
#endif // MAINWINDOW_H |
//Misc Projects/PcMarlinInterface/PasteController.cpp |
---|
0,0 → 1,647 |
#include "PasteController.h" |
PasteController::PasteController(QWidget *parent) : QWidget(parent) |
{ |
connected = false; |
hotkeysEnabled = false; |
xPos = yPos = zPos = 0.0; |
X_Incr = X_Decr = Y_Incr = Y_Decr = Z_Incr = Z_Decr = E_Incr = false; |
transmittingData = false; |
queueCmds = new QQueue<QString>(); |
tmrUpdate = new QTimer(this); |
connect(tmrUpdate, SIGNAL(timeout()), this, SLOT(MoveToolhead())); |
QString helpString = ""; |
helpString.append("XY Control: Arrow Keys or H/J/K/L\n"); |
helpString.append("Z Control: PgUp/PgDown\n"); |
helpString.append(" - Hold Shift for Slower Movement\n"); |
helpString.append("Extruder Trigger: Space"); |
labelHelp = new QLabel(helpString); |
QVBoxLayout *helpLayout = new QVBoxLayout(); |
helpLayout->addWidget(labelHelp); |
QGroupBox *helpBox = new QGroupBox("Hotkeys:"); |
helpBox->setLayout(helpLayout); |
btnEnableHotkeys = new QPushButton("&Enable Hotkeys"); |
connect(btnEnableHotkeys, SIGNAL(clicked()), this, SLOT(ToggleHotkeys())); |
btnInit = new QPushButton("&Initialize Printer"); |
connect(btnInit, SIGNAL(clicked()), this, SLOT(InitializePrinter())); |
btnHome = new QPushButton("&Home Printhead"); |
connect(btnHome, SIGNAL(clicked()), this, SLOT(ResetPosition())); |
QVBoxLayout *miscBtnLayout = new QVBoxLayout(); |
miscBtnLayout->addWidget(btnInit); |
miscBtnLayout->addWidget(btnEnableHotkeys); |
miscBtnLayout->addWidget(btnHome); |
QGroupBox *miscBtnBox = new QGroupBox("Preset Commands"); |
miscBtnBox->setLayout(miscBtnLayout); |
miscBtnBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum); |
// Icons from http://ikons.piotrkwiatkowski.co.uk/index.html |
QIcon iconUp(":/External/Resources/arrow_up.png"); |
QIcon iconDown(":/External/Resources/arrow_down.png"); |
QIcon iconLeft(":/External/Resources/arrow_left.png"); |
QIcon iconRight(":/External/Resources/arrow_right.png"); |
QIcon iconAdd(":/External/Resources/upload.png"); |
QIcon iconRemove(":/External/Resources/download.png"); |
QIcon iconDelete(":/External/Resources/close.png"); |
btnForward = new QToolButton(); |
btnForward->setIcon(iconUp); |
btnForward->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE)); |
btnForward->setAutoRaise(true); |
connect(btnForward, SIGNAL(clicked()), this, SLOT(MoveToolheadSingle())); |
btnBackward = new QToolButton(); |
btnBackward->setIcon(iconDown); |
btnBackward->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE)); |
btnBackward->setAutoRaise(true); |
connect(btnBackward, SIGNAL(clicked()), this, SLOT(MoveToolheadSingle())); |
btnLeft = new QToolButton(); |
btnLeft->setIcon(iconLeft); |
btnLeft->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE)); |
btnLeft->setAutoRaise(true); |
connect(btnLeft, SIGNAL(clicked()), this, SLOT(MoveToolheadSingle())); |
btnRight = new QToolButton(); |
btnRight->setIcon(iconRight); |
btnRight->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE)); |
btnRight->setAutoRaise(true); |
connect(btnRight, SIGNAL(clicked()), this, SLOT(MoveToolheadSingle())); |
btnUp = new QToolButton(); |
btnUp->setIcon(iconAdd); |
btnUp->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE)); |
btnUp->setAutoRaise(true); |
connect(btnUp, SIGNAL(clicked()), this, SLOT(MoveToolheadSingle())); |
btnDown = new QToolButton(); |
btnDown->setIcon(iconRemove); |
btnDown->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE)); |
btnDown->setAutoRaise(true); |
connect(btnDown, SIGNAL(clicked()), this, SLOT(MoveToolheadSingle())); |
btnExtrude = new QToolButton(); |
btnExtrude->setIcon(iconDelete); |
btnExtrude->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE)); |
btnExtrude->setAutoRaise(true); |
connect(btnExtrude, SIGNAL(clicked()), this, SLOT(ExtrudeSingle())); |
QGridLayout *btnXYELayout = new QGridLayout(); |
btnXYELayout->addWidget(btnForward, 0, 1, 1, 1); |
btnXYELayout->addWidget(btnLeft, 1, 0, 1, 1); |
btnXYELayout->addWidget(btnExtrude, 1, 1, 1, 1); |
btnXYELayout->addWidget(btnRight, 1, 2, 1, 1); |
btnXYELayout->addWidget(btnBackward, 2, 1, 1, 1); |
QVBoxLayout *btnZLayout = new QVBoxLayout(); |
btnZLayout->addWidget(btnUp); |
btnZLayout->addWidget(btnDown); |
QHBoxLayout *btnNavLayout = new QHBoxLayout(); |
btnNavLayout->addLayout(btnXYELayout); |
btnNavLayout->addLayout(btnZLayout); |
QGroupBox *controlBox = new QGroupBox("Manual Printer Control"); |
controlBox->setLayout(btnNavLayout); |
controlBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); |
labelXPos = new QLabel("X :"); |
labelXPos->setFont(QFont("", 14, QFont::Normal)); |
labelYPos = new QLabel("Y :"); |
labelYPos->setFont(QFont("", 14, QFont::Normal)); |
labelZPos = new QLabel("Z :"); |
labelZPos->setFont(QFont("", 14, QFont::Normal)); |
textXValue = new QLineEdit(); |
textXValue->setReadOnly(true); |
textXValue->setMaximumWidth(60); |
textXValue->setFont(QFont("", 10, QFont::Bold)); |
textXValue->setAlignment(Qt::AlignCenter); |
textXValue->setText(QString::number(xPos, 'f', 2)); |
textYValue = new QLineEdit(); |
textYValue->setReadOnly(true); |
textYValue->setMaximumWidth(60); |
textYValue->setFont(QFont("", 10, QFont::Bold)); |
textYValue->setAlignment(Qt::AlignCenter); |
textYValue->setText(QString::number(yPos, 'f', 2)); |
textZValue = new QLineEdit(); |
textZValue->setReadOnly(true); |
textZValue->setMaximumWidth(60); |
textZValue->setFont(QFont("", 10, QFont::Bold)); |
textZValue->setAlignment(Qt::AlignCenter); |
textZValue->setText(QString::number(zPos, 'f', 2)); |
QHBoxLayout *posValueLayout = new QHBoxLayout(); |
posValueLayout->addWidget(labelXPos); |
posValueLayout->addWidget(textXValue); |
posValueLayout->addWidget(labelYPos); |
posValueLayout->addWidget(textYValue); |
posValueLayout->addWidget(labelZPos); |
posValueLayout->addWidget(textZValue); |
QGroupBox *toolheadPosBox = new QGroupBox("Toolhead Position"); |
toolheadPosBox->setLayout(posValueLayout); |
toolheadPosBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); |
labelXYSteps = new QLabel("XY Axis Step (mm):"); |
sliderXYSteps = new QSlider(Qt::Horizontal); |
textXYSteps = new QDoubleSpinBox(); |
textXYSteps->setMinimumWidth(60); |
labelXYSpeed = new QLabel("XY Axis Speed (mm/s):"); |
sliderXYSpeed = new QSlider(Qt::Horizontal); |
textXYSpeed = new QSpinBox(); |
textXYSpeed->setMinimumWidth(60); |
labelZSteps = new QLabel("Z Axis Step (mm):"); |
sliderZSteps = new QSlider(Qt::Horizontal); |
textZSteps = new QDoubleSpinBox(); |
textZSteps->setMinimumWidth(60); |
labelZSpeed = new QLabel("Z Axis Speed (mm/s):"); |
sliderZSpeed = new QSlider(Qt::Horizontal); |
textZSpeed = new QSpinBox(); |
textZSpeed->setMinimumWidth(60); |
labelRepeatDelay = new QLabel("Repeat Delay (ms):"); |
sliderRepeatDelay = new QSlider(Qt::Horizontal); |
textRepeatDelay = new QSpinBox(); |
textRepeatDelay->setMinimumWidth(60); |
labelEForwardSteps = new QLabel("Extrude Step (mm):"); |
sliderEForwardSteps = new QSlider(Qt::Horizontal); |
textEForwardSteps = new QDoubleSpinBox(); |
textEForwardSteps->setMinimumWidth(60); |
labelEForwardSpeed = new QLabel("Extrude Speed (mm/s):"); |
sliderEForwardSpeed = new QSlider(Qt::Horizontal); |
textEForwardSpeed = new QSpinBox(); |
textEForwardSpeed->setMinimumWidth(60); |
labelEBackwardSteps = new QLabel("Retract Step (mm):"); |
sliderEBackwardSteps = new QSlider(Qt::Horizontal); |
textEBackwardSteps = new QDoubleSpinBox(); |
textEBackwardSteps->setMinimumWidth(60); |
labelEBackwardSpeed = new QLabel("Retract Speed: (mm/s)"); |
sliderEBackwardSpeed = new QSlider(Qt::Horizontal); |
textEBackwardSpeed = new QSpinBox(); |
textEBackwardSpeed->setMinimumWidth(60); |
labelExtrusionHeight = new QLabel("Extrude Height (mm):"); |
sliderExtrusionHeight = new QSlider(Qt::Horizontal); |
textExtrusionHeight = new QDoubleSpinBox(); |
textExtrusionHeight->setMinimumWidth(60); |
labelEZSteps = new QLabel("Z Axis Step (mm):"); |
sliderEZSteps = new QSlider(Qt::Horizontal); |
textEZSteps = new QDoubleSpinBox(); |
textEZSteps->setMinimumWidth(60); |
connect(sliderXYSteps, SIGNAL(valueChanged(int)), this, SLOT(QSliderToQDoubleSpinBox(int))); |
connect(textXYSteps, SIGNAL(valueChanged(double)), this, SLOT(QDoubleSpinBoxToQSlider(double))); |
sliderXYSteps->setRange(0, 1000); |
textXYSteps->setRange(0,10); |
textXYSteps->setSingleStep(0.1); |
textXYSteps->setValue(0.5); |
connect(sliderXYSpeed, SIGNAL(valueChanged(int)), textXYSpeed, SLOT(setValue(int))); |
connect(textXYSpeed, SIGNAL(valueChanged(int)), sliderXYSpeed, SLOT(setValue(int))); |
sliderXYSpeed->setRange(1, 4000); |
textXYSpeed->setRange(1, 4000); |
textXYSpeed->setSingleStep(100); |
textXYSpeed->setValue(600); |
connect(sliderZSteps, SIGNAL(valueChanged(int)), this, SLOT(QSliderToQDoubleSpinBox(int))); |
connect(textZSteps, SIGNAL(valueChanged(double)), this, SLOT(QDoubleSpinBoxToQSlider(double))); |
sliderZSteps->setRange(0, 1000); |
textZSteps->setRange(0, 10); |
textZSteps->setSingleStep(0.1); |
textZSteps->setValue(0.5); |
connect(sliderZSpeed, SIGNAL(valueChanged(int)), textZSpeed, SLOT(setValue(int))); |
connect(textZSpeed, SIGNAL(valueChanged(int)), sliderZSpeed, SLOT(setValue(int))); |
sliderZSpeed->setRange(1, 1000); |
textZSpeed->setRange(1, 1000); |
textZSpeed->setSingleStep(100); |
textZSpeed->setValue(400); |
connect(sliderRepeatDelay, SIGNAL(valueChanged(int)), textRepeatDelay, SLOT(setValue(int))); |
connect(textRepeatDelay, SIGNAL(valueChanged(int)), sliderRepeatDelay, SLOT(setValue(int))); |
sliderRepeatDelay->setRange(1, 200); |
textRepeatDelay->setRange(1, 200); |
textRepeatDelay->setValue(45); |
QGridLayout *xyRepeatLayout = new QGridLayout(); |
xyRepeatLayout->addWidget(labelXYSteps, 0, 0); |
xyRepeatLayout->addWidget(sliderXYSteps, 0, 1); |
xyRepeatLayout->addWidget(textXYSteps, 0, 2); |
xyRepeatLayout->addWidget(labelXYSpeed, 1, 0); |
xyRepeatLayout->addWidget(sliderXYSpeed, 1, 1); |
xyRepeatLayout->addWidget(textXYSpeed, 1, 2); |
xyRepeatLayout->addWidget(labelZSteps, 2, 0); |
xyRepeatLayout->addWidget(sliderZSteps, 2, 1); |
xyRepeatLayout->addWidget(textZSteps, 2, 2); |
xyRepeatLayout->addWidget(labelZSpeed, 3, 0); |
xyRepeatLayout->addWidget(sliderZSpeed, 3, 1); |
xyRepeatLayout->addWidget(textZSpeed, 3, 2); |
xyRepeatLayout->addWidget(labelRepeatDelay, 4, 0); |
xyRepeatLayout->addWidget(sliderRepeatDelay, 4, 1); |
xyRepeatLayout->addWidget(textRepeatDelay, 4, 2); |
QGroupBox *xyRepeatBox = new QGroupBox("Movement Settings"); |
xyRepeatBox->setLayout(xyRepeatLayout); |
connect(sliderEForwardSteps, SIGNAL(valueChanged(int)), this, SLOT(QSliderToQDoubleSpinBox(int))); |
connect(textEForwardSteps, SIGNAL(valueChanged(double)), this, SLOT(QDoubleSpinBoxToQSlider(double))); |
sliderEForwardSteps->setRange(0, 10000); |
textEForwardSteps->setRange(0, 100); |
textEForwardSteps->setSingleStep(0.1); |
textEForwardSteps->setValue(8); |
connect(sliderEForwardSpeed, SIGNAL(valueChanged(int)), textEForwardSpeed, SLOT(setValue(int))); |
connect(textEForwardSpeed, SIGNAL(valueChanged(int)), sliderEForwardSpeed, SLOT(setValue(int))); |
sliderEForwardSpeed->setRange(1, 10000); |
textEForwardSpeed->setRange(1, 10000); |
textEForwardSpeed->setSingleStep(100); |
textEForwardSpeed->setValue(800); |
connect(sliderEBackwardSteps, SIGNAL(valueChanged(int)), this, SLOT(QSliderToQDoubleSpinBox(int))); |
connect(textEBackwardSteps, SIGNAL(valueChanged(double)), this, SLOT(QDoubleSpinBoxToQSlider(double))); |
sliderEBackwardSteps->setRange(0, 10000); |
textEBackwardSteps->setRange(0, 100); |
textEBackwardSteps->setSingleStep(0.1); |
textEBackwardSteps->setValue(2); |
connect(sliderEBackwardSpeed, SIGNAL(valueChanged(int)), textEBackwardSpeed, SLOT(setValue(int))); |
connect(textEBackwardSpeed, SIGNAL(valueChanged(int)), sliderEBackwardSpeed, SLOT(setValue(int))); |
sliderEBackwardSpeed->setRange(1, 10000); |
textEBackwardSpeed->setRange(1, 10000); |
textEBackwardSpeed->setSingleStep(100); |
textEBackwardSpeed->setValue(1600); |
connect(sliderExtrusionHeight, SIGNAL(valueChanged(int)), this, SLOT(QSliderToQDoubleSpinBox(int))); |
connect(textExtrusionHeight, SIGNAL(valueChanged(double)), this, SLOT(QDoubleSpinBoxToQSlider(double))); |
connect(textExtrusionHeight, SIGNAL(valueChanged(double)), this, SLOT(SetBaseHeight())); |
sliderExtrusionHeight->setRange(0, 400); |
textExtrusionHeight->setRange(0, 4); |
textExtrusionHeight->setSingleStep(0.1); |
textExtrusionHeight->setValue(2); |
connect(sliderEZSteps, SIGNAL(valueChanged(int)), this, SLOT(QSliderToQDoubleSpinBox(int))); |
connect(textEZSteps, SIGNAL(valueChanged(double)), this, SLOT(QDoubleSpinBoxToQSlider(double))); |
connect(textEZSteps, SIGNAL(valueChanged(double)), this, SLOT(SetBaseHeight())); |
sliderEZSteps->setRange(0, 1000); |
textEZSteps->setRange(0, 10); |
textEZSteps->setSingleStep(0.1); |
textEZSteps->setValue(2); |
QGridLayout *extruderLayout = new QGridLayout(); |
extruderLayout->addWidget(labelEForwardSteps, 0, 0); |
extruderLayout->addWidget(sliderEForwardSteps, 0, 1); |
extruderLayout->addWidget(textEForwardSteps, 0, 2); |
extruderLayout->addWidget(labelEForwardSpeed, 1, 0); |
extruderLayout->addWidget(sliderEForwardSpeed, 1, 1); |
extruderLayout->addWidget(textEForwardSpeed, 1, 2); |
extruderLayout->addWidget(labelEBackwardSteps, 2, 0); |
extruderLayout->addWidget(sliderEBackwardSteps, 2, 1); |
extruderLayout->addWidget(textEBackwardSteps, 2, 2); |
extruderLayout->addWidget(labelEBackwardSpeed, 4, 0); |
extruderLayout->addWidget(sliderEBackwardSpeed, 4, 1); |
extruderLayout->addWidget(textEBackwardSpeed, 4, 2); |
extruderLayout->addWidget(labelExtrusionHeight, 5, 0); |
extruderLayout->addWidget(sliderExtrusionHeight, 5, 1); |
extruderLayout->addWidget(textExtrusionHeight, 5, 2); |
extruderLayout->addWidget(labelEZSteps, 6, 0); |
extruderLayout->addWidget(sliderEZSteps, 6, 1); |
extruderLayout->addWidget(textEZSteps, 6, 2); |
QGroupBox *extruderBox = new QGroupBox("Extruder Settings"); |
extruderBox->setLayout(extruderLayout); |
QVBoxLayout *column1Layout = new QVBoxLayout(); |
column1Layout->addWidget(controlBox, 0, Qt::AlignTop); |
column1Layout->addWidget(miscBtnBox, 0, Qt::AlignTop); |
column1Layout->addWidget(helpBox, 1, Qt::AlignTop); |
QVBoxLayout *column2Layout = new QVBoxLayout(); |
column2Layout->addWidget(toolheadPosBox); |
column2Layout->addWidget(xyRepeatBox); |
column2Layout->addWidget(extruderBox); |
QHBoxLayout *mainLayout = new QHBoxLayout(); |
mainLayout->addLayout(column1Layout); |
mainLayout->addLayout(column2Layout); |
EnableTransmit(false); |
setLayout(mainLayout); |
setFixedSize(sizeHint()); |
} |
PasteController::~PasteController() |
{ |
} |
void PasteController::EnableTransmit(bool en) { |
connected = en; |
btnEnableHotkeys->setEnabled(en); |
btnInit->setEnabled(en); |
btnHome->setEnabled(en); |
btnForward->setEnabled(en); |
btnBackward->setEnabled(en); |
btnLeft->setEnabled(en); |
btnRight->setEnabled(en); |
btnDown->setEnabled(en); |
btnUp->setEnabled(en); |
btnExtrude->setEnabled(en); |
} |
void PasteController::InitializePrinter() { |
queueCmds->enqueue("G90\n"); // Absolute positioning |
queueCmds->enqueue("M83\n"); // Relative extrusion |
queueCmds->enqueue("M204 S3000"); // Default acceleration (movement) |
queueCmds->enqueue("M205 X10"); // Maximum XY jerk |
queueCmds->enqueue("M302"); // Allow cold extrusions |
if (!transmittingData) { |
transmittingData = true; |
emit TransmitData(queueCmds->head().toUtf8()); |
} |
ResetPosition(); |
SetBaseHeight(); |
} |
void PasteController::ToggleHotkeys() { |
if (hotkeysEnabled) { |
qApp->removeEventFilter(this); |
btnEnableHotkeys->setText("&Enable Hotkeys"); |
} else { |
qApp->installEventFilter(this); |
btnEnableHotkeys->setText("&Disable Hotkeys"); |
} |
hotkeysEnabled = !hotkeysEnabled; |
} |
void PasteController::MoveToolhead() { |
if (X_Incr && !X_Decr) |
xPos = (xPos + textXYSteps->value() < X_MAX) ? xPos + textXYSteps->value() : X_MAX; |
if (!X_Incr && X_Decr) |
xPos = (xPos - textXYSteps->value() > X_MIN) ? xPos - textXYSteps->value() : X_MIN; |
if (Y_Incr && !Y_Decr) |
yPos = (yPos + textXYSteps->value() < Y_MAX) ? yPos + textXYSteps->value() : Y_MAX; |
if (!Y_Incr && Y_Decr) |
yPos = (yPos - textXYSteps->value() > Y_MIN) ? yPos - textXYSteps->value() : Y_MIN; |
if (Z_Incr && !Z_Decr) |
zPos = (zPos + textZSteps->value() < Z_MAX) ? zPos + textZSteps->value() : Z_MAX; |
if (!Z_Incr && Z_Decr) |
zPos = (zPos - textZSteps->value() > Z_MIN) ? zPos - textZSteps->value() : Z_MIN; |
UpdatePosition(); |
QString str; |
QTextStream strIO(&str); |
if (Z_Incr || Z_Decr) { |
strIO << "G0"; |
strIO << " Z" << zPos; |
strIO << " F" << textZSpeed->value(); |
strIO << "\n"; |
} else { |
strIO << "G0"; |
strIO << " X" << xPos; |
strIO << " Y" << yPos; |
strIO << " F" << textXYSpeed->value(); |
strIO << "\n"; |
} |
queueCmds->enqueue(str); |
if (!transmittingData) { |
transmittingData = true; |
emit TransmitData(queueCmds->head().toUtf8()); |
} |
} |
void PasteController::MoveToolheadSingle() { |
if (QObject::sender() == btnRight) xPos += textXYSteps->value(); |
if (QObject::sender() == btnLeft) xPos -= textXYSteps->value(); |
if (QObject::sender() == btnForward) yPos += textXYSteps->value(); |
if (QObject::sender() == btnBackward) yPos -= textXYSteps->value(); |
if (QObject::sender() == btnUp) zPos += textZSteps->value(); |
if (QObject::sender() == btnDown) zPos -= textZSteps->value(); |
UpdatePosition(); |
QString str; |
QTextStream strIO(&str); |
if (QObject::sender() == btnRight || QObject::sender() == btnLeft || |
QObject::sender() == btnForward || QObject::sender() == btnBackward) { |
strIO << "G0"; |
strIO << " X" << xPos; |
strIO << " Y" << yPos; |
strIO << " F" << textXYSpeed->value(); |
strIO << "\n"; |
} else if (QObject::sender() == btnUp || QObject::sender() == btnDown) { |
strIO << "G0"; |
strIO << " Z" << zPos; |
strIO << " F" << textZSpeed->value(); |
strIO << "\n"; |
} |
queueCmds->enqueue(str); |
if (!transmittingData) { |
transmittingData = true; |
emit TransmitData(queueCmds->head().toUtf8()); |
} |
} |
void PasteController::UpdatePosition() { |
textXValue->setText(QString::number(xPos, 'f', 2)); |
textYValue->setText(QString::number(yPos, 'f', 2)); |
textZValue->setText(QString::number(zPos, 'f', 2)); |
} |
void PasteController::ExtrudeSingle() { |
QString str; |
// Move printdown down |
str = "G0 Z" + QString::number(textExtrusionHeight->value()) + |
" F" + QString::number(textZSpeed->value()) + "\n"; |
zPos = textExtrusionHeight->value(); |
queueCmds->enqueue(str); |
// Extrude paste |
str = "G0 E-" + QString::number(textEForwardSteps->value()) + |
" F" + QString::number(textEForwardSpeed->value()) + "\n"; |
queueCmds->enqueue(str); |
// Retract paste |
str = "G0 E" + QString::number(textEBackwardSteps->value()) + |
" F" + QString::number(textEBackwardSpeed->value()) + "\n"; |
queueCmds->enqueue(str); |
// Move printhead up |
str = "G0 Z" + QString::number(textEZSteps->value() + textExtrusionHeight->value()) + |
" F" + QString::number(textZSpeed->value()) + "\n"; |
zPos = textEZSteps->value() + textExtrusionHeight->value(); |
queueCmds->enqueue(str); |
if (!transmittingData) { |
transmittingData = true; |
emit TransmitData(queueCmds->head().toUtf8()); |
} |
} |
void PasteController::ResetPosition() { |
xPos = yPos = zPos = 0; |
queueCmds->enqueue("G28\n"); // Home printhead |
if (!transmittingData) { |
transmittingData = true; |
emit TransmitData(queueCmds->head().toUtf8()); |
} |
MoveToolhead(); |
} |
void PasteController::ProcessData(QByteArray data) { |
static QString recvData; |
if (transmittingData) { |
// Need to wait for acknowledgement from the printer after each command |
recvData.append(QString(data)); |
while (recvData.indexOf('\n') != -1) { |
QString ret = recvData.left(recvData.indexOf('\n')+1); |
recvData.remove(0, recvData.indexOf('\n')+1); |
bool transmit = false; |
if (ret.startsWith("ok")) { |
// Last command successfully processed |
queueCmds->dequeue(); |
transmit = true; |
} else if (ret.startsWith("rs" || ret.startsWith("Resend"))) { |
transmit = true; |
} else if (ret.startsWith("!!" || ret.startsWith("Error"))) { |
emit UpdateStatus("Hardware fault detected!"); |
queueCmds->clear(); |
} else if (ret.startsWith("echo")) { |
// Ignore anything else sent |
} |
if (transmit && !queueCmds->isEmpty()) { |
emit TransmitData(queueCmds->head().toUtf8()); |
} else if (queueCmds->isEmpty()){ |
transmittingData = false; |
} |
} |
} |
} |
void PasteController::SetBaseHeight() { |
if (connected) { |
QString str = "G0 Z" + QString::number(textEZSteps->value() + textExtrusionHeight->value()) + |
" F" + QString::number(textZSpeed->value()) + "\n"; |
zPos = textEZSteps->value() + textExtrusionHeight->value(); |
queueCmds->enqueue(str); |
if (!transmittingData) { |
transmittingData = true; |
emit TransmitData(queueCmds->head().toUtf8()); |
} |
UpdatePosition(); |
} |
} |
void PasteController::QSliderToQDoubleSpinBox(int) { |
textXYSteps->setValue((double)sliderXYSteps->value()/100); |
textZSteps->setValue((double)sliderZSteps->value()/100); |
textEZSteps->setValue((double)sliderEZSteps->value()/100); |
textEForwardSteps->setValue((double)sliderEForwardSteps->value()/100); |
textEBackwardSteps->setValue((double)sliderEBackwardSteps->value()/100); |
textExtrusionHeight->setValue((double)sliderExtrusionHeight->value()/100); |
} |
void PasteController::QDoubleSpinBoxToQSlider(double) { |
sliderXYSteps->setValue(textXYSteps->value()*100); |
sliderZSteps->setValue(textZSteps->value()*100); |
sliderEZSteps->setValue(textEZSteps->value()*100); |
sliderEForwardSteps->setValue((double)textEForwardSteps->value()*100); |
sliderEBackwardSteps->setValue((double)textEBackwardSteps->value()*100); |
sliderExtrusionHeight->setValue((double)textExtrusionHeight->value()*100); |
} |
bool PasteController::eventFilter(QObject *obj, QEvent *event) |
{ |
// Only process keyboard press and release events |
if (event->type() == QEvent::KeyPress) { |
QKeyEvent *keyevent = static_cast<QKeyEvent*>(event); |
// QKeySequence seq = keyevent->modifiers() + keyevent->key(); |
if (hotkeysEnabled) { |
if (keyevent->isAutoRepeat()) return true; |
bool keychange = false; |
if (keyevent->key() == Qt::Key_Left || keyevent->key() == Qt::Key_H) { |
btnLeft->setDown(true); |
X_Decr = keychange = true; |
} |
if (keyevent->key() == Qt::Key_Right || keyevent->key() == Qt::Key_L) { |
btnRight->setDown(true); |
X_Incr = keychange = true; |
} |
if (keyevent->key() == Qt::Key_Up || keyevent->key() == Qt::Key_K) { |
btnForward->setDown(true); |
Y_Incr = keychange = true; |
} |
if (keyevent->key() == Qt::Key_Down || keyevent->key() == Qt::Key_J) { |
btnBackward->setDown(true); |
Y_Decr = keychange = true; |
} |
if (keyevent->key() == Qt::Key_PageDown) { |
btnDown->setDown(true); |
Z_Decr = keychange = true; |
} |
if (keyevent->key() == Qt::Key_PageUp) { |
btnUp->setDown(true); |
Z_Incr = keychange = true; |
} |
if (keyevent->key() == Qt::Key_Space) { |
btnExtrude->setDown(true); |
E_Incr = keychange = true; |
} |
if (E_Incr) { |
ExtrudeSingle(); |
} else if (X_Incr || X_Decr || Y_Incr || Y_Decr || Z_Incr || Z_Decr) { |
MoveToolhead(); |
if (keyevent->modifiers() == Qt::ShiftModifier) { |
tmrUpdate->start(textRepeatDelay->value() * SLOW_MULTIPLIER); |
} else { |
tmrUpdate->start(textRepeatDelay->value()); |
} |
} |
if (keychange) return true; |
} |
} else if (event->type() == QEvent::KeyRelease) { |
QKeyEvent *keyevent = static_cast<QKeyEvent*>(event); |
// QKeySequence seq = keyevent->modifiers() + keyevent->key(); |
if (hotkeysEnabled) { |
if (keyevent->isAutoRepeat()) return true; |
bool keychange = false; |
if (keyevent->key() == Qt::Key_Left || keyevent->key() == Qt::Key_H) { |
btnLeft->setDown(false); |
X_Decr = keychange = false; |
} |
if (keyevent->key() == Qt::Key_Right || keyevent->key() == Qt::Key_L) { |
btnRight->setDown(false); |
X_Incr = keychange = false; |
} |
if (keyevent->key() == Qt::Key_Up || keyevent->key() == Qt::Key_K) { |
btnForward->setDown(false); |
Y_Incr = keychange = false; |
} |
if (keyevent->key() == Qt::Key_Down || keyevent->key() == Qt::Key_J) { |
btnBackward->setDown(false); |
Y_Decr = keychange = false; |
} |
if (keyevent->key() == Qt::Key_PageDown) { |
btnDown->setDown(false); |
Z_Decr = keychange = false; |
} |
if (keyevent->key() == Qt::Key_PageUp) { |
btnUp->setDown(false); |
Z_Incr = keychange = false; |
} |
if (keyevent->key() == Qt::Key_Space) { |
btnExtrude->setDown(false); |
E_Incr = keychange = false; |
} |
if (!X_Incr && !X_Decr && !Y_Incr && !Y_Decr && !Z_Incr && !Z_Decr) { |
tmrUpdate->stop(); |
} |
if (keychange) return true; |
} |
} |
return QWidget::eventFilter(obj, event); |
} |
//Misc Projects/PcMarlinInterface/PasteController.h |
---|
0,0 → 1,131 |
#ifndef PASTECONTROLLER_H |
#define PASTECONTROLLER_H |
#include "GlobalDefines.h" |
#define BTN_ICON_SIZE 32 |
#define X_MIN 0 |
#define X_MAX 290 |
#define Y_MIN 0 |
#define Y_MAX 270 |
#define Z_MIN 0 |
#define Z_MAX 240 |
#define SLOW_MULTIPLIER 4 |
class PasteController : public QWidget |
{ |
Q_OBJECT |
public: |
PasteController(QWidget *parent = 0); |
~PasteController(); |
signals: |
void EnableControls(void); |
void DisableControls(void); |
void TransmitData(QByteArray); |
void UpdateStatus(QString); |
public slots: |
void EnableTransmit(bool); |
void InitializePrinter(void); |
void ToggleHotkeys(void); |
void MoveToolhead(void); |
void MoveToolheadSingle(void); |
void UpdatePosition(void); |
void ExtrudeSingle(void); |
void ResetPosition(void); |
void ProcessData(QByteArray); |
void SetBaseHeight(void); |
void QSliderToQDoubleSpinBox(int); |
void QDoubleSpinBoxToQSlider(double); |
protected: |
bool eventFilter(QObject *, QEvent *); |
private: |
bool connected; |
bool hotkeysEnabled; |
double xPos,yPos,zPos; |
bool X_Incr, X_Decr, Y_Incr, Y_Decr, Z_Incr, Z_Decr, E_Incr; |
bool transmittingData; |
void IncrementToolhead(double x, double y, double z); |
void SingleExtrude(void); |
QQueue<QString> *queueCmds; |
QTimer *tmrUpdate; |
QLabel *labelHelp; |
QPushButton *btnEnableHotkeys; |
QPushButton *btnInit; |
QPushButton *btnHome; |
// Printer control buttons |
QToolButton *btnForward; |
QToolButton *btnBackward; |
QToolButton *btnLeft; |
QToolButton *btnRight; |
QToolButton *btnUp; |
QToolButton *btnDown; |
QToolButton *btnExtrude; |
// Toolhead position elements |
QLabel *labelXPos; |
QLineEdit *textXValue; |
QLabel *labelYPos; |
QLineEdit *textYValue; |
QLabel *labelZPos; |
QLineEdit *textZValue; |
// Movement setting elements |
QLabel *labelXYSteps; |
QSlider *sliderXYSteps; |
QDoubleSpinBox *textXYSteps; |
QLabel *labelXYSpeed; |
QSlider *sliderXYSpeed; |
QSpinBox *textXYSpeed; |
QLabel *labelZSteps; |
QSlider *sliderZSteps; |
QDoubleSpinBox *textZSteps; |
QLabel *labelZSpeed; |
QSlider *sliderZSpeed; |
QSpinBox *textZSpeed; |
QLabel *labelRepeatDelay; |
QSlider *sliderRepeatDelay; |
QSpinBox *textRepeatDelay; |
// Extruder setting elements |
QLabel *labelEForwardSteps; |
QSlider *sliderEForwardSteps; |
QDoubleSpinBox *textEForwardSteps; |
QLabel *labelEForwardSpeed; |
QSlider *sliderEForwardSpeed; |
QSpinBox *textEForwardSpeed; |
QLabel *labelEBackwardSteps; |
QSlider *sliderEBackwardSteps; |
QDoubleSpinBox *textEBackwardSteps; |
QLabel *labelEBackwardSpeed; |
QSlider *sliderEBackwardSpeed; |
QSpinBox *textEBackwardSpeed; |
QLabel *labelExtrusionHeight; |
QSlider *sliderExtrusionHeight; |
QDoubleSpinBox *textExtrusionHeight; |
QLabel *labelEZSteps; |
QSlider *sliderEZSteps; |
QDoubleSpinBox *textEZSteps; |
}; |
#endif // PASTECONTROLLER_H |
//Misc Projects/PcMarlinInterface/IOWidget.h |
---|
0,0 → 1,31 |
#ifndef IOWIDGET_H |
#define IOWIDGET_H |
#include "GlobalDefines.h" |
class IOWidget : public QWidget |
{ |
Q_OBJECT |
public: |
IOWidget(QWidget *parent = 0); |
~IOWidget(); |
public slots: |
void PreprocessTransmit(QByteArray data = QByteArray()); |
void ProcessReceivedByte(QByteArray data); |
void ClearBtn(void); |
void EnableTransmit(bool); |
signals: |
void TransmitByteArray(QByteArray data); |
private: |
QTextEdit *textData; |
QLineEdit *textTransmit; |
QPushButton *btnTransmit; |
QPushButton *btnClear; |
bool lastTransmit; |
}; |
#endif // IOWIDGET_H |
//Misc Projects/PcMarlinInterface/MacroWidget.h |
---|
0,0 → 1,62 |
#ifndef MACROWIDGET_H |
#define MACROWIDGET_H |
#include "GlobalDefines.h" |
#define MACRO_DEFAULT_COUNT 4 |
class MacroWidget : public QWidget |
{ |
Q_OBJECT |
public: |
MacroWidget(QWidget *parent = 0); |
~MacroWidget(); |
QSize sizeHint() const; |
public slots: |
// *public* slots |
void EnableTransmit(bool); |
// *private* slots |
void InitTransmit(QWidget* t); |
void KeybindPrompt(int id); |
void AddEntry(void); |
void RemoveEntry(void); |
void Clear(void); |
void WriteToFile(void); |
void ReadFromFile(void); |
signals: |
void TransmitText(QByteArray data); |
protected: |
bool eventFilter(QObject *, QEvent *); |
private: |
int count; |
bool connected; |
QString lastKnownFilePath; |
QPushButton *btnExport; |
QPushButton *btnImport; |
QPushButton *btnAddMacro; |
QPushButton *btnRemoveMacro; |
QPushButton *btnClear; |
QList<QLineEdit*> nameList; |
QList<QTextEdit*> valueList; |
QList<QPushButton*> btnSendList; |
QList<QPushButton*> btnKeyList; |
QList<QKeySequence> registeredKeySequences; |
QList<int> registeredKeyMacroIDs; |
QGridLayout *mainLayout; |
QHBoxLayout *ioLayout; |
QSignalMapper *sigmapTransmit; |
QSignalMapper *sigmapKeybind; |
QPair<QPushButton*,int> currKeyBindInfo; |
}; |
#endif // MACROWIDGET |
//Misc Projects/PcMarlinInterface/SerialHelper.cpp |
---|
0,0 → 1,179 |
#include "SerialHelper.h" |
SerialHelper::SerialHelper(QObject *parent) : QObject(parent) |
{ |
connected = false; |
speeds << "9600" << "19200" << "38400" << "57600" << "115200" << "230400" << "250000"; |
dataBits << "8 Bits" << "7 Bits" << "6 Bits" << "5 Bits"; |
stopBits << "1 Bit" << "1.5 Bits" << "2 Bits"; |
parity << "None" << "Even" << "Odd" << "Space" << "Mark"; |
flowControl << "None" << "Hardware" << "Software"; |
serialPort = NULL; |
} |
SerialHelper::~SerialHelper() |
{ |
if (serialPort != NULL && serialPort->isOpen()) |
serialPort->close(); |
delete serialPort; |
} |
void SerialHelper::QueryParameters() |
{ |
QList<QSerialPortInfo> portsList = QSerialPortInfo::availablePorts(); |
QStringList ports; |
for (int i = 0; i < portsList.size(); i++) { |
ports.append(portsList[i].portName()); |
} |
emit UpdateParameters(ports, speeds, dataBits, stopBits, parity, flowControl); |
} |
void SerialHelper::Connect(QString port, QString speed, QString dataBits, |
QString stopBits, QString parity, QString flowControl) |
{ |
if (!connected) { |
emit UpdateStatus("Connecting to " + port); |
serialPort = new QSerialPort(); |
connect(serialPort, SIGNAL(readyRead()), this, SLOT(ProcessIncomingData())); |
connect(serialPort, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(ProcessError(QSerialPort::SerialPortError))); |
serialPort->setPortName(port); |
if (serialPort->open(QIODevice::ReadWrite)) { |
connected = true; |
bool ok = false; |
int baud = speed.toInt(&ok); |
if (ok) serialPort->setBaudRate(baud); |
if (dataBits == "5 Bits") |
serialPort->setDataBits(QSerialPort::Data5); |
else if (dataBits == "6 Bits") |
serialPort->setDataBits(QSerialPort::Data6); |
else if (dataBits == "7 Bits") |
serialPort->setDataBits(QSerialPort::Data7); |
else |
serialPort->setDataBits(QSerialPort::Data8); |
if (stopBits == "1.5 Bits") |
serialPort->setStopBits(QSerialPort::OneAndHalfStop); |
else if (stopBits == "2 Bits") |
serialPort->setStopBits(QSerialPort::TwoStop); |
else |
serialPort->setStopBits(QSerialPort::OneStop); |
if (parity == "Even") |
serialPort->setParity(QSerialPort::EvenParity); |
else if (parity == "Odd") |
serialPort->setParity(QSerialPort::OddParity); |
else if (parity == "Space") |
serialPort->setParity(QSerialPort::SpaceParity); |
else if (parity == "Mark") |
serialPort->setParity(QSerialPort::MarkParity); |
else |
serialPort->setParity(QSerialPort::NoParity); |
if (flowControl == "Hardware") |
serialPort->setFlowControl(QSerialPort::HardwareControl); |
else if (flowControl == "Software") |
serialPort->setFlowControl(QSerialPort::SoftwareControl); |
else |
serialPort->setFlowControl(QSerialPort::NoFlowControl); |
// See http://umforum.ultimaker.com/index.php?/topic/5886-um2-controller-resetreboot-when-opening-usb-port-on-linux/ |
serialPort->setDataTerminalReady(1); |
if (ok) { |
QString status = "Connected (%1 @ %2 D: %3 S: %4 P: %5 FC: %6)"; |
emit UpdateStatus(status.arg(port).arg(speed).arg(dataBits).arg(stopBits).arg(parity).arg(flowControl)); |
emit Connected(true); |
} else |
Disconnect(); |
} |
} |
} |
void SerialHelper::Disconnect(bool errored) |
{ |
serialPort->disconnect(); |
serialPort->close(); |
delete serialPort; |
connected = false; |
if (!errored) |
emit UpdateStatus("Disconnected"); |
emit Connected(false); |
} |
void SerialHelper::TransmitString(QString string) |
{ |
serialPort->write(string.toStdString().c_str()); |
serialPort->write(SERIAL_NEWLINE_CHAR); |
} |
void SerialHelper::TransmitByteArray(QByteArray data) |
{ |
serialPort->write(data); |
} |
void SerialHelper::ProcessIncomingData() |
{ |
char tmpBuffer[SERIAL_BUFFER_SIZE]; |
int len = serialPort->read(tmpBuffer, sizeof(tmpBuffer)); |
while (len > 0) { |
QByteArray data(tmpBuffer, len); |
emit ReceivedByte(data); |
// Check if there is more data to be read from the serial port |
len = serialPort->read(tmpBuffer, sizeof(tmpBuffer)); |
} |
} |
void SerialHelper::ProcessError(QSerialPort::SerialPortError error) |
{ |
if (error == QSerialPort::NoError) return; |
switch(error) { |
case QSerialPort::DeviceNotFoundError: |
emit UpdateStatus("(Error) Device not found"); |
return; |
case QSerialPort::PermissionError: |
emit UpdateStatus("(Error) Device already opened or lacking permission"); |
return; |
case QSerialPort::OpenError: |
emit UpdateStatus("(Error) Device already opened"); |
return; |
case QSerialPort::NotOpenError: |
emit UpdateStatus("(Error) Device not opened"); |
return; |
case QSerialPort::ParityError: |
emit UpdateStatus("(Error) Parity error detected"); |
break; |
case QSerialPort::FramingError: |
emit UpdateStatus("(Error) Framing error detected"); |
break; |
case QSerialPort::BreakConditionError: |
emit UpdateStatus("(Error) Break condition detected"); |
break; |
case QSerialPort::WriteError: |
emit UpdateStatus("(Error) Unable to write to device"); |
break; |
case QSerialPort::ReadError: |
emit UpdateStatus("(Error) Unable to read from device"); |
break; |
case QSerialPort::ResourceError: |
emit UpdateStatus("(Error) Device missing or disconnected"); |
break; |
case QSerialPort::UnsupportedOperationError: |
emit UpdateStatus("(Error) Operation not supported or prohibited"); |
break; |
case QSerialPort::TimeoutError: |
emit UpdateStatus("(Error) Connection timeout"); |
break; |
case QSerialPort::UnknownError: |
emit UpdateStatus("(Error) Unknown error"); |
break; |
default: |
break; |
} |
serialPort->clearError(); |
Disconnect(true); |
} |
//Misc Projects/PcMarlinInterface/SerialHelper.h |
---|
0,0 → 1,54 |
#ifndef SERIALHELPER_H |
#define SERIALHELPER_H |
#include "GlobalDefines.h" |
#include <QtSerialPort> |
#define SERIAL_NEWLINE_CHAR "\n" |
#define SERIAL_BUFFER_SIZE 32 |
class SerialHelper : public QObject |
{ |
Q_OBJECT |
public: |
SerialHelper(QObject *parent = 0); |
~SerialHelper(); |
bool connected; |
public slots: |
// Inbound from SerialController |
void QueryParameters(void); |
void Connect(QString port, QString speed, QString dataBits, |
QString stopBits, QString parity, QString flowControl); |
void Disconnect(bool errored = false); |
void TransmitString(QString string); |
void TransmitByteArray(QByteArray data); |
// Local processing of received data |
void ProcessIncomingData(void); |
void ProcessError(QSerialPort::SerialPortError error); |
signals: |
// Outbound to SerialController |
void UpdateParameters(QStringList ports, QStringList speeds, QStringList dataBits, |
QStringList stopBits, QStringList parity, QStringList flowControl); |
void ReceivedByte(QByteArray); |
void Connected(bool); |
void UpdateStatus(QString string); |
private: |
QSerialPort *serialPort; |
QStringList speeds; |
QStringList dataBits; |
QStringList stopBits; |
QStringList parity; |
QStringList flowControl; |
char bufferIn[SERIAL_BUFFER_SIZE]; |
int bufferInIndex; |
bool bufferInOverflow; |
QString currString; |
}; |
#endif // SERIALHELPER_H |
//Misc Projects/PcMarlinInterface/SerialWidget.cpp |
---|
0,0 → 1,200 |
#include "SerialWidget.h" |
SerialWidget::SerialWidget(QWidget *parent) : QWidget(parent) |
{ |
// Serial connection UI |
btnConnect = new QPushButton("&Connect"); |
btnRefresh = new QPushButton("&Refresh"); |
labelPort = new QLabel("Serial Port:"); |
labelSpeed = new QLabel("Baud Rate:"); |
labelDataBits = new QLabel("Data:"); |
labelStopBits = new QLabel("Stop:"); |
labelParity = new QLabel("Parity Bit:"); |
labelFlowControl = new QLabel("Flow Control:"); |
cboxPort = new QComboBox(); |
cboxPort->setMinimumWidth(80); |
cboxSpeed = new QComboBox(); |
cboxSpeed->setEditable(true); |
cboxSpeed->setValidator(new QIntValidator(0, 100000000, this)); |
cboxDataBits = new QComboBox(); |
cboxDataBits->setMaximumWidth(60); |
cboxStopBits = new QComboBox(); |
cboxStopBits->setMaximumWidth(60); |
cboxParity = new QComboBox(); |
cboxFlowControl = new QComboBox(); |
cboxFlowControl->setMinimumWidth(70); |
QGridLayout *serialSettingsLayout = new QGridLayout(); |
serialSettingsLayout->addWidget(btnConnect, 0, 0); |
serialSettingsLayout->addWidget(labelPort, 0, 1); |
serialSettingsLayout->addWidget(cboxPort, 0, 2); |
serialSettingsLayout->addWidget(labelDataBits, 0, 3); |
serialSettingsLayout->addWidget(cboxDataBits, 0, 4); |
serialSettingsLayout->addWidget(labelParity, 0, 5); |
serialSettingsLayout->addWidget(cboxParity, 0, 6); |
serialSettingsLayout->addWidget(btnRefresh, 1, 0); |
serialSettingsLayout->addWidget(labelSpeed, 1, 1); |
serialSettingsLayout->addWidget(cboxSpeed, 1, 2); |
serialSettingsLayout->addWidget(labelStopBits, 1, 3); |
serialSettingsLayout->addWidget(cboxStopBits, 1, 4); |
serialSettingsLayout->addWidget(labelFlowControl, 1, 5); |
serialSettingsLayout->addWidget(cboxFlowControl, 1, 6); |
setLayout(serialSettingsLayout); |
serialHelper = new SerialHelper(); |
serialThread = new QThread(); |
serialHelper->moveToThread(serialThread); |
connect(serialHelper, SIGNAL(UpdateStatus(QString)), this, SIGNAL(UpdateStatus(QString))); |
connect(this, SIGNAL(QueryParameters()), serialHelper, SLOT(QueryParameters())); |
connect(serialHelper, SIGNAL(UpdateParameters(QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)), |
this, SLOT(UpdateParameters(QStringList,QStringList,QStringList,QStringList,QStringList,QStringList))); |
connect(this, SIGNAL(Connect(QString,QString,QString,QString,QString,QString)), |
serialHelper, SLOT(Connect(QString,QString,QString,QString,QString,QString))); |
connect(serialHelper, SIGNAL(Connected(bool)), this, SIGNAL(Connected(bool))); |
connect(serialHelper, SIGNAL(Connected(bool)), this, SLOT(LocalConnected(bool))); |
connect(this, SIGNAL(Disconnect()), serialHelper, SLOT(Disconnect())); |
connect(this, SIGNAL(TransmitByteArray(QByteArray)), serialHelper, SLOT(TransmitByteArray(QByteArray))); |
connect(serialHelper, SIGNAL(ReceivedByte(QByteArray)), this, SIGNAL(ReceivedByte(QByteArray))); |
connect(serialThread, SIGNAL(finished()), serialHelper, SLOT(deleteLater())); |
serialThread->start(); |
connect(btnConnect, SIGNAL(clicked()), this, SLOT(ConnectToggleBtn())); |
connect(btnRefresh, SIGNAL(clicked()), this, SIGNAL(QueryParameters())); |
emit QueryParameters(); |
LocalConnected(false); |
} |
SerialWidget::~SerialWidget() |
{ |
serialThread->quit(); |
} |
void SerialWidget::UpdateParameters(QStringList ports, QStringList speeds, QStringList dataBits, |
QStringList stopBits, QStringList parity, QStringList flowControl) |
{ |
QString currPort = cboxPort->currentText(); |
cboxPort->clear(); |
cboxPort->addItems(ports); |
if (currPort != "" && ports.contains(currPort)) |
cboxPort->setCurrentText(currPort); |
QString currSpeed = cboxSpeed->currentText(); |
cboxSpeed->clear(); |
cboxSpeed->addItems(speeds); |
if (currSpeed != "") cboxSpeed->setCurrentText(currSpeed); |
int currData = cboxDataBits->currentIndex(); |
cboxDataBits->clear(); |
cboxDataBits->addItems(dataBits); |
if (currData >= 0) cboxDataBits->setCurrentIndex(currData); |
int currStop = cboxStopBits->currentIndex(); |
cboxStopBits->clear(); |
cboxStopBits->addItems(stopBits); |
if (currStop >= 0) cboxStopBits->setCurrentIndex(currStop); |
int currParity = cboxParity->currentIndex(); |
cboxParity->clear(); |
cboxParity->addItems(parity); |
if (currParity >= 0) cboxParity->setCurrentIndex(currParity); |
int currFlow = cboxFlowControl->currentIndex(); |
cboxFlowControl->clear(); |
cboxFlowControl->addItems(flowControl); |
if (currFlow >= 0) cboxFlowControl->setCurrentIndex(currFlow); |
} |
void SerialWidget::LocalConnected(bool connected) |
{ |
if (connected) { |
btnConnect->setText("&Disconnect"); |
btnRefresh->hide(); |
labelPort->hide(); |
labelSpeed->hide(); |
labelDataBits->hide(); |
labelStopBits->hide(); |
labelParity->hide(); |
labelFlowControl->hide(); |
cboxPort->hide(); |
cboxSpeed->hide(); |
cboxDataBits->hide(); |
cboxStopBits->hide(); |
cboxParity->hide(); |
cboxFlowControl->hide(); |
} else { |
btnConnect->setText("&Connect"); |
btnRefresh->show(); |
labelPort->show(); |
labelSpeed->show(); |
labelDataBits->show(); |
labelStopBits->show(); |
labelParity->show(); |
labelFlowControl->show(); |
cboxPort->show(); |
cboxSpeed->show(); |
cboxDataBits->show(); |
cboxStopBits->show(); |
cboxParity->show(); |
cboxFlowControl->show(); |
} |
} |
void SerialWidget::ConnectToggleBtn() |
{ |
if (serialHelper->connected) { |
emit Disconnect(); |
} else { |
if (cboxPort->currentText() != "" && cboxSpeed->currentText() != "") { |
emit Connect(cboxPort->currentText(), cboxSpeed->currentText(), cboxDataBits->currentText(), |
cboxStopBits->currentText(), cboxParity->currentText(), cboxFlowControl->currentText()); |
} |
} |
} |
//void SerialController::Serial_ProcessIncomingData() |
//{ |
// char tmpBuffer[SERIAL_BUFFER_SIZE]; |
// int len = serialPort->read(tmpBuffer, sizeof(tmpBuffer)); |
// while (len > 0) { |
// for (int i = 0; i < len; i++) { |
// // Save received data into local buffer |
// bufferIn[bufferInIndex] = tmpBuffer[i]; |
// // If newline char is received, end current string |
// if (tmpBuffer[i] == '\n') { |
// if (bufferInOverflow) |
// currString.append(QString::fromLocal8Bit(bufferIn, bufferInIndex)); |
// else |
// currString = QString::fromLocal8Bit(bufferIn, bufferInIndex); |
// bufferInOverflow = false; |
// bufferInIndex = 0; |
// emit Serial_ReceivedString(currString); |
// } else { |
// bufferInIndex++; |
// } |
// // If received string is larger than our serial buffer, append to previous data |
// if (bufferInIndex == SERIAL_BUFFER_SIZE-1) { |
// bufferIn[SERIAL_BUFFER_SIZE-1] = 0x0; |
// if (bufferInOverflow) |
// currString.append(QString::fromLocal8Bit(bufferIn, bufferInIndex)); |
// else |
// currString = QString::fromLocal8Bit(bufferIn, bufferInIndex); |
// bufferInOverflow = true; |
// bufferInIndex = 0; |
// } |
// } |
// // Check if there is more data to be read from the serial port |
// len = serialPort->read(tmpBuffer, sizeof(tmpBuffer)); |
// } |
//} |
//Misc Projects/PcMarlinInterface/SerialWidget.h |
---|
0,0 → 1,56 |
#ifndef SERIALWIDGET_H |
#define SERIALWIDGET_H |
#include "GlobalDefines.h" |
#include "SerialHelper.h" |
class SerialWidget : public QWidget |
{ |
Q_OBJECT |
public: |
SerialWidget(QWidget *parent = 0); |
~SerialWidget(); |
public slots: |
// Inbound from SerialHelper |
void UpdateParameters(QStringList ports, QStringList speeds, QStringList dataBits, |
QStringList stopBits, QStringList parity, QStringList flowControl); |
// Local GUI processing |
void ConnectToggleBtn(void); |
void LocalConnected(bool); |
signals: |
// Outbound to SerialHelper |
void QueryParameters(void); |
void Connect(QString port, QString speed, QString dataBits, |
QString stopBits, QString parity, QString flowControl); |
void Disconnect(void); |
void TransmitByteArray(QByteArray data); |
// Outbound to MainWindow |
void ReceivedByte(QByteArray data); |
void Connected(bool); |
void UpdateStatus(QString string); |
private: |
SerialHelper *serialHelper; |
QThread *serialThread; |
QPushButton *btnConnect; |
QPushButton *btnRefresh; |
QLabel *labelPort; |
QLabel *labelSpeed; |
QLabel *labelDataBits; |
QLabel *labelStopBits; |
QLabel *labelParity; |
QLabel *labelFlowControl; |
QComboBox *cboxPort; |
QComboBox *cboxSpeed; |
QComboBox *cboxDataBits; |
QComboBox *cboxStopBits; |
QComboBox *cboxParity; |
QComboBox *cboxFlowControl; |
}; |
#endif // SERIALWIDGET_H |
//Misc Projects/PcMarlinInterface/Resources/arrow_down.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/arrow_down.png |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources/arrow_left.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/arrow_left.png |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources/arrow_right.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/arrow_right.png |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources/arrow_up.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/arrow_up.png |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources/close.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/close.png |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources/download.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/download.png |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources/upload.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/upload.png |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources/Icon.ico |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/Icon.ico |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources/Icon_16.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/Icon_16.bmp |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources/Icon_32.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/Icon_32.bmp |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources/Icon_64.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
//Misc Projects/PcMarlinInterface/Resources/Icon_64.bmp |
---|
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//Misc Projects/PcMarlinInterface/Resources.qrc |
---|
0,0 → 1,14 |
<RCC> |
<qresource prefix="/External"> |
<file>Resources/Icon_16.bmp</file> |
<file>Resources/Icon_32.bmp</file> |
<file>Resources/Icon_64.bmp</file> |
<file>Resources/arrow_down.png</file> |
<file>Resources/arrow_up.png</file> |
<file>Resources/arrow_left.png</file> |
<file>Resources/arrow_right.png</file> |
<file>Resources/close.png</file> |
<file>Resources/download.png</file> |
<file>Resources/upload.png</file> |
</qresource> |
</RCC> |
//Misc Projects/PcMarlinInterface/Icon.rc |
---|
0,0 → 1,0 |
IDI_ICON1 ICON DISCARDABLE "Resources\Icon.ico" |
//Misc Projects/PcMarlinInterface/main.cpp |
---|
0,0 → 1,11 |
#include "MainWindow.h" |
#include <QApplication> |
int main(int argc, char *argv[]) |
{ |
QApplication a(argc, argv); |
MainWindow w; |
w.show(); |
return a.exec(); |
} |