Skip to content

Commit

Permalink
Use CustomDistributor to build known layouts
Browse files Browse the repository at this point in the history
- Distributor uses coordinates rather than factors to avoid precision issues
- Distributor considers leftover pixels
- Custom stand with and thickness
- size_t to int
  • Loading branch information
psieg committed Jun 9, 2016
1 parent 49b0372 commit e9ee21a
Show file tree
Hide file tree
Showing 20 changed files with 307 additions and 627 deletions.
4 changes: 2 additions & 2 deletions Software/src/AbstractLedDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public slots:
virtual void requestFirmwareVersion() = 0;
virtual void updateDeviceSettings();

virtual size_t maxLedsCount() = 0;
virtual size_t defaultLedsCount() = 0;
virtual int maxLedsCount() = 0;
virtual int defaultLedsCount() = 0;

/*!
\obsolete only form compatibility with Lightpack ver.<=5.5 hardware
Expand Down
4 changes: 2 additions & 2 deletions Software/src/LedDeviceAdalight.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public slots:
void setColorSequence(QString value);
void requestFirmwareVersion();
void updateDeviceSettings();
size_t maxLedsCount() { return 255;}
virtual size_t defaultLedsCount() { return 25; }
int maxLedsCount() { return 255; }
virtual int defaultLedsCount() { return 25; }

private:
bool writeBuffer(const QByteArray & buff);
Expand Down
4 changes: 2 additions & 2 deletions Software/src/LedDeviceAlienFx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public slots:
void setSmoothSlowdown(int /*value*/);
void setColorSequence(QString /*value*/);
void requestFirmwareVersion();
size_t maxLedsCount() { return 1; }
size_t defaultLedsCount() { return 1; }
int maxLedsCount() { return 1; }
int defaultLedsCount() { return 1; }


private:
Expand Down
4 changes: 2 additions & 2 deletions Software/src/LedDeviceArdulight.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public slots:
void setColorSequence(QString value);
void requestFirmwareVersion();
void updateDeviceSettings();
size_t maxLedsCount(){ return 255;}
virtual size_t defaultLedsCount() { return 25; }
int maxLedsCount(){ return 255; }
virtual int defaultLedsCount() { return 25; }

private:
bool writeBuffer(const QByteArray & buff);
Expand Down
2 changes: 1 addition & 1 deletion Software/src/LedDeviceLightpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void LedDeviceLightpack::setColors(const QList<QRgb> & colors)
emit commandCompleted(ok);
}

size_t LedDeviceLightpack::maxLedsCount()
int LedDeviceLightpack::maxLedsCount()
{
if (m_devices.size() == 0)
tryToReopenDevice();
Expand Down
6 changes: 3 additions & 3 deletions Software/src/LedDeviceLightpack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public slots:
virtual void setColorSequence(QString /*value*/);
virtual void requestFirmwareVersion();
virtual void updateDeviceSettings();
virtual size_t maxLedsCount();
virtual size_t defaultLedsCount() { return maxLedsCount(); }
size_t lightpacksFound() { return m_devices.size(); }
virtual int maxLedsCount();
virtual int defaultLedsCount() { return maxLedsCount(); }
int lightpacksFound() { return m_devices.size(); }

private:
bool readDataFromDevice();
Expand Down
4 changes: 2 additions & 2 deletions Software/src/LedDeviceVirtual.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public slots:
void setGamma(double value);
void setBrightness(int value);
void requestFirmwareVersion();
size_t maxLedsCount() { return 255;}
size_t defaultLedsCount() { return 10;}
int maxLedsCount() { return 255; }
int defaultLedsCount() { return 10; }


private:
Expand Down
6 changes: 0 additions & 6 deletions Software/src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ SOURCES += \
wizard/LightpackDiscoveryPage.cpp \
wizard/ConfigureDevicePage.cpp \
wizard/SelectDevicePage.cpp \
wizard/AndromedaDistributor.cpp \
wizard/CassiopeiaDistributor.cpp \
wizard/PegasusDistributor.cpp \
wizard/CustomDistributor.cpp \
systrayicon/SysTrayIcon.cpp \
UpdatesProcessor.cpp
Expand Down Expand Up @@ -279,9 +276,6 @@ HEADERS += \
wizard/SelectDevicePage.hpp \
types.h \
wizard/AreaDistributor.hpp \
wizard/AndromedaDistributor.hpp \
wizard/CassiopeiaDistributor.hpp \
wizard/PegasusDistributor.hpp \
wizard/CustomDistributor.hpp \
systrayicon/SysTrayIcon.hpp \
systrayicon/SysTrayIcon_p.hpp \
Expand Down
117 changes: 0 additions & 117 deletions Software/src/wizard/AndromedaDistributor.cpp

This file was deleted.

59 changes: 0 additions & 59 deletions Software/src/wizard/AndromedaDistributor.hpp

This file was deleted.

45 changes: 19 additions & 26 deletions Software/src/wizard/AreaDistributor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,58 +40,51 @@ class ScreenArea {
_vScanStart(vScanStart),
_vScanEnd(vScanEnd){}

double hScanStart() { return _hScanStart; }
double hScanEnd() { return _hScanEnd; }
double vScanStart() { return _vScanStart; }
double vScanEnd() { return _vScanEnd; }
int hScanStart() { return _hScanStart; }
int hScanEnd() { return _hScanEnd; }
int vScanStart() { return _vScanStart; }
int vScanEnd() { return _vScanEnd; }
protected:
double _hScanStart;
double _hScanEnd;
double _vScanStart;
double _vScanEnd;
int _hScanStart;
int _hScanEnd;
int _vScanStart;
int _vScanEnd;
};

template <class T>
inline T within1(T x) {
if (x < 0.0) return 0.0;
if (x > 1.0) return 1.0;
return x;
}

template <class T>
inline int cmp(T x, T y, T e) {
inline int cmp(T x, T y, double e) {
T d = x - y;
if (fabs(d) < e) return 0;
if (fabs((double)d) < e) return 0;
if (d < 0) return -1;
return 1;
}

class AreaDistributor {
public:
AreaDistributor(int screenId, size_t areaCount):
_screenId(screenId),
AreaDistributor(QRect screen, int areaCount) :
_areaCount(areaCount),
_screen(screen),
_currentArea(NULL)
{}
virtual ~AreaDistributor(){}

virtual ScreenArea * next() = 0;

size_t areaCount() const { return _areaCount; }
int areaCount() const { return _areaCount; }

protected:
int _screenId;
size_t _areaCount;
int _areaCount;
QRect _screen;
ScreenArea * _currentArea;

double aspect() const {
QRect screenRect = QApplication::desktop()->screenGeometry(_screenId);
return (double)screenRect.width() / screenRect.height();
return (double)_screen.width() / _screen.height();
}

virtual size_t areaCountOnSideEdge() const = 0;
virtual size_t areaCountOnTopEdge() const = 0;
virtual size_t areaCountOnBottomEdge() const = 0;
virtual int areaCountOnSideEdge() const = 0;
virtual int areaCountOnTopEdge() const = 0;
virtual int areaCountOnBottomEdge() const = 0;
};

#endif // AREADISTRIBUTOR_HPP
Loading

0 comments on commit e9ee21a

Please sign in to comment.