fix: small collection of bugfixed debugger hints and warnings (#801)

* small collection of bugfixed debugger hints / warnings

* 'toStdVector' has been explicitly marked deprecated

* fixed double zip naming in artifacts

* V4L2 WebUI Fix

* Some code fixes based on alerts from lgtm.com

* only execute dynamic v4l2 enum code, if V4L2_AVAIL

* very high critical bugfix ;)

* merge fix

* some lgtm.com fixes

* lgtm fixes

* undo localtime_r fix

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
SJunkies
2020-05-25 21:51:11 +02:00
committed by GitHub
parent e1288a2649
commit 3ff7fe483f
24 changed files with 519 additions and 522 deletions

View File

@@ -87,7 +87,7 @@ private:
///
/// @return Zero on success else negative
///
virtual int write(const std::vector<ColorRgb>& ledValues);
virtual int write(const std::vector<ColorRgb>& ledValues) override;
///
/// Test if the device is a (or the) lightpack we are looking for
@@ -131,7 +131,7 @@ private:
/// the number of bits per channel
int _bitsPerChannel;
/// count of real hardware leds
int _hwLedCount;
};

View File

@@ -87,8 +87,7 @@ int LedDeviceFile::write(const std::vector<ColorRgb> & ledValues)
// get a precise timestamp as a string
const auto now = std::chrono::system_clock::now();
const auto nowAsTimeT = std::chrono::system_clock::to_time_t(now);
const auto nowMs = std::chrono::duration_cast<std::chrono::milliseconds>(
now.time_since_epoch()) % 1000;
const auto nowMs = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000;
const auto elapsedTimeMs = std::chrono::duration_cast<std::chrono::milliseconds>(now - lastWriteTime);

View File

@@ -32,10 +32,13 @@ LedDevicePiBlaster::LedDevicePiBlaster(const QJsonObject &deviceConfig)
LedDevicePiBlaster::~LedDevicePiBlaster()
{
if (_fid != nullptr)
{
fclose(_fid);
_fid = nullptr;
}
}
bool LedDevicePiBlaster::init(const QJsonObject &deviceConfig)
{
bool isInitOK = LedDevice::init(deviceConfig);
@@ -95,7 +98,6 @@ int LedDevicePiBlaster::open()
if (!QFile::exists(_deviceName))
{
errortext = QString ("The device (%1) does not yet exist.").arg(_deviceName);
}
else
{
@@ -116,7 +118,6 @@ int LedDevicePiBlaster::open()
if ( retval < 0 )
{
this->setInError( errortext );
}
}
return retval;
@@ -132,8 +133,8 @@ void LedDevicePiBlaster::close()
{
fclose(_fid);
_fid = nullptr;
}}
}
}
int LedDevicePiBlaster::write(const std::vector<ColorRgb> & ledValues)
{
@@ -149,31 +150,31 @@ int LedDevicePiBlaster::write(const std::vector<ColorRgb> & ledValues)
if ( (valueIdx >= 0) && (valueIdx < static_cast<int>( _ledCount)) )
{
double pwmDutyCycle = 0.0;
switch (_gpio_to_color[ i ])
switch (_gpio_to_color[ i ])
{
case 'r':
pwmDutyCycle = ledValues[valueIdx].red / 255.0;
break;
case 'g':
pwmDutyCycle = ledValues[valueIdx].green / 255.0;
break;
case 'b':
pwmDutyCycle = ledValues[valueIdx].blue / 255.0;
break;
case 'w':
pwmDutyCycle = ledValues[valueIdx].red;
pwmDutyCycle += ledValues[valueIdx].green;
pwmDutyCycle += ledValues[valueIdx].blue;
pwmDutyCycle /= (3.0*255.0);
break;
default:
continue;
case 'r':
pwmDutyCycle = ledValues[valueIdx].red / 255.0;
break;
case 'g':
pwmDutyCycle = ledValues[valueIdx].green / 255.0;
break;
case 'b':
pwmDutyCycle = ledValues[valueIdx].blue / 255.0;
break;
case 'w':
pwmDutyCycle = ledValues[valueIdx].red;
pwmDutyCycle += ledValues[valueIdx].green;
pwmDutyCycle += ledValues[valueIdx].blue;
pwmDutyCycle /= (3.0*255.0);
break;
default:
continue;
}
// fprintf(_fid, "%i=%f\n", iPins[iPin], pwmDutyCycle);
if ( (fprintf(_fid, "%i=%f\n", i, pwmDutyCycle) < 0)
|| (fflush(_fid) < 0)) {
if ( (fprintf(_fid, "%i=%f\n", i, pwmDutyCycle) < 0) || (fflush(_fid) < 0))
{
if (_fid != nullptr)
{
fclose(_fid);