AutomatedScreenshotController::WaitPredicate AutomatedScreenshotController::SelectedPinSceneSetup(const std::string& query, int searchMenuPinIx) const { const long long MsToWaitForSearchResults = 7000; const long long MsToWaitForCameraToTransitionToPoi = 5000; const long long MsWaitForPoiToOpen = 5000; m_searchQueryPerformer.PerformSearchQuery(query, false, false); return Seq(WaitMs(MsToWaitForSearchResults), Act([=]() { m_messageBus.Publish(SelectMenuItemMessage(searchMenuPinIx)); }), WaitMs(MsToWaitForCameraToTransitionToPoi), Act([=]() { const float x = m_screenProperties.GetScreenWidth()/2.f; const float y = m_screenProperties.GetScreenHeight()*(2.f/3.f); m_worldPinsModule.GetWorldPinsService().HandleTouchTap({x, y}); }), WaitMs(MsWaitForPoiToOpen), Act([=]() { m_searchQueryPerformer.RequestClear(); m_searchQueryPerformer.RemoveSearchQueryResults(); }) ); }
void ScrollDisplay() { int i; int d = 40; int ms = 10; // delay for (i = 1; i < d; ++i) { SetRowOffset(i); WaitMs(ms); } while (--i >= 0) { SetRowOffset(i); WaitMs(ms); } for (i = 131; i > 131 - d; --i) { SetRowOffset(i); WaitMs(ms); } while (++i <= 131) { SetRowOffset(i); WaitMs(ms); } SetRowOffset(0); }
// send address via IIC. BOOL I2C_SendAddr(BYTE DevAddr, WORD Addr, BYTE ReadWriteFlag, BYTE I2cDevice) { I2C_Start(I2cDevice); if(!I2C_WriteByte(DevAddr, I2cDevice)) { WaitMs(EEPROM_WRITE_TIME); // Wairt for Programming-time. I2C_Start(I2cDevice); if(!I2C_WriteByte(DevAddr, I2cDevice))// | PageAddr)) { I2C_Stop(I2cDevice); return FALSE; } } if(!I2C_WriteByte((BYTE)Addr, I2cDevice)) { I2C_Stop(I2cDevice); return FALSE; } if(ReadWriteFlag == IIC_READ) { I2C_Start(I2cDevice); if(!I2C_WriteByte((DevAddr | IIC_READ), I2cDevice)) { I2C_Stop(I2cDevice); return FALSE; } } return TRUE; }
//===========================================================================// void AT45DB_Init_Flash(void) { MRES = 0; DF_CS = 1; WaitMs(1); MRES = 1; }
void ClearScreen() { WriteCmd(ocClearWin); WriteData(0); WriteData(0); WriteData(xMost); WriteData(yMost); WaitMs(5); // give it time to finish }
void DrawLine(uchar x1, uchar y1, uchar x2, uchar y2, CLR clr) { WriteCmd(ocDrawLine); WriteData(x1); WriteData(y1); WriteData(x2); WriteData(y2); WriteClrCmd(clr); WaitMs(5); // give it time to do the drawing }
void DrawCircle(uchar x, uchar y, uchar r, CLR clrOutline, CLR clrFill) { WriteCmd(ocDrawCirc); WriteData(x); // x center WriteData(y); // y center WriteData(r); // radius WriteClrCmd(clrOutline); WriteClrCmd(clrFill); WaitMs(5); // give it time to do the drawing }
/* draws lines in first and last row and column, based on constants defined in OLED.h */ void DrawEdges() { ClearScreen(); DrawLine(0, 0, xMost, 0, clrRed); DrawLine(0, yLast, xMost, yLast, clrMagenta); DrawLine(0, 0, 0, yMost, clrCyan); DrawLine(xLast, 0, xLast, yMost, clrYellow); WaitMs(1000); }
void DrawRectangle(uchar xLeft, uchar yTop, uchar xRight, uchar yBottom, CLR clrOutline, CLR clrFill) { WriteCmd(ocDrawRect); WriteData(xLeft); WriteData(yTop); WriteData(xRight); WriteData(yBottom); WriteClrCmd(clrOutline); WriteClrCmd(clrFill); WaitMs(5); // give it time to do the drawing }
void XbInit() { //init uart //init mode // set to device stand by XbSyncState=XBEE_NOT_SYNC; //initialize uart #1: 9600 bps, 8N1, no FIFO UartInit(9600); WaitMs(3); XbResetInit(); XbHwReset(); }
AutomatedScreenshotController::WaitPredicate AutomatedScreenshotController::SharedLandmarkSceneWaitPredicate(const bool openSearchMenu) const { const long long MsToWaitForWatermarkToSettle = 3000; const long long MsToWaitForSearchResultsToReturn = 3000; const long long MsToWaitForSearchMenuToOpen = 2000; return Seq(WaitMs(MsToWaitForWatermarkToSettle), Act([=]() { m_messageBus.Publish(SearchMenu::OpenSearchMenuMessage(openSearchMenu)); }), WaitMs(MsToWaitForSearchMenuToOpen), Act([=]() { if (openSearchMenu) { m_messageBus.Publish(OpenSearchMenuSectionMessage([=](const Menu::View::IMenuSectionViewModel& section) { return openSearchMenu && section.Name() == "Find"; })); } else { m_searchQueryPerformer.PerformSearchQuery("", true, false); } }), WaitMs(MsToWaitForSearchResultsToReturn)); }
/* draws lines at perimeter to help identify which rows & cols are visible */ void FindEdges() { int r, c; ClearScreen(); for (r = 0; r <= 10; r += 2) DrawLine(0, r, 131, r, clrRed); for (r = 131; r >= 121; r -= 2) DrawLine(0, r, 131, r, clrMagenta); for (c = 0; c <= 10; c += 2) DrawLine(c, 0, c, 131, clrCyan); for (c = 131; c >= 121; c -= 2) DrawLine(c, 0, c, 131, clrYellow); WaitMs(1000); }
char ReceiveChar(uart_regs * uart, unsigned int TimeoutMs, unsigned int *error){ uint32_t i = 0; volatile int temp = 0; while (1){ temp = loadmem((int)&uart->status); if ((temp & RX_DATAREADY) != 0){ break; } else { if (i == TimeoutMs){ *error = 1; return 0; } i++; WaitMs(1); } } return loadmem((int)&uart->data); }
/* draw 100 random circles (inspired by SparkFun's sample code) */ void DrawCircles() { int i; ClearScreen(); for (i = 0; i < 100; ++i) { DrawCircle( rand() % dxScreen, rand() % dyScreen, rand() % 32 + 10, ClrFromRGB(rand(), rand(), rand()), ClrFromRGB(rand(), rand(), rand())); } WaitMs(1000); }
/* uses direct writing to RAM to set each pixel on the screen; draws color swatches */ void FillScreenPixels() { int r, c; ClearScreen(); /* max resolution is 6 bits per pixel, so low 2 bits are ignored; changing by 4 moves to next distinct value */ SetPixelBox(0, 0, 63, 63, true); for (r = 0; r < 256; r += 4) for (c = 0; c < 256; c += 4) DrawPixel(ClrFromRGB(r, c, 0)); SetPixelBox(64, 0, 127, 63, true); for (r = 0; r < 256; r += 4) for (c = 0; c < 256; c += 4) DrawPixel(ClrFromRGB(r, 0, c)); SetPixelBox(0, 64, 63, 127, true); for (r = 0; r < 256; r += 4) for (c = 0; c < 256; c += 4) DrawPixel(ClrFromRGB(0, c, r)); SetPixelBox(64, 64, 127, 79, true); for (r = 0; r < 16; ++r) for (c = 0; c < 256; c += 4) DrawPixel(ClrFromRGB(c, 0, 0)); SetPixelBox(64, 80, 127, 95, true); for (r = 0; r < 16; ++r) for (c = 0; c < 256; c += 4) DrawPixel(ClrFromRGB(0, c, 0)); SetPixelBox(64, 96, 127, 111, true); for (r = 0; r < 16; ++r) for (c = 0; c < 256; c += 4) DrawPixel(ClrFromRGB(0, 0, c)); SetPixelBox(64, 112, 127, 127, true); for (r = 0; r < 16; ++r) for (c = 0; c < 256; c += 4) DrawPixel(ClrFromRGB(c, c, c)); WaitMs(1000); }
/*---------------------------------------------------------------------- * Get a key from the input device. */ int GetKey(void) { int key; //First clear Rx buffer UART_FifoReset(UARTX,UART_RxFIFO); //then waiting for user input while (1) { WaitMs(50); if (SerialKeyPressed((char*)&key)) break; // //if there is another input, we may check that. // } return key; }
void DrawTest(void){ uint32_t h,v; uint16_t dark = 0; uint32_t c = 0; uint16_t col = 0; uint32_t pixel = 0; DrawBox(0,0,0,HLEN-1,VLEN-1); /* DrawHLine(-1,0,0,20);*/ /* DrawBox(0xAA,270,190,370,290);*/ // DrawHLine(0x55,0,0,HLEN-1); //DrawHLine(0x55,VLEN-1,0,HLEN-1); DrawVLine(0x55,0,0,VLEN-1); DrawVLine(0x55,HLEN-1,0,VLEN-1); WaitMs(100); for (h = 0; h < HLEN; ++h) { pixel++; if (pixel == 10){ pixel = 0; dark++; } if (dark == 16) { c++; dark = 0; } if (c == 4) { c = 0; } col = 0; switch (c) { case 0: col = (dark << 1); break; case 1: col = (dark << 7); break; case 2: col = (dark << 12); break; case 3: col = (dark << 1) | (dark << 7) | (dark << 12); break; } DrawPoint(col,h,0); } for (v = 1; v < VLEN; ++v) { DrawCopyHLine(v-1,v); } }
char ReceiveChar(uart_regs * uart, uint32_t TimeoutMs, uint32_t *error){ uint32_t i = 0; uint32_t tempTail; uint32_t Idx = GetUartIdx(uart); while (UartData[Idx].RxIdxHead == UartData[Idx].RxIdxTail){ if (i == TimeoutMs){ *error = 1; return 0; } i++; WaitMs(1); } /* calculate new buffer index */ tempTail = ((UartData[Idx].RxIdxTail + 1) & (UART_RX_BUFFER_SIZE - 1)); UartData[Idx].RxIdxTail = tempTail; /* read item */ return UartData[Idx].RxBuf[tempTail]; }
void DrawColorBars() { int r, c; ClearScreen(); SetPixelBox(0, 0, 39, 127, true); for(r = 0; r < 256; r += 2) for (c = 0; c < 40; ++c) DrawPixel(ClrFromRGB(0, r, 0)); SetPixelBox(44, 0, 83, 127, true); for(r = 0; r < 256; r += 2) for (c = 0; c < 40; ++c) DrawPixel(ClrFromRGB(r, 0, 0)); SetPixelBox(88, 0, 127, 127, true); for(r = 0; r < 256; r += 2) for (c = 0; c < 40; ++c) DrawPixel(ClrFromRGB(0, 0, r)); WaitMs(1000); }
// Initialize hardware key scan (GPIO) operation. VOID AdcKeyScanInit(VOID) { AdcKeyState = ADC_KEY_STATE_IDLE; TimeOutSet(&AdcKeyScanTimer, 0); #ifdef AU6210K_NR_D_8_CSRBT SET_B6_ANALOG_IN(); #endif #ifdef ADC_KEY_PORT_CH1 #if (ADC_KEY_PORT_CH1 == ADC_CHANNEL_B6) SET_B6_ANALOG_IN(); #endif #if (ADC_KEY_PORT_CH1 == ADC_CHANNEL_D7) SET_D7_ANALOG_IN(); #endif #if (ADC_KEY_PORT_CH1 == ADC_CHANNEL_E0) SET_E0_ANALOG_IN(); #endif #if (ADC_KEY_PORT_CH1 == ADC_CHANNEL_E1) SET_E1_ANALOG_IN(); #endif #endif #ifdef ADC_KEY_PORT_CH2 #if (ADC_KEY_PORT_CH2 == ADC_CHANNEL_B6) SET_B6_ANALOG_IN(); #endif #if (ADC_KEY_PORT_CH2 == ADC_CHANNEL_D7) SET_D7_ANALOG_IN(); #endif #if (ADC_KEY_PORT_CH2 == ADC_CHANNEL_E0) SET_E0_ANALOG_IN(); #endif #if (ADC_KEY_PORT_CH2 == ADC_CHANNEL_E1) SET_E1_ANALOG_IN(); #endif #endif #ifdef HEADPHONE_ADC_PORT_CH #if (HEADPHONE_ADC_PORT_CH == ADC_CHANNEL_B6) SET_B6_ANALOG_IN(); #endif #if (HEADPHONE_ADC_PORT_CH == ADC_CHANNEL_D7) SET_D7_ANALOG_IN(); #endif #if (HEADPHONE_ADC_PORT_CH == ADC_CHANNEL_E0) SET_E0_ANALOG_IN(); #endif #if (HEADPHONE_ADC_PORT_CH == ADC_CHANNEL_E1) SET_E1_ANALOG_IN(); #endif #endif #ifdef AU6210K_ZB_BT007_CSR baGPIOCtrl[GPIO_D_IE] &= ~0x20;//D5 baGPIOCtrl[GPIO_D_OE] |= 0x20; baGPIOCtrl[GPIO_D_PU] |= 0x20; baGPIOCtrl[GPIO_D_PD] |= 0x20; baGPIOCtrl[GPIO_D_OUT] &= ~0x10; WaitMs(2); baGPIOCtrl[GPIO_D_IE] &= ~0x40;//D6 baGPIOCtrl[GPIO_D_OE] |= 0x40; baGPIOCtrl[GPIO_D_PU] |= 0x40; baGPIOCtrl[GPIO_D_PD] |= 0x40; baGPIOCtrl[GPIO_D_OUT] &= ~0x40; WaitMs(2); baGPIOCtrl[GPIO_A_IE] &= ~0x04;//A2 baGPIOCtrl[GPIO_A_OE] |= 0x04; baGPIOCtrl[GPIO_A_PU] |= 0x04; baGPIOCtrl[GPIO_A_PD] |= 0x04; baGPIOCtrl[GPIO_A_OUT] &= ~0x04; WaitMs(2); baGPIOCtrl[GPIO_A_IE] &= ~0x02;//A2 baGPIOCtrl[GPIO_A_OE] |= 0x02; baGPIOCtrl[GPIO_A_PU] |= 0x02; baGPIOCtrl[GPIO_A_PD] |= 0x02; baGPIOCtrl[GPIO_A_OUT] &= ~0x02; WaitMs(2); DBG1(("dfdfd")); #endif }
/* set the start line for the display; the code in this project uses this property to adjust so that the first row displayed is row 0; so, you probably want to use SetRowOffset for a scrolling effect */ void SetStartLine(uchar b) { WriteCmd(ocStartLine); WriteData(b); WaitMs(5); }
/* shift the display so the specified row is at the top of the screen */ void SetRowOffset(uchar b) { WriteCmd(ocOffset); WriteData(b); WaitMs(5); }
bool LineInControl(void) { uint16_t Msg = 0; SW_TIMER LineInTimer; APP_DBG("Enter LineInControl...\n"); if(!IsLineInLink()) { APP_DBG("Exit LineInControl...\n"); return TRUE; } #ifndef FUNC_MIXER_SRC_EN AudioSampleRateSet(44100); #endif SoundRemind(SOUND_LINEIN); #ifdef FUNC_TREB_BASS_EN if(gSys.EqStatus == 0) { TrebBassSet(gSys.TrebVal, gSys.BassVal); } #endif if(gSys.MicEnable) { MixerMute(MIXER_SOURCE_ANA_MONO); MixerMute(MIXER_SOURCE_MIC); } else { MixerMute(MIXER_SOURCE_ANA_STERO); } WaitMs(20); AudioAnaSetChannel(gSys.MicEnable ? AUDIO_CH_MIC_LINEIN : AUDIO_CH_LINEIN); if(gSys.MicEnable) { MixerUnmute(MIXER_SOURCE_ANA_MONO); MixerUnmute(MIXER_SOURCE_MIC); } else { MixerUnmute(MIXER_SOURCE_ANA_STERO); } // ÏûÏ¢×¢²á if(gSys.MuteFlag) { gSys.MuteFlag = 0; AudioPlayerMute(gSys.MuteFlag); } InitTimer(&LineInTimer, 250, LineInLedCb); StartTimer(&LineInTimer); AudioSysInfoSetBreakPoint(); SetModeSwitchState(MODE_SWITCH_STATE_DONE); while(Msg != MSG_COMMON_CLOSE) { //led light timer CheckTimer(&LineInTimer); Msg = MsgRecv(5); switch(Msg) { case MSG_MODE: //working mode changing Msg = MSG_COMMON_CLOSE; break; case MSG_POWER: gSys.NextModuleID = MODULE_ID_STANDBY; Msg = MSG_COMMON_CLOSE; break; #ifdef FUNC_RECORD_EN case MSG_REC: //¼Òô gSys.ModuleIDBackUp = gSys.CurModuleID; gSys.NextModuleID = MODULE_ID_RECORDER; gSys.RecordState = RECORD_STATE_REC; gSys.RecordSource = RECORD_SOURCE_LINEIN; Msg = MSG_COMMON_CLOSE; break; #endif #ifdef FUNC_REC_PLAYBACK_EN case MSG_REC_PLAYBACK: EnterRecBackPlay(gSys.CurModuleID, IsUDiskLink() ? DEV_ID_USB : DEV_ID_SD, TRUE, 0, 0); break; #endif default: CommonMsgProccess(Msg); break; } } #if (defined(FUNC_BREAKPOINT_EN) && (defined(FUNC_USB_EN) || defined(FUNC_CARD_EN))) { BP_SYS_INFO *pBpSysInfo; pBpSysInfo = (BP_SYS_INFO *)BP_GetInfo(BP_SYS_INFO_TYPE); BP_SET_ELEMENT(pBpSysInfo->Volume, gSys.Volume); BP_SET_ELEMENT(pBpSysInfo->Eq, gSys.Eq); BP_SaveInfo(BP_SAVE2NVM); } #endif AudioAnaSetChannel(gSys.MicEnable ? AUDIO_CH_MIC : AUDIO_CH_NONE); APP_DBG("leave LineInControl...\n"); return TRUE;//OK }
const std::array<AutomatedScreenshotController::SceneSetupFunction, AutomatedScreenshotController::NumScenes> AutomatedScreenshotController::States() const { return {{ [this]() { const PlaceJumps::View::PlaceJumpModel London( "London", Eegeo::Space::LatLong::FromDegrees(51.512179, -0.080664), 162.2f, 1780.1f, ""); m_placeJumpController.JumpTo(London); m_weatherController.SetTime("Day"); m_weatherController.SetTheme("Summer"); return WaitMs(8000); }, [this]() { const long long WaitMsForInteriorToLoad = 4000; const long long MsToWaitForCameraToEnterInterior = 3000; const Eegeo::Resources::Interiors::InteriorId WestportHouseInteriorId("westport_house"); const Eegeo::Space::LatLong location(Eegeo::Space::LatLong::FromDegrees(56.460108, -2.978094)); const float distanceFromInterest = 200.f; const PlaceJumps::View::PlaceJumpModel WestportHouse( "WestportHouse", location, 312.8f, distanceFromInterest, ""); m_placeJumpController.JumpTo(WestportHouse); return Seq(WaitMs(WaitMsForInteriorToLoad), Act([=]() { m_interiorSelectionModel.SelectInteriorId(WestportHouseInteriorId); }), WaitMs(MsToWaitForCameraToEnterInterior), Act([=]() { m_cameraTransitionService.StartTransitionTo(location.ToECEF(), distanceFromInterest, WestportHouseInteriorId, 2, true); }), WaitForCameraTransition(&m_cameraTransitionService), Act([=]() { m_searchQueryPerformer.PerformSearchQuery("General", true, true); }), WaitMs(8000), Act([=]() { m_searchQueryPerformer.RequestClear(); m_searchQueryPerformer.RemoveSearchQueryResults(); }) ); }, [this]() { return IsLandscapeLayout(m_screenProperties) ? TabletVASceneSetup(true) : PhoneNYCSceneSetup(true); }, [this]() { return IsLandscapeLayout(m_screenProperties) ? TabletVASceneSetup(false) : PhoneNYCSceneSetup(false); }, [this]() { return IsLandscapeLayout(m_screenProperties) ? SelectedPinSceneSetup("Victoria and Albert Museum", 2) : SelectedPinSceneSetup("Empire State Building", 0); }, [this]() { static const std::string LightThemesManifestUrlDefault = "https://cdn-resources.wrld3d.com/mobile-themes-new/v883/ambientwhite/manifest.bin.gz"; const long long MsToWaitForSearchQueryToClear = 3000; const long long MsToWaitForThemeToLoad = 3000; const PlaceJumps::View::PlaceJumpModel SanFran( "SanFran", Eegeo::Space::LatLong::FromDegrees(37.742448, -122.446477), 27.2f, 1914.3f, ""); m_messageBus.Publish(ClosePoiMessage()); m_messageBus.Publish(SearchMenu::OpenSearchMenuMessage(false)); m_placeJumpController.JumpTo(SanFran); m_cityThemeLoader.LoadThemes(LightThemesManifestUrlDefault, "Summer", "DayDefault"); return Seq(WaitMs(MsToWaitForSearchQueryToClear), Act([=]() { m_searchQueryPerformer.RemoveSearchQueryResults(); }), WaitForStreaming(&m_cityThemeLoader), WaitMs(MsToWaitForThemeToLoad)); }, [this]() { static const std::string SciFiThemesManifestUrlDefault = "https://cdn-resources.wrld3d.com/mobile-themes-new/v883/scifi/manifest.bin.gz"; const long long MsToWaitForSearchResultsToClearAndThemeToLoad = 3000; const PlaceJumps::View::PlaceJumpModel LA( "LA", Eegeo::Space::LatLong::FromDegrees(34.051624, -118.254724), 187.6f, 1885.8f, ""); m_placeJumpController.JumpTo(LA); m_searchQueryPerformer.RemoveSearchQueryResults(); m_cityThemeLoader.LoadThemes(SciFiThemesManifestUrlDefault, "Summer", "DayDefault"); return Seq(WaitForStreaming(&m_cityThemeLoader), WaitMs(MsToWaitForSearchResultsToClearAndThemeToLoad)); } }}; }
/* restore normal operation after invert */ void NormalDisplay() { WriteCmd(ocDispNormal); WaitMs(5); // give it time to finish }
void InvertDisplay() { WriteCmd(ocDispInverse); WaitMs(5); // give it time to finish }
/* draws a rectangle (outline and fill), then inverts; this is another way to verify that the first and last row and col are set correctly; after inverting, you should see a red line all the way around the perimeter, with no gray outside it */ void DrawFullRect() { ClearScreen(); /* set all pixels, even off-screen */ DrawRectangle(0, 0, xMost, yMost, clrGray, clrGray); DrawRectangle(0, 0, xLast, yLast, clrCyan, clrBlue); WaitMs(1000); InvertDisplay(); WaitMs(1000); #ifdef NO // this can help determine the correct start line (used in init) SetStartLine(1); WaitMs(1000); SetStartLine(2); WaitMs(1000); SetStartLine(3); WaitMs(1000); SetStartLine(4); WaitMs(1000); SetStartLine(0); WaitMs(1000); SetStartLine(131); WaitMs(1000); SetStartLine(130); WaitMs(1000); SetStartLine(129); WaitMs(1000); SetStartLine(128); WaitMs(1000); SetStartLine(127); WaitMs(1000); SetStartLine(126); WaitMs(1000); SetStartLine(128); // put back to the right place! #endif NormalDisplay(); }
void Sleep(int fSleep) { WriteCmd(fSleep ? ocSleepOn : ocSleepOff); WaitMs(5); // give it time to finish }
void InitOLED() { InitOLEDLines(); /* get ready for communication */ SetControlState(); /* give OLED a little time to react to power on */ WaitMs(20); /* send reset */ ResetLow(); /* docs don't specify time required for reset, but parallel comms interface indicates that it generally only needs 60ns at level (1 op = 62.5ns at 16 MHz) */ asm("nop"); asm("nop"); ResetHigh(); WaitMs(10); // wait for reset to complete WriteCmd(ocLock); // make sure not locked WriteData(0x12); WriteCmd(ocConfig); WriteData(0x8e); // 1000 1110 -- external Vcc, internal Vcomh, Vpa/b/c /* settings command bit values, descriptions from low to high (see OLED driver doc for details): cc11 d100 -- increment horiz, SEG0=col0, reverse color CBA (RGB), [d = data bus size] COM n-1 to 0 (0 row top), enable COM split, [c = color depth] note that reversing colors is helpful for the 256-color case since that means that blue (not red) gets the 2-bit section (R/G are 3-bit) */ WriteCmd(ocSettings); #if defined(COLOR_262k) // 262k color (9-bit): 1011 1100 WriteData(0xbc); #elif defined(COLOR_65k) // 65k color (8-bit): 0111 0100 WriteData(0x74); #elif defined(COLOR_256) // 256 color (8-bit): 0011 0100 WriteData(0x34); #else #error 'color depth not defined; see OLED.h' #endif WriteCmd(ocPowerSaving); // WriteData(0x15); // external VSL, power saving WriteData(0x12); // internal VSL, power saving // WriteData(0x05); // external VSL, normal // WriteData(0); // internal VSL, normal [default] /* set the start line for the display; the code in this project uses this property to adjust so that the first row displayed is row 0; scrolling should be done using the Offset property */ WriteCmd(ocStartLine); WriteData(128); // otherwise the first row is 4... (131 => -1, so 132 - 4 = 128) #ifdef DEFAULTS /* the documented default values should be fine for these, so we don't need to set them specifically; they're listed here since they are assumed to be set to the defaults */ WriteCmd(ocMUXRatio); WriteData(131); WriteCmd(ocOffset); WriteData(0); WriteCmd(ocDispNormal); #endif /* clear screen */ ClearScreen(); /* make sure display is on */ Sleep(false); }
void AdTest(void) { #if 0 UINT16 data; printf("SPI:%X,%X,%X\n",SPI1->CR1,SPI1->CR2,SPI1->SR); //Send 0x10 AdCS(true); //Wait SPI is Not bussy. while( SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_BSY) ); //Clear Rx Buffer while(SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE) ) data = SPI_I2S_ReceiveData(SPI1); SPI_I2S_SendData(SPI1,0x10);//SpiSendByte(0x10); //Wait SPI is Not bussy. while( SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_BSY) ); //Clear Rx Buffer while( SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE) ) data = SPI_I2S_ReceiveData(SPI1); //Send Dummy to get Data SPI_I2S_SendData(SPI1,0xFF); //Wait SPI is Not bussy. while( SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_BSY) ); //Wait Rx Buffer Is not empty while(RESET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE) ); data = SPI_I2S_ReceiveData(SPI1); AdCS(false); printf("Status:0x%X\n",data); WaitMs(1); //============================================================= //Send 0x10 AdCS(true); //Wait SPI is Not bussy. while( SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_BSY) ); //Clear Rx Buffer while(SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE) ) data = SPI_I2S_ReceiveData(SPI1); SPI_I2S_SendData(SPI1,0x12); //Wait SPI is Not bussy. while( SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_BSY) ); //Clear Rx Buffer while( SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE) ) data = SPI_I2S_ReceiveData(SPI1); //Read High Byte //Send Dummy to get Data SPI_I2S_SendData(SPI1,0xFF); //Wait SPI is Not bussy. while( SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_BSY) ); //Wait Rx Buffer Is not empty while(RESET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE) ); data = SPI_I2S_ReceiveData(SPI1); //Read Low Byte //Send Dummy to get Data SPI_I2S_SendData(SPI1,0xFF); //Wait SPI is Not bussy. while( SET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_BSY) ); //Wait Rx Buffer Is not empty while(RESET==SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE) ); data = (data<<8) | SPI_I2S_ReceiveData(SPI1); AdCS(false); printf("Mode:0x%X\n",data); #else printf("Status: %X\n",AdReadData(0,1)); printf("Mode : %X\n",AdReadData(2,2)); AdWriteData(2,0x175,2); #endif }