ATMO_BOOL CAtmoMultiConnection::setChannelValues(int numValues,unsigned char *channel_values) { if(m_hComports[0] == INVALID_HANDLE_VALUE) return ATMO_FALSE; if((numValues & 1) || !channel_values) return ATMO_FALSE; // numValues must be even! ATMO_BOOL result = ATMO_TRUE; Lock(); size_t Index = 0; for (int i = 0; i < numValues; i+=2) { Index = (size_t)channel_values[i]; if(Index < sizeof(m_output)) m_output[Index] = channel_values[i + 1]; } for(int i = 0; i < 4; i++) if(m_hComports[i] != INVALID_HANDLE_VALUE) result = result & internal_SendData(m_hComports[i], &m_output[i*4*3]); Unlock(); return result; }
ATMO_BOOL CAtmoMultiConnection::SendData(pColorPacket data) { if(m_hComports[0] == INVALID_HANDLE_VALUE) return ATMO_FALSE; int numChannels = this->getNumChannels(); int idx; int iBuffer = 0; ATMO_BOOL result = ATMO_TRUE; Lock(); for(int i = 0; i < numChannels ; i++) { if(m_ChannelAssignment && (i < m_NumAssignedChannels)) idx = m_ChannelAssignment[i]; else idx = -1; if((idx>=0) && (idx<data->numColors)) { m_output[iBuffer] = data->zone[idx].r; m_output[iBuffer+1] = data->zone[idx].g; m_output[iBuffer+2] = data->zone[idx].b; } iBuffer+=3; } for(int i = 0;i < 4; i++) if(m_hComports[i] != INVALID_HANDLE_VALUE) result = result & internal_SendData(m_hComports[i], &m_output[i*4*3]); Unlock(); return result; }
ATMO_BOOL CAtmoMultiConnection::SendData(pColorPacket data) { if(m_hComports[0] == INVALID_HANDLE_VALUE) return ATMO_FALSE; int numChannels = this->getNumChannels(); int zoneIdx; int iBuffer = 0; ATMO_BOOL result = ATMO_TRUE; Lock(); for(int channel = 0; channel < numChannels ; channel++) { if(m_ChannelAssignment && (channel < m_NumAssignedChannels)) zoneIdx = m_ChannelAssignment[ channel ]; else zoneIdx = -1; if((zoneIdx>=0) && (zoneIdx < data->numColors)) { if(m_pAtmoConfig->isWhiteAdjPerChannel()) { int wr; int wg; int wb; m_pAtmoConfig->getChannelWhiteAdj( channel, wr, wg, wb); m_output[iBuffer] = (data->zone[zoneIdx].r * wr) / 256; m_output[iBuffer+1] = (data->zone[zoneIdx].g * wg) / 256; m_output[iBuffer+2] = (data->zone[zoneIdx].b * wb) / 256; } else { m_output[iBuffer] = data->zone[zoneIdx].r; m_output[iBuffer+1] = data->zone[zoneIdx].g; m_output[iBuffer+2] = data->zone[zoneIdx].b; } } iBuffer+=3; } for(int i = 0;i < 4; i++) if(m_hComports[i] != INVALID_HANDLE_VALUE) result = result & internal_SendData(m_hComports[i], &m_output[i*4*3]); Unlock(); return result; }
ATMO_BOOL CAtmoMultiConnection::setChannelColor(int channel, tRGBColor color) { if(m_hComports[0] == INVALID_HANDLE_VALUE) return ATMO_FALSE; if((channel < 0) || (channel >= getNumChannels())) return ATMO_FALSE; ATMO_BOOL result = ATMO_TRUE; Lock(); channel*=3; m_output[channel++] = color.r; m_output[channel++] = color.g; m_output[channel] = color.b; for(int i = 0; i < 4; i++) if(m_hComports[i] != INVALID_HANDLE_VALUE) result = result & internal_SendData(m_hComports[i], &m_output[i*4*3]); Unlock(); return result; }