Skip to content

Commit 5d5b249

Browse files
authored
Fix #1007 - LED's retain last state after clearing a source (#1008)
* Save BLACK as lastLedColor during writeBlack * Remove debug statement overhead * Re-Add typecasting to ensure readable output * Revert "New language support: Russian and Chinese (simplified)" This reverts commit 5c95fab. * Ignore TemporaryError
1 parent 730b5d5 commit 5d5b249

File tree

7 files changed

+22
-496
lines changed

7 files changed

+22
-496
lines changed

assets/webconfig/i18n/ru.json

Lines changed: 0 additions & 232 deletions
This file was deleted.

assets/webconfig/i18n/zh-CN.json

Lines changed: 0 additions & 237 deletions
This file was deleted.

assets/webconfig/js/settings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var storedAccess;
22
var storedLang;
3-
var availLang = ['cs','de','en','es','fr','it','nl','pl','ro','sv','vi','ru','tr','zh-CN'];
4-
var availLangText = ['Čeština', 'Deutsch', 'English', 'Español', 'Français', 'Italiano', 'Nederlands', 'Polski', 'Română', 'Svenska', 'Tiếng Việt', 'русский', 'Türkçe', '汉语'];
3+
var availLang = ['cs','de','en','es','fr','it','nl','pl','ro','sv','vi','tr'];
4+
var availLangText = ['Čeština', 'Deutsch', 'English', 'Español', 'Français', 'Italiano', 'Nederlands', 'Polski', 'Română', 'Svenska', 'Tiếng Việt', 'Türkçe'];
55
var availAccess = ['default','advanced','expert'];
66
//$.i18n.debug = true;
77

include/utils/ColorRgb.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ static_assert(sizeof(ColorRgb) == 3, "Incorrect size of ColorRgb");
4646
inline std::ostream& operator<<(std::ostream& os, const ColorRgb& color)
4747
{
4848
os << "{"
49-
<< color.red << ","
50-
<< color.green << ","
51-
<< color.blue
49+
<< static_cast<unsigned>(color.red) << ","
50+
<< static_cast<unsigned>(color.green) << ","
51+
<< static_cast<unsigned>(color.blue)
5252
<< "}";
5353

5454
return os;
@@ -64,9 +64,9 @@ inline std::ostream& operator<<(std::ostream& os, const ColorRgb& color)
6464
inline QTextStream& operator<<(QTextStream &os, const ColorRgb& color)
6565
{
6666
os << "{"
67-
<< color.red << ","
68-
<< color.green << ","
69-
<< color.blue
67+
<< static_cast<unsigned>(color.red) << ","
68+
<< static_cast<unsigned>(color.green) << ","
69+
<< static_cast<unsigned>(color.blue)
7070
<< "}";
7171

7272
return os;

libsrc/leddevice/LedDevice.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ int LedDevice::writeBlack(int numberOfBlack)
246246
QTimer::singleShot(_latchTime_ms, &loop, &QEventLoop::quit);
247247
loop.exec();
248248
}
249-
rc = write(std::vector<ColorRgb>(static_cast<unsigned long>(_ledCount), ColorRgb::BLACK ));
249+
_lastLedValues = std::vector<ColorRgb>(static_cast<unsigned long>(_ledCount), ColorRgb::BLACK );
250+
rc = write(_lastLedValues);
250251
}
251252
return rc;
252253
}

libsrc/leddevice/dev_net/LedDeviceYeelight.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -983,10 +983,7 @@ LedDeviceYeelight::LedDeviceYeelight(const QJsonObject &deviceConfig)
983983

984984
LedDeviceYeelight::~LedDeviceYeelight()
985985
{
986-
if ( _tcpMusicModeServer != nullptr )
987-
{
988986
delete _tcpMusicModeServer;
989-
}
990987
}
991988

992989
LedDevice* LedDeviceYeelight::construct(const QJsonObject &deviceConfig)
@@ -1448,10 +1445,18 @@ int LedDeviceYeelight::write(const std::vector<ColorRgb> & ledValues)
14481445
}
14491446
else
14501447
{
1451-
QString errorReason = QString ("(%1) %2").arg(_tcpMusicModeServer->serverError()).arg( _tcpMusicModeServer->errorString());
1452-
Warning( _log, "write Error [%s]: _tcpMusicModeServer: %s", QSTRING_CSTR(light.getName()), QSTRING_CSTR(errorReason));
1453-
light.setInError("Failed to get stream socket");
1454-
}
1448+
QString errorReason = QString("(%1) %2").arg(_tcpMusicModeServer->serverError()).arg(_tcpMusicModeServer->errorString());
1449+
if (_tcpMusicModeServer->serverError() == QAbstractSocket::TemporaryError)
1450+
{
1451+
Info(_log, "Ignore write Error [%s]: _tcpMusicModeServer: %s", QSTRING_CSTR(light.getName()), QSTRING_CSTR(errorReason));
1452+
skipWrite = true;
1453+
}
1454+
else
1455+
{
1456+
Warning(_log, "write Error [%s]: _tcpMusicModeServer: %s", QSTRING_CSTR(light.getName()), QSTRING_CSTR(errorReason));
1457+
light.setInError("Failed to get stream socket");
1458+
}
1459+
}
14551460
}
14561461
else
14571462
{

libsrc/leddevice/dev_serial/ProviderRs232.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ void ProviderRs232::setInError(const QString& errorMsg)
193193

194194
int ProviderRs232::writeBytes(const qint64 size, const uint8_t *data)
195195
{
196-
DebugIf(_isInSwitchOff, _log, "_inClosing [%d], enabled [%d], _deviceReady [%d], _frameDropCounter [%d]", _isInSwitchOff, _isEnabled, _isDeviceReady, _frameDropCounter);
197-
198196
int rc = 0;
199197
if (!_rs232Port.isOpen())
200198
{
@@ -205,9 +203,6 @@ int ProviderRs232::writeBytes(const qint64 size, const uint8_t *data)
205203
return -1;
206204
}
207205
}
208-
209-
DebugIf( _isInSwitchOff, _log, "[%s]", QSTRING_CSTR(uint8_t_to_hex_string(data, size, 32)) );
210-
211206
qint64 bytesWritten = _rs232Port.write(reinterpret_cast<const char*>(data), size);
212207
if (bytesWritten == -1 || bytesWritten != size)
213208
{
@@ -243,13 +238,7 @@ int ProviderRs232::writeBytes(const qint64 size, const uint8_t *data)
243238
rc = -1;
244239
}
245240
}
246-
else
247-
{
248-
DebugIf(_isInSwitchOff,_log, "In Closing: bytesWritten [%d], _rs232Port.error() [%d], %s", bytesWritten, _rs232Port.error(), _rs232Port.error() == QSerialPort::NoError ? "No Error" : QSTRING_CSTR(_rs232Port.errorString()) );
249-
}
250241
}
251-
252-
DebugIf(_isInSwitchOff, _log, "[%d], _inClosing[%d], enabled [%d], _deviceReady [%d]", rc, _isInSwitchOff, _isEnabled, _isDeviceReady);
253242
return rc;
254243
}
255244

0 commit comments

Comments
 (0)