- TAG [uartscopeclean] eingefügt, über den alle Logs gelöscht werden

- Pauseknopf und Eingabezeile hinzugefügt, um Kommandos an den Pi zu schicken
This commit is contained in:
2026-09-07 14:53:54 +02:00
parent ef335f2d9e
commit 934f32a3bd
14 changed files with 763 additions and 347 deletions

View File

@@ -19,6 +19,7 @@
#include "tagwidget.h"
#include "videowidget.h"
#include "connectdialog.h"
#include "sendbar.h"
class MainWindow : public QMainWindow
{
@@ -64,6 +65,7 @@ private:
TableView *m_tableView = nullptr;
TagWidget *m_tagWidget = nullptr;
VideoWidget *m_videoWidget= nullptr;
SendBar *m_sendBar = nullptr;
QLabel *m_portLabel = nullptr;
QLabel *m_stateLabel = nullptr;

78
include/sendbar.h Normal file
View File

@@ -0,0 +1,78 @@
#pragma once
#include <QWidget>
#include <QPushButton>
#include <QLineEdit>
#include <QComboBox>
#include <QString>
#include <QByteArray>
#include <QPoint>
// SendBar sits below the Raw/Table view and the HDMI preview and lets the
// user talk BACK to the firmware over UART/TCP, for debugging:
//
// [ Pause ] [ ...free-text input...................... ] [Senden] [ending v]
//
// - The left button sends a fixed, user-configurable byte sequence (right-
// click it to change the label and the code - e.g. a single control byte
// or a short command string). Handy for a "pause"/"step" command that's
// sent identically every time.
// - The input line sends whatever is typed the moment Enter is pressed
// (or the "Senden" button is clicked), with a selectable line ending
// appended.
//
// SendBar itself never touches the serial device - it only emits
// sendRequested() with the raw bytes to write; MainWindow forwards those to
// SerialWorker::writeData().
class SendBar : public QWidget
{
Q_OBJECT
public:
explicit SendBar(QWidget *parent = nullptr);
// Persisted configuration accessors, used by MainWindow::save/restoreSettings.
QString buttonLabel() const { return m_buttonLabel; }
QString buttonCode() const { return m_buttonCode; } // raw, as typed (with escapes)
int lineEndingIndex() const;
void setButtonLabel(const QString &label);
void setButtonCode(const QString &code);
void setLineEndingIndex(int index);
// Turns C-style escapes (\n \r \t \0 \\ and \xHH) in `text` into the
// actual bytes they represent. Exposed as static so it can be reused/
// unit-tested independently of the widget.
static QByteArray unescape(const QString &text);
public slots:
// Enables/disables the send controls - there is no point letting the
// user try to send anything while nothing is connected.
void setConnected(bool connected);
signals:
// Raw bytes ready to be written to the serial/network device.
void sendRequested(const QByteArray &data);
// The button label/code or the line-ending choice changed - MainWindow
// listens to this to persist it immediately, consistent with how the
// Tag filter and Screenshot folder dialogs already behave.
void configChanged();
private slots:
void onPauseClicked();
void onPauseContextMenu(const QPoint &pos);
void onSendClicked();
void configureButton();
private:
void setupUi();
void updatePauseButtonUi();
void sendInputLine();
QPushButton *m_pauseBtn = nullptr;
QLineEdit *m_inputEdit = nullptr;
QPushButton *m_sendBtn = nullptr;
QComboBox *m_endingCombo = nullptr;
QString m_buttonLabel = tr("Pause");
QString m_buttonCode = QStringLiteral("PAUSE\\n");
};

View File

@@ -7,6 +7,7 @@
#include <QFile>
#include <QTextStream>
#include <QString>
#include <QByteArray>
#include <QTimer>
// SerialWorker lives in its own QThread and owns the actual data source,
@@ -44,6 +45,10 @@ public slots:
void closePort();
void setLogFile(const QString &path);
void stopLogging();
// Writes raw bytes back out to the currently open device (serial port
// or TCP socket) - used by the send bar (Pause button / input line) to
// talk back to the firmware. No-op if nothing is currently open.
void writeData(const QByteArray &data);
signals:
void newLine(const QString &line);
@@ -53,6 +58,12 @@ signals:
// history too). `filename` is whatever followed the tag, verbatim -
// the receiver is responsible for sanitizing/defaulting it.
void screenshotRequested(const QString &filename);
// Fired specifically for a [UARTSCOPECLEAR] control tag (in addition to
// the normal tagDetected() above): the firmware asks for a completely
// fresh UARTScope state, e.g. right at boot. Handled the same as an
// ANSI clear-screen - wipes Raw view, Table view, Tag Monitor and the
// video preview frame.
void uartscopeClearRequested();
void clearScreen();
void portOpened();
void portClosed();