int cBoblight::writePix(int *rgb)
{
   tell(2, "writePix r:%d g:%d b:%d", rgb[0], rgb[1], rgb[2]);
   boblight_addpixel(m_boblight, -1, rgb);

   return success;
}
Exemplo n.º 2
0
void BobClient::sync()
{
    if(!m_connected) {
        qCWarning(dcBoblight) << "Not connected to boblight. Cannot sync";
        return;
    }
    if(m_lastSyncTime.addMSecs(50) > QTime::currentTime()) {
        if(!m_resyncTimer.isActive()) {
            m_resyncTimer.start();
        }
        return;
    }
    qCDebug(dcBoblight) << "syncing";
    m_lastSyncTime = QTime::currentTime();

    for(int i = 0; i < lightsCount(); ++i) {
        //load the color into int array
        int rgb[3];
        rgb[0] = m_colors[i].red() * m_colors[i].alphaF();
        rgb[1] = m_colors[i].green() * m_colors[i].alphaF();
        rgb[2] = m_colors[i].blue() * m_colors[i].alphaF();
        qCDebug(dcBoblight) << "set color" << rgb[0] << rgb[1] << rgb[2];

        //set all lights to the color we want and send it
        boblight_addpixel(m_boblight, i, rgb);

    }

    if (!boblight_sendrgb(m_boblight, 1, NULL)) //some error happened, probably connection broken, so bitch and try again
    {
        qCWarning(dcBoblight) << "Boblight connection error:" << boblight_geterror(m_boblight);
        boblight_destroy(m_boblight);
        m_connected = false;
        connect(m_hostname, m_port);
    }
}