From bd3deb2b7fa413abc485b33bcfb1b79f2591c8d9 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Sun, 18 Oct 2020 15:44:18 +0200 Subject: [PATCH] implemented scroll direction --- LedDisplayController/leddisplaybackend.cpp | 4 +++- LedDisplayController/leddisplaytextmodel.cpp | 5 ++++- LedDisplayController/leddisplaytextmodel.h | 5 ++++- .../ressources/qml/TextEditDialog.qml | 15 +++++++++++++-- .../include/LedDisplayController.h | 4 +++- .../src/LedDisplayController.cpp | 6 ++++++ .../src/OmobiLedDisplay.cpp | 4 ++++ 7 files changed, 37 insertions(+), 6 deletions(-) diff --git a/LedDisplayController/leddisplaybackend.cpp b/LedDisplayController/leddisplaybackend.cpp index 6386573..f00085c 100644 --- a/LedDisplayController/leddisplaybackend.cpp +++ b/LedDisplayController/leddisplaybackend.cpp @@ -157,7 +157,7 @@ void LedDisplayBackend::sendBluetoothKeepAlive() { } void LedDisplayBackend::handleBluetoothDataReceived(QString s){ - //qDebug() << "New data: \n" << qPrintable(s); + qDebug() << "New data: \n" << qPrintable(s); QJsonParseError parseError; QJsonDocument doc = QJsonDocument::fromJson(s.toUtf8(), &parseError); @@ -199,6 +199,8 @@ void LedDisplayBackend::handleBluetoothDataReceived(QString s){ this->displayTextModel->maximumTextLength = data["maximumTextLength"].toInt(); this->displayTextModel->maximumTextSets = data["maximumTextSets"].toInt(); + qDebug() << "text sets are: " << this->textSetsBuffer; + this->displayTextModel->setTexts(this->textSetsBuffer); this->textSetsBuffer.clear(); diff --git a/LedDisplayController/leddisplaytextmodel.cpp b/LedDisplayController/leddisplaytextmodel.cpp index 7a7d138..a5a13f9 100644 --- a/LedDisplayController/leddisplaytextmodel.cpp +++ b/LedDisplayController/leddisplaytextmodel.cpp @@ -42,6 +42,7 @@ QHash LedDisplayTextModel::roleNames() const { ColorRole, "color" }, { AlignmentRole, "alignment" }, { ScrollRole, "scroll" }, + { ScrollDirectionRole, "scrollDirection" }, { ScrollSpeedRole, "scrollSpeed" }, { ScrollCountRole, "scrollCount" }, { IndexRole, "index" } @@ -54,8 +55,9 @@ void LedDisplayTextModel::append( bool active, unsigned int runtime, QString color, - QString alignment, + unsigned int alignment, bool scroll, + unsigned int scrollDirection, unsigned int scrollSpeed, unsigned int scrollCount ) { @@ -74,6 +76,7 @@ void LedDisplayTextModel::append( { ColorRole, color }, { AlignmentRole, alignment }, { ScrollRole, scroll }, + { ScrollDirectionRole, scrollDirection}, { ScrollSpeedRole, scrollSpeed }, { ScrollCountRole, scrollCount } }; diff --git a/LedDisplayController/leddisplaytextmodel.h b/LedDisplayController/leddisplaytextmodel.h index c13e905..97db764 100644 --- a/LedDisplayController/leddisplaytextmodel.h +++ b/LedDisplayController/leddisplaytextmodel.h @@ -22,6 +22,7 @@ public: ColorRole, AlignmentRole, ScrollRole, + ScrollDirectionRole, ScrollSpeedRole, ScrollCountRole, IndexRole, @@ -46,8 +47,9 @@ public: bool active, unsigned int runtime, QString color, - QString alignment, + unsigned int alignment, bool scroll, + unsigned int scrollDirection, unsigned int scrollSpeed, unsigned int scrollCount ); @@ -81,6 +83,7 @@ private: {ColorRole, QVariant::String}, {AlignmentRole, QVariant::Int}, {ScrollRole, QVariant::Bool}, + {ScrollDirectionRole, QVariant::Int}, {ScrollSpeedRole, QVariant::Int}, {ScrollCountRole, QVariant::Int}, {IndexRole, QVariant::Int} diff --git a/LedDisplayController/ressources/qml/TextEditDialog.qml b/LedDisplayController/ressources/qml/TextEditDialog.qml index 11c9a4e..54dc6bb 100644 --- a/LedDisplayController/ressources/qml/TextEditDialog.qml +++ b/LedDisplayController/ressources/qml/TextEditDialog.qml @@ -31,6 +31,7 @@ Dialog { editingModel.color = colorColorPicker.value editingModel.alignment = alignmentComboBox.currentIndex editingModel.scroll = scrollSwitch.checked + editingModel.scrollDirection = scrollDirectionComboBox.currentIndex editingModel.scrollSpeed = scrollSpeedSpinBox.value editingModel.scrollCount = scrollCountSpinBox.value } @@ -39,8 +40,9 @@ Dialog { activeSwitch.checked, runtimeSpinBox.value, colorColorPicker.value, - alignmentComboBox.currentText, + alignmentComboBox.currentIndex, scrollSwitch.checked, + scrollDirectionComboBox.currentIndex, scrollSpeedSpinBox.value, scrollCountSpinBox.value ) @@ -97,7 +99,7 @@ Dialog { ComboBoxDelegate { id: alignmentComboBox Layout.fillWidth: true - model: ["left", "center", "right"] + model: [qsTr("left"), qsTr("center"), qsTr("right")] text: qsTr("Alignment") } @@ -107,6 +109,13 @@ Dialog { text: qsTr("Scroll") } + ComboBoxDelegate { + id: scrollDirectionComboBox + Layout.fillWidth: true + model: [qsTr("right to left"), qsTr("left to right")] + text: qsTr("Scroll direction") + } + SpinBoxDelegate { id: scrollSpeedSpinBox Layout.fillWidth: true @@ -166,6 +175,7 @@ Dialog { colorColorPicker.value = editingModel.color alignmentComboBox.currentIndex = editingModel.alignment scrollSwitch.checked = editingModel.scroll + scrollDirectionComboBox.currentIndex = editingModel.scrollDirection scrollSpeedSpinBox.value = editingModel.scrollSpeed scrollCountSpinBox.value = editingModel.scrollCount @@ -186,6 +196,7 @@ Dialog { colorColorPicker.value = "#ffffff" alignmentComboBox.currentIndex = 0 scrollSwitch.checked = false + scrollDirectionComboBox.currentIndex = 0 scrollSpeedSpinBox.value = 5 scrollCountSpinBox.value = 1 } diff --git a/vscode/OmobiLEDdisplayBluetooth/include/LedDisplayController.h b/vscode/OmobiLEDdisplayBluetooth/include/LedDisplayController.h index 899932c..fb595e8 100644 --- a/vscode/OmobiLEDdisplayBluetooth/include/LedDisplayController.h +++ b/vscode/OmobiLEDdisplayBluetooth/include/LedDisplayController.h @@ -59,6 +59,7 @@ public: ColorParameter, AlignmentParameter, ScrollParameter, + ScrollDirectionParameter, ScrollSpeedParameter, ScrollCountParameter, IndexParameter, @@ -125,6 +126,7 @@ private: char color[7]; text_align_t alignment; bool scroll; + int scrollDirection; int scrollSpeed; /*!< Between 0 and 10 */ uint16_t scrollCount; } text_set_t; @@ -137,7 +139,7 @@ private: } sets_t; // storage variables - const text_set_t defaultTextSet {"", false, 0, "", AlignCenter, false, 0, 0}; + const text_set_t defaultTextSet {"", false, 0, "", AlignCenter, false, 0, 0, 0}; sets_t text_sets; // storage control diff --git a/vscode/OmobiLEDdisplayBluetooth/src/LedDisplayController.cpp b/vscode/OmobiLEDdisplayBluetooth/src/LedDisplayController.cpp index ec13925..3272902 100644 --- a/vscode/OmobiLEDdisplayBluetooth/src/LedDisplayController.cpp +++ b/vscode/OmobiLEDdisplayBluetooth/src/LedDisplayController.cpp @@ -291,6 +291,12 @@ LedDisplayController::GetSetTextSetParameterExitCode LedDisplayController::getSe returnValue = currentTextSet->scroll ? "true" : "false"; break; + case ScrollDirectionParameter: + if(set) + currentTextSet->scrollDirection = value->toInt(); + else + returnValue = currentTextSet->scrollDirection; + break; case ScrollSpeedParameter: if (set) { diff --git a/vscode/OmobiLEDdisplayBluetooth/src/OmobiLedDisplay.cpp b/vscode/OmobiLEDdisplayBluetooth/src/OmobiLedDisplay.cpp index b479497..1017ec8 100644 --- a/vscode/OmobiLEDdisplayBluetooth/src/OmobiLedDisplay.cpp +++ b/vscode/OmobiLEDdisplayBluetooth/src/OmobiLedDisplay.cpp @@ -110,6 +110,10 @@ void OmobiLedDisplay::onDataReceived(String dataString) textSetIndex, LedDisplayController::DisplayTextSetParameter(textSetParameter)); + Serial.println("sending parameter: " + String(textSetParameter) + " with value: " + this->ledDisplayController->getTextSetParameter( + textSetIndex, + LedDisplayController::DisplayTextSetParameter(textSetParameter))); + String json; serializeJson(doc, json); this->bleServer->sendData(json);