feat: Implement initial Ambilight color mapping
This commit is contained in:
parent
4ac2e445a9
commit
3425fe26b5
@ -14,6 +14,7 @@ public:
|
|||||||
~DebugClient();
|
~DebugClient();
|
||||||
|
|
||||||
void sendImage(const QImage &image);
|
void sendImage(const QImage &image);
|
||||||
|
void setLedsColor(const QVector<QColor> &colors) { Q_UNUSED(colors); qDebug() << "DebugClient: setLedsColor called (dummy implementation)."; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Helper to convert RGB to an ASCII character or colored block
|
// Helper to convert RGB to an ASCII character or colored block
|
||||||
|
|||||||
@ -35,11 +35,7 @@ HyperionGrabber::HyperionGrabber(QHash<QString, QString> opts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MODE
|
|
||||||
_client_p = new DebugClient(this);
|
|
||||||
#else
|
|
||||||
_client_p = new WledClient(addr, port, this);
|
_client_p = new WledClient(addr, port, this);
|
||||||
#endif
|
|
||||||
|
|
||||||
_waylandGrabber_p = new WaylandGrabber(this);
|
_waylandGrabber_p = new WaylandGrabber(this);
|
||||||
connect(_waylandGrabber_p, &WaylandGrabber::frameReady, this, &HyperionGrabber::_processFrame);
|
connect(_waylandGrabber_p, &WaylandGrabber::frameReady, this, &HyperionGrabber::_processFrame);
|
||||||
@ -96,5 +92,50 @@ void HyperionGrabber::_processFrame(const QVideoFrame &frame)
|
|||||||
scaledImage = scaledImage.convertToFormat(QImage::Format_RGB888);
|
scaledImage = scaledImage.convertToFormat(QImage::Format_RGB888);
|
||||||
}
|
}
|
||||||
|
|
||||||
_client_p->sendImage(scaledImage);
|
// Ambilight color mapping
|
||||||
|
// For demonstration, let's assume a simple layout: 10 LEDs on top, 10 on right, 10 on bottom, 10 on left
|
||||||
|
// In a real scenario, this layout would come from configuration (e.g., from wled_config_tool)
|
||||||
|
|
||||||
|
int ledsTop = 10;
|
||||||
|
int ledsRight = 10;
|
||||||
|
int ledsBottom = 10;
|
||||||
|
int ledsLeft = 10;
|
||||||
|
int totalLeds = ledsTop + ledsRight + ledsBottom + ledsLeft;
|
||||||
|
|
||||||
|
QVector<QColor> ledColors;
|
||||||
|
ledColors.reserve(totalLeds);
|
||||||
|
|
||||||
|
// Calculate average color for each LED region
|
||||||
|
// This is a simplified example; actual implementation would involve more precise region calculation
|
||||||
|
// and handling of corner LEDs.
|
||||||
|
|
||||||
|
// Top LEDs
|
||||||
|
for (int i = 0; i < ledsTop; ++i) {
|
||||||
|
int x = (scaledImage.width() / ledsTop) * i + (scaledImage.width() / ledsTop / 2);
|
||||||
|
int y = scaledImage.height() / 2; // Sample from middle of the image height
|
||||||
|
ledColors.append(scaledImage.pixelColor(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Right LEDs
|
||||||
|
for (int i = 0; i < ledsRight; ++i) {
|
||||||
|
int x = scaledImage.width() / 2; // Sample from middle of the image width
|
||||||
|
int y = (scaledImage.height() / ledsRight) * i + (scaledImage.height() / ledsRight / 2);
|
||||||
|
ledColors.append(scaledImage.pixelColor(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bottom LEDs
|
||||||
|
for (int i = 0; i < ledsBottom; ++i) {
|
||||||
|
int x = (scaledImage.width() / ledsBottom) * i + (scaledImage.width() / ledsBottom / 2);
|
||||||
|
int y = scaledImage.height() / 2; // Sample from middle of the image height
|
||||||
|
ledColors.append(scaledImage.pixelColor(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Left LEDs
|
||||||
|
for (int i = 0; i < ledsLeft; ++i) {
|
||||||
|
int x = scaledImage.width() / 2; // Sample from middle of the image width
|
||||||
|
int y = (scaledImage.height() / ledsLeft) * i + (scaledImage.height() / ledsLeft / 2);
|
||||||
|
ledColors.append(scaledImage.pixelColor(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
_client_p->setLedsColor(ledColors); // Send all LED colors at once
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user