void CTexture::ClampImageToSurfaceT() { if( !m_bClampedT && m_dwHeight < m_dwCreatedTextureHeight ) { DrawInfo di; if( StartUpdate(&di) ) { if( m_dwTextureFmt == TEXTURE_FMT_A8R8G8B8 ) { uint32_t* linesrc = (uint32_t*)((uint8_t*)di.lpSurface+di.lPitch*(m_dwHeight-1)); for( uint32_t y = m_dwHeight; y<m_dwCreatedTextureHeight; y++ ) { uint32_t* linedst = (uint32_t*)((uint8_t*)di.lpSurface+di.lPitch*y); for( uint32_t x=0; x<m_dwCreatedTextureWidth; x++ ) linedst[x] = linesrc[x]; } } else { uint16_t* linesrc = (uint16_t*)((uint8_t*)di.lpSurface+di.lPitch*(m_dwHeight-1)); for( uint32_t y = m_dwHeight; y<m_dwCreatedTextureHeight; y++ ) { uint16_t* linedst = (uint16_t*)((uint8_t*)di.lpSurface+di.lPitch*y); for( uint32_t x=0; x<m_dwCreatedTextureWidth; x++ ) linedst[x] = linesrc[x]; } } EndUpdate(&di); } } m_bClampedT = true; }
void CTexture::RestoreAlphaChannel(void) { DrawInfo di; if ( StartUpdate(&di) ) { uint32 *pSrc = (uint32 *)di.lpSurface; int lPitch = di.lPitch; for (uint32 y = 0; y < m_dwHeight; y++) { uint32 * dwSrc = (uint32 *)((uint8 *)pSrc + y*lPitch); for (uint32 x = 0; x < m_dwWidth; x++) { uint32 dw = dwSrc[x]; uint32 dwRed = (uint8)((dw & 0x00FF0000)>>16); uint32 dwGreen = (uint8)((dw & 0x0000FF00)>>8 ); uint32 dwBlue = (uint8)((dw & 0x000000FF) ); uint32 dwAlpha = (dwRed+dwGreen+dwBlue)/3; dw &= 0x00FFFFFF; dw |= (dwAlpha<<24); /* uint32 dw = dwSrc[x]; if( (dw&0x00FFFFFF) > 0 ) dw |= 0xFF000000; else dw &= 0x00FFFFFF; */ } } EndUpdate(&di); }
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { RECT rcClient; // Client area of parent window int iPBHeight = 30; switch (message) /* handle the messages */ { case WM_CREATE : GetClientRect(hwnd, &rcClient); hwndPB = CreateWindowEx(0, PROGRESS_CLASS, (LPTSTR) NULL, WS_CHILD | WS_VISIBLE, rcClient.left, (rcClient.bottom - rcClient.top-iPBHeight)/2, rcClient.right, iPBHeight, hwnd, (HMENU) 0, ((LPCREATESTRUCT) lParam)->hInstance, NULL); PostMessage(hwnd,WM_UPDATE_START,(WPARAM)hwndPB,(LPARAM)NULL); break; case WM_PAINT : DefWindowProc (hwnd, message, wParam, lParam); //PostMessage(hwnd,WM_UPDATE_START,(WPARAM)hwndPB,(LPARAM)NULL); break; case WM_DESTROY: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; case WM_UPDATE_START: { TCHAR *pFilePath = ".\\"; StartUpdate((HWND)wParam,pFilePath); } break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; }
void CTexture::ClampImageToSurfaceS() { if( !m_bClampedS && m_dwWidth < m_dwCreatedTextureWidth ) { DrawInfo di; if( StartUpdate(&di) ) { if( m_dwTextureFmt == TEXTURE_FMT_A8R8G8B8 ) { for( uint32_t y = 0; y<m_dwHeight; y++ ) { uint32_t* line = (uint32_t*)((uint8_t*)di.lpSurface+di.lPitch*y); uint32_t val = line[m_dwWidth-1]; for( uint32_t x=m_dwWidth; x<m_dwCreatedTextureWidth; x++ ) line[x] = val; } } else { for( uint32_t y = 0; y<m_dwHeight; y++ ) { uint16_t* line = (uint16_t*)((uint8_t*)di.lpSurface+di.lPitch*y); uint16_t val = line[m_dwWidth-1]; for( uint32_t x=m_dwWidth; x<m_dwCreatedTextureWidth; x++ ) line[x] = val; } } EndUpdate(&di); } } m_bClampedS = true; }
eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) { eOSState state = ProcessInstallationStatus(); if (state == osEnd) return osEnd; state = cOsdMenu::ProcessKey(Key); if (state == osUnknown) { switch (Key) { case kOk: { cOsdItem *current = Get(Current()); cSkinSetupSubMenu *subMenuItem = dynamic_cast<cSkinSetupSubMenu*>(current); if (subMenuItem) { state = AddSubMenu(new cSkindesignerSkinSetup(skin, subMenuItem->GetName(), subMenuItem->GetDisplayText())); break; } else { return osBack; } } case kRed: { string versionNeeded = ""; bool versionOk = config.CheckVersion(skin, versionNeeded); if (!versionOk) { cString error = cString::sprintf("%s %s %s %s %s", tr("Skin Designer"), tr("version"), versionNeeded.c_str(), tr("or higher"), tr("needed")); Skins.Message(mtError, *error); break; } bool gitAvailable = StartUpdate(skin); if (gitAvailable) { Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Updating Skin from Git"))); } else { Skins.Message(mtStatus, tr("No Git Repsoitory available")); } break; } // KEY YELLOW case kYellow: { if (config.SkinActive(skin)) { Skins.Message(mtError, tr("Skin is running and can't be deleted")); } else if (Interface->Confirm(*cString::sprintf("%s?", tr("Really delete skin")))) { config.DeleteSkin(skin); Skins.Message(mtStatus, tr("Skin deleted")); cCondWait::SleepMs(1000); return osEnd; } state = osContinue; break; } default: break; } } return state; }
//! @brief Initializes the application. //! //! It will open the main window and connect default to server or open the connect window. bool UpdaterApp::OnInit() { //this triggers the Cli Parser amongst other stuff if (!wxApp::OnInit()) return false; if ( m_paramcount == 5) { WaitForExit(m_pid); wxArrayString params; if (!StartUpdate(TrimQuotes(m_source_dir), TrimQuotes(m_destination_dir), true)) { //update failed, try as admin params.push_back(m_source_dir); params.push_back(m_destination_dir); RunProcess(m_updater_exe, params, false, true); params.clear(); } //start springlobby return RunProcess(m_springlobby_exe, params, true); } else if (m_paramcount != 2) { return false; } return StartUpdate(TrimQuotes(m_source_dir), TrimQuotes(m_destination_dir), false); }
//=========================================================================== bool CSMLoginScene::OnTargetBtnEvent( NDUINode * uiNode, int targetEvent ) { int iTag = uiNode->GetTag(); if ( TE_TOUCH_BTN_CLICK == targetEvent ) { if ( TAG_BTN_OK == iTag ) { CloseConfirmDlg(); StartUpdate(); } else if ( TAG_BTN_CANCEL == iTag ) { exit(0); } } return true; }
void CTexture::ClampImageToSurfaceT() { #ifdef __GX__ return; // In GX we can always use the exact texture height. #else //__GX__ if( !m_bClampedT && m_dwHeight < m_dwCreatedTextureHeight ) { DrawInfo di; if( StartUpdate(&di) ) { if( m_dwTextureFmt == TEXTURE_FMT_A8R8G8B8 ) { uint32* linesrc = (uint32*)((uint8*)di.lpSurface+di.lPitch*(m_dwHeight-1)); for( uint32 y = m_dwHeight; y<m_dwCreatedTextureHeight; y++ ) { uint32* linedst = (uint32*)((uint8*)di.lpSurface+di.lPitch*y); for( uint32 x=0; x<m_dwCreatedTextureWidth; x++ ) { linedst[x] = linesrc[x]; } } } else { uint16* linesrc = (uint16*)((uint8*)di.lpSurface+di.lPitch*(m_dwHeight-1)); for( uint32 y = m_dwHeight; y<m_dwCreatedTextureHeight; y++ ) { uint16* linedst = (uint16*)((uint8*)di.lpSurface+di.lPitch*y); for( uint32 x=0; x<m_dwCreatedTextureWidth; x++ ) { linedst[x] = linesrc[x]; } } } EndUpdate(&di); } } m_bClampedT = true; #endif //!__GX__ }
void CTexture::ClampImageToSurfaceS() { #ifdef __GX__ return; // In GX we can always use the exact texture width. #else //__GX__ if( !m_bClampedS && m_dwWidth < m_dwCreatedTextureWidth ) { DrawInfo di; if( StartUpdate(&di) ) { if( m_dwTextureFmt == TEXTURE_FMT_A8R8G8B8 ) { for( uint32 y = 0; y<m_dwHeight; y++ ) { uint32* line = (uint32*)((uint8*)di.lpSurface+di.lPitch*y); uint32 val = line[m_dwWidth-1]; for( uint32 x=m_dwWidth; x<m_dwCreatedTextureWidth; x++ ) { line[x] = val; } } } else { for( uint32 y = 0; y<m_dwHeight; y++ ) { uint16* line = (uint16*)((uint8*)di.lpSurface+di.lPitch*y); uint16 val = line[m_dwWidth-1]; for( uint32 x=m_dwWidth; x<m_dwCreatedTextureWidth; x++ ) { line[x] = val; } } } EndUpdate(&di); } } m_bClampedS = true; #endif //!__GX__ }
// There are reasons to create this function. D3D will only create surface of width and height // as 2's pow, for example, N64's 20x14 image, D3D will create a 32x16 surface. // When we using such a surface as D3D texture, and the U and V address is for the D3D surface // width and height. It is still OK if the U and V addr value is less than the real image within // the D3D surface. But we will have problems if the U and V addr value is larger than it, or even // large then 1.0. // In such a case, we need to scale the image to the D3D surface dimension, to ease the U/V addr // limition void CTexture::ScaleImageToSurface(bool scaleS, bool scaleT) { uint8 g_ucTempBuffer[1024*1024*4]; if( scaleS==false && scaleT==false) return; // If the image is not scaled, call this function to scale the real image to // the D3D given dimension uint32 width = scaleS ? m_dwWidth : m_dwCreatedTextureWidth; uint32 height = scaleT ? m_dwHeight : m_dwCreatedTextureHeight; uint32 xDst, yDst; uint32 xSrc, ySrc; DrawInfo di; if (!StartUpdate(&di)) { return; } int pixSize = GetPixelSize(); // Copy across from the temp buffer to the surface switch (pixSize) { case 4: { memcpy((uint8*)g_ucTempBuffer, (uint8*)(di.lpSurface), m_dwHeight*m_dwCreatedTextureWidth*4); uint32 * pDst; uint32 * pSrc; for (yDst = 0; yDst < m_dwCreatedTextureHeight; yDst++) { // ySrc ranges from 0..m_dwHeight // I'd rather do this but sometimes very narrow (i.e. 1 pixel) // surfaces are created which results in /0... //ySrc = (yDst * (m_dwHeight-1)) / (d3dTextureHeight-1); ySrc = (uint32)((yDst * height) / m_dwCreatedTextureHeight+0.49f); pSrc = (uint32*)((uint8*)g_ucTempBuffer + (ySrc * m_dwCreatedTextureWidth * 4)); pDst = (uint32*)((uint8*)di.lpSurface + (yDst * di.lPitch)); for (xDst = 0; xDst < m_dwCreatedTextureWidth; xDst++) { xSrc = (uint32)((xDst * width) / m_dwCreatedTextureWidth+0.49f); pDst[xDst] = pSrc[xSrc]; } } } break; case 2: { memcpy((uint8*)g_ucTempBuffer, (uint8*)(di.lpSurface), m_dwHeight*m_dwCreatedTextureWidth*2); uint16 * pDst; uint16 * pSrc; for (yDst = 0; yDst < m_dwCreatedTextureHeight; yDst++) { // ySrc ranges from 0..m_dwHeight ySrc = (yDst * height) / m_dwCreatedTextureHeight; pSrc = (uint16*)((uint8*)g_ucTempBuffer + (ySrc * m_dwCreatedTextureWidth * 2)); pDst = (uint16*)((uint8*)di.lpSurface + (yDst * di.lPitch)); for (xDst = 0; xDst < m_dwCreatedTextureWidth; xDst++) { xSrc = (xDst * width) / m_dwCreatedTextureWidth; pDst[xDst] = pSrc[xSrc]; } } } break; } EndUpdate(&di); if( scaleS ) m_bScaledS = true; if( scaleT ) m_bScaledT = true; }
__declspec(dllexport) void AutomaticUpdate (HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { StartUpdate((HINSTANCE)hDLL, NULL, "", SW_NORMAL); }
//=========================================================================== void CSMLoginScene::OnMsg_ClientVersion(NDTransData& kData) { bool bUpdate = false; int bLatest = kData.ReadByte(); int bForceUpdate = kData.ReadByte(); int FromVersion = kData.ReadInt(); int ToVersion = kData.ReadInt(); std::string UpdatePath = kData.ReadUnicodeString(); if ( bForceUpdate ) { CloseWaitingAni(); //printf("请用户重新下载最新游戏版本"); if ( m_pLabelPromtp ) { m_pLabelPromtp->SetText( NDCommonCString2(SZ_ERROR_01).c_str() ); m_pLabelPromtp->SetFontColor( ccc4(0xFF,0x0,0x0,255) ); m_pLabelPromtp->SetVisible( true ); //m_pLabelPromtp->SetFontSize( 20 ); } return ; } else if ( ( FromVersion == ToVersion ) && ( !bLatest ) ) { CloseWaitingAni(); //printf("当前版本数据有误,请重新下载或者联系GM"); if ( m_pLabelPromtp ) { m_pLabelPromtp->SetText( NDCommonCString2(SZ_ERROR_02).c_str() ); m_pLabelPromtp->SetFontColor( ccc4(0xFF,0x0,0x0,255) ); m_pLabelPromtp->SetVisible( true ); //m_pLabelPromtp->SetFontSize( 20 ); } return ; } else if ( ( FromVersion == 0 ) && ( ToVersion == 0 ) ) { CloseWaitingAni(); //printf("版本信息损坏,请重新下载或者联系GM"); if ( m_pLabelPromtp ) { m_pLabelPromtp->SetText( NDCommonCString2(SZ_ERROR_03).c_str() ); m_pLabelPromtp->SetFontColor( ccc4(0xFF,0x0,0x0,255) ); m_pLabelPromtp->SetVisible( true ); //m_pLabelPromtp->SetFontSize( 20 ); } return ; } else if ( ( FromVersion == ToVersion ) && (bLatest) ) { //printf("当前版本是最新游戏版本"); StartEntry(); return; } else { bUpdate = true; } NDLog("URL:%s",UpdatePath.c_str()); kDeqUpdateUrl.push_back(UpdatePath); if (bUpdate) { if (!bLatest) { CloseWaitingAni(); //if ( !NDBeforeGameMgrObj.isWifiNetWork() )//关闭掉坑爹的WIFI监测 //{ // ShowCheckWIFIOff(); // m_pTimer->SetTimer( this, TAG_TIMER_CHECK_WIFI, 1.0f ); //} //else { StartUpdate(); } } } }
//=========================================================================== void CSMLoginScene::OnTimer( OBJID idTag ) { static bool bFirst = true; if (bFirst) { LOGD("Entry First OnTimer"); //idTag = TAG_TIMER_UPDATE; bFirst = false; } if ( idTag == TAG_TIMER_UPDATE ) { if ( !rename( m_strSavePath.c_str(), m_strSavePath.c_str() ) ) { if ( remove( m_strSavePath.c_str() ) ) { m_pTimer->KillTimer(this, TAG_TIMER_UPDATE); return; } } FromUrl(m_strUpdateURL.c_str()); ToPath(m_strSavePath.c_str()); Download(); m_pTimer->KillTimer(this, TAG_TIMER_UPDATE); } else if ( idTag == TAG_TIMER_DOWNLOAD_SUCCESS ) { m_pTimer->KillTimer(this, TAG_TIMER_DOWNLOAD_SUCCESS); LOGD("Entry TAG_TIMER_DOWNLOAD_SUCCESS process."); UnZipFile( m_strSavePath.c_str(), m_strCachePath.c_str()); } else if ( idTag == TAG_TIMER_UNZIP_SUCCESS ) { m_pTimer->KillTimer(this, TAG_TIMER_UNZIP_SUCCESS); if ( remove(m_strSavePath.c_str()) ) { NDLog("delete:%s failed",m_strSavePath.c_str()); //return; } std::string szListFile = NDPath::GetCashesPath() + SZ_DEL_FILE; DeleteFileFromFile( szListFile ); if(kDeqUpdateUrl.size() > 0) { kDeqUpdateUrl.pop_front(); } PackageCount++; //查找下载队列 if (kDeqUpdateUrl.size() > 0) { //定义保存路径 m_strUpdateURL = *kDeqUpdateUrl.begin(); //m_savePath = [[NSString stringWithFormat:@"%s/update%d.zip", m_cachPath.c_str(), PackageCount] UTF8String]; m_pTimer->SetTimer( this, TAG_TIMER_UPDATE, 0.5f ); StartDownload(); } else { //跳转到启动界面 StartEntry(); } } else if ( TAG_TIMER_CHECK_WIFI == idTag ) { //如果检测没开启WIFI则不断检测// if ( NDBeforeGameMgrObj.isWifiNetWork() ) { m_pTimer->KillTimer( this, TAG_TIMER_CHECK_WIFI ); CloseConfirmDlg(); StartUpdate(); } } else if ( TAG_TIMER_CHECK_UPDATE == idTag ) { m_pTimer->KillTimer(this, TAG_TIMER_CHECK_UPDATE); ShowUpdateOff(); } else if ( TAG_TIMER_CHECK_COPY == idTag ) { int copyStatus = NDBeforeGameMgr::GetCopyStatus(); switch (copyStatus) { case -1: m_pTimer->KillTimer( this, TAG_TIMER_CHECK_COPY ); //NSLog( @"Copy files error!" ); exit(0); break; case 0: break; case 1: m_pTimer->KillTimer( this, TAG_TIMER_CHECK_COPY ); NDBeforeGameMgrObj.doNDSdkLogin(); ShowWaitingAni(); break; default: break; } } else if ( TAG_TIMER_FIRST_RUN == idTag ) { LOGD("Entry TAG_TIMER_FIRST_RUN == idTag"); m_pTimer->KillTimer( this, TAG_TIMER_FIRST_RUN ); CreateUpdateUILayer(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) CCLog( "@@login02: to call OnEvent_LoginOKNormal()\r\n" ); m_iAccountID = NDBeforeGameMgrObj.GetCurrentUser(); OnEvent_LoginOKNormal(m_iAccountID); #else #ifdef USE_MGSDK NDUIImage * pImage = (NDUIImage *)m_pLayerUpdate->GetChild( TAG_CTRL_PIC_BG); if ( pImage ) { NDPicture * pPicture = new NDPicture; pPicture->Initialization( NDPath::GetUIImgPath( SZ_MOBAGE_BG_PNG_PATH ).c_str() ); pImage->SetPicture( pPicture, true ); } #endif #if CACHE_MODE == 1 if ( NDBeforeGameMgrObj.CheckFirstTimeRuning() ) { if ( m_pLabelPromtp ) { m_pLabelPromtp->SetText( NDCommonCString2(SZ_FIRST_INSTALL).c_str() ); m_pLabelPromtp->SetVisible( true ); ShowWaitingAni(); #ifdef USE_MGSDK m_pLabelPromtp->SetVisible( false );//Mobage的版本暂将文字绘在背景图上 #endif } m_pTimer->SetTimer( this, TAG_TIMER_CHECK_COPY, 0.5f ); } else #endif { NDBeforeGameMgrObj.doNDSdkLogin(); ShowWaitingAni(); } #endif //CreateUpdateUILayer(); //NDBeforeGameMgrObj.CheckClientVersion(SZ_UPDATE_URL); } else if ( TAG_TIMER_LOAD_RES_OK == idTag ) { m_pTimer->KillTimer( this, TAG_TIMER_LOAD_RES_OK ); CloseWaitingAni(); CloseUpdateUILayer(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) //if ( m_iAccountID == 0 ) m_iAccountID = ScriptMgrObj.excuteLuaFuncRetN( "GetAccountID", "Login_ServerUI" ); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) m_iAccountID = NDBeforeGameMgrObj.GetCurrentUser(); #endif ScriptMgrObj.excuteLuaFunc( "ShowUI", "Entry", m_iAccountID ); // ScriptMgrObj.excuteLuaFunc("ProecssLocalNotification", "MsgLoginSuc"); } }
eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) { eOSState state = ProcessInstallationStatus(); if (state == osEnd) return osEnd; bool hadSubMenu = HasSubMenu(); state = cMenuSetupPage::ProcessKey(Key); if (hadSubMenu && Key == kOk) { Store(); } if (!hadSubMenu && (Key == kOk || Key == kUp || Key == kDown || Key == kLeft || Key == kRight || Key == kRed || Key == kYellow)) { SetHelp(NULL, NULL, NULL, NULL); cOsdItem *current = Get(Current()); cSkinMenuItem *skinMenuItem = dynamic_cast<cSkinMenuItem*>(current); if (!skinMenuItem) return state; eItemType type = skinMenuItem->Type(); currentSkin = skinMenuItem->GetSkinName(); // KEY OK if ((Key == kOk)) { if (type == itSkinSetup) { state = AddSubMenu(new cSkindesignerSkinSetup(currentSkin, "", "")); } else if (type == itNoSkinSetup) { state = osContinue; } else if (type == itSkinRepo) { Skins.Message(mtStatus, tr("Downloading Skin Screenshots...")); cSkindesignerSkinPreview *prev = new cSkindesignerSkinPreview(currentSkin); Skins.Message(mtStatus, NULL); state = AddSubMenu(prev); } } // Menu Moves if (Key == kUp || Key == kDown || Key == kLeft || Key == kRight) { if (type == itSkinRepo) { SetHelp(tr("Install Skin"), NULL, NULL, NULL); } else if (type == itSkinSetup || type == itNoSkinSetup) { cSkinRepo *repo = config.GetSkinRepo(currentSkin); if (repo) { if (repo->Type() == rtGit) SetHelp(tr("Update"), NULL, tr("Delete Skin"), NULL); else SetHelp(NULL, NULL, tr("Delete Skin"), NULL); } } } // KEY RED if (Key == kRed) { string versionNeeded = ""; bool versionOk = config.CheckVersion(currentSkin, versionNeeded); if (!versionOk) { cString error = cString::sprintf("%s %s %s %s %s", tr("Skin Designer"), tr("version"), versionNeeded.c_str(), tr("or higher"), tr("needed")); Skins.Message(mtError, *error); return state; } if (type == itSkinRepo) { Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Installing Skin"))); StartInstallation(currentSkin); } else if (type == itSkinSetup || type == itNoSkinSetup) { bool gitAvailable = StartUpdate(currentSkin); if (gitAvailable) { Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Updating Skin from Git"))); } else { Skins.Message(mtStatus, tr("No Git Repsoitory available")); } } } // KEY YELLOW if (Key == kYellow) { if (type == itSkinSetup || type == itNoSkinSetup) { if (config.SkinActive(currentSkin)) { Skins.Message(mtError, tr("Skin is running and can't be deleted")); } else if (Interface->Confirm(*cString::sprintf("%s?", tr("Really delete skin")))) { config.DeleteSkin(currentSkin); Skins.Message(mtStatus, tr("Skin deleted")); cCondWait::SleepMs(1000); return osEnd; } state = osContinue; } } } return state; }
/*** bool WS2812::updateLEDs(GRB rgGRB[], uint32_t cPass) * * Parameters: * rgGRB: An array of GRB structures that contains the * the value for each Green, Red, or Blue pixel in * the device. Values may be from 0 to 255. * This point must NOT change until updateLEDs() returns true. * * cPass: How many devices to convert in the pattern buffer per call to * updateLEDs(). This allows you to control how long you say in updateLEDs() * The default value is to convert 5 devices per call to updateLEDs(). * * Return Values: * False while updateLEDs() is still working to convert devices. * True when all devices have been converted. * * Description: * * This will return false until the DMA is stream the refresh cycle * and until all devices have been converted into the pattern buffer. * Once everything is done, this will return true and then you can change * rgGRB to a new pattern. You need to repeatedly call updateLEDs() until it * returns true. * * ------------------------------------------------------------ */ bool WS2812::updateLEDs(GRB rgGRB[], uint32_t cPass) { if(!_fInit) { return(false); } switch(_updateState) { case INIT: if(_pGRB == NULL) { _pGRB = rgGRB; _iNextDevice = 0; _iBit = 0; _iByte = 0; memset(_pPatternBuffer, 0, _cbPatternBuffer); _updateState = WAITUPD; } break; case WAITUPD: if(StartUpdate()) { _updateState = CONVGRB; } break; case CONVGRB: if(_pGRB == rgGRB) { for(int i=0; i<cPass && _iNextDevice < _cDevices; i++, _iNextDevice++) { applyGRB(rgGRB[_iNextDevice]); } if(_iNextDevice == _cDevices) { if(_fInvert) { _updateState = INVERT; } else { _updateState = ENDUPD; } } } break; case INVERT: for(int i=0; i<_cbPatternBuffer; i++) { _pPatternBuffer[i] = ~_pPatternBuffer[i]; } _updateState = ENDUPD; break; case ENDUPD: abortUpdate(); EndUpdate(); return(true); break; default: break; } return(false); }