implemented scroll direction

This commit is contained in:
Dorian Zedler 2020-10-18 15:44:18 +02:00
parent 1b28fe84b8
commit bd3deb2b7f
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37
7 changed files with 37 additions and 6 deletions

View file

@ -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();

View file

@ -42,6 +42,7 @@ QHash<int, QByteArray> 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 }
};

View file

@ -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}

View file

@ -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
}

View file

@ -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

View file

@ -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)
{

View file

@ -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);