static void checkHT1632(HT1632Class& ht1632) { static int checkCount = 0; static const int checkCountMax = 13; // TWEAK ME if (++checkCount < checkCountMax && getDisplayMode() != displayModeMessage) return; // HACK: ensure all chips are enabled and kicking, even if some // noise in the pins interface made them go out to lunch ht1632.reinit(); checkCount = 0; }
int DisplayDispatcher::setDispProp(int cmd,int param0,int param1,int param2) { switch(cmd) { case DISPLAY_CMD_SETDISPPARA: return setDisplayParameter(param0,param1,param2); case DISPLAY_CMD_CHANGEDISPMODE: return changeDisplayMode(param0,param1,param2); case DISPLAY_CMD_CLOSEDISP: return closeDisplay(param0); case DISPLAY_CMD_OPENDISP: return openDisplay(param0); case DISPLAY_CMD_GETDISPCOUNT: return getDisplayCount(); case DISPLAY_CMD_GETDISPLAYMODE: return getDisplayMode(); case DISPLAY_CMD_GETDISPPARA: return getDisplayParameter(param0,param1); case DISPLAY_CMD_GETHDMISTATUS: return getHdmiStatus(); case DISPLAY_CMD_GETMASTERDISP: return getMasterDisplay(); case DISPLAY_CMD_GETMAXHDMIMODE: return getMaxHdmiMode(); case DISPLAY_CMD_GETMAXWIDTHDISP: return getMaxWidthDisplay(); case DISPLAY_CMD_GETTVSTATUS: return getTvDacStatus(); case DISPLAY_CMD_SETMASTERDISP: return setMasterDisplay(param0); case DISPLAY_CMD_SETDISPMODE: return setDisplayMode(param0); default: LOGE("Display Cmd not Support!\n"); return -1; } }
D3DPRESENT_PARAMETERS D3DeviceFactory::getDefaultPresentParameters(HWND hwnd, UINT adapter) { // static D3DPRESENT_PARAMETERS param; ZeroMemory(¶m, sizeof(param)); const CSize winSize = getClientRect(hwnd).Size(); const D3DDISPLAYMODE displayMode = getDisplayMode(adapter); param.Windowed = TRUE; param.SwapEffect = D3DSWAPEFFECT_DISCARD; param.EnableAutoDepthStencil = TRUE; param.AutoDepthStencilFormat = D3DFMT_D16; param.BackBufferFormat = displayMode.Format; param.BackBufferWidth = winSize.cx; param.BackBufferHeight = winSize.cy; param.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; return param; }
void Pulsars::saveSettingsToConfig(void) { conf->beginGroup("Pulsars"); conf->setValue("url", updateUrl); conf->setValue("update_frequency_days", updateFrequencyDays); conf->setValue("updates_enabled", updatesEnabled); conf->setValue("distribution_enabled", getDisplayMode()); conf->setValue("use_separate_colors", getGlitchFlag()); conf->setValue("filter_enabled", getFilteredMode()); conf->setValue("filter_value", QString::number(getFilterValue(), 'f', 2)); conf->setValue("enable_at_startup", enableAtStartup); conf->setValue("flag_show_pulsars_button", flagShowPulsarsButton); conf->setValue("marker_color", StelUtils::vec3fToStr(getMarkerColor())); conf->setValue("glitch_color", StelUtils::vec3fToStr(getGlitchColor())); conf->endGroup(); }
void Lamp::update() { // drawMenu(menuPosition()); doLed(); if (idleMetro.check()==1) { drawMenu(menuPosition()); _idleTime++; if (_idleTime==10) updateMenuIndex('t'); } if (clkMetro.check()==1) getDate(); if (!_alarming) { switch (getDisplayMode()) { case lAUDIO: drawAudio(); break; case lCYCLE: drawCycle(); break; case lRANDOM: drawRandom(); break; case lSOLID: drawSolid(); break; default: break; } } else { drawAlarm(); } }
void GLUTCanvas::init() { glutInitDisplayMode(getDisplayMode()); atexit(onExitFunction); // FIXME: sholdn't this be part of GLUTApplication?? glutInitWindowSize(size_.x, size_.y); glutCreateWindow(title_.c_str()); windowID_ = glutGetWindow(); Canvases_[windowID_] = this; registerCallbacks(); rgbaSize_ = ivec4(glutGet(GLUT_WINDOW_RED_SIZE), glutGet(GLUT_WINDOW_GREEN_SIZE), glutGet(GLUT_WINDOW_BLUE_SIZE), glutGet(GLUT_WINDOW_ALPHA_SIZE)) ; stencilSize_ = glutGet(GLUT_WINDOW_STENCIL_SIZE); depthSize_ = glutGet(GLUT_WINDOW_DEPTH_SIZE); doubleBuffered_ = (0 != glutGet(GLUT_WINDOW_DOUBLEBUFFER)); stereoViewing_ = (0 != glutGet(GLUT_WINDOW_STEREO)); GLCanvas::init(); }
bool start( unsigned preroll ) { m_displayMode = getDisplayMode(); if ( !m_displayMode ) { mlt_log_error( &m_consumer, "Profile is not compatible with decklink.\n" ); return false; } // Set the video output mode if ( S_OK != m_deckLinkOutput->EnableVideoOutput( m_displayMode->GetDisplayMode(), bmdVideoOutputFlagDefault) ) { mlt_log_error( &m_consumer, "Failed to enable video output\n" ); return false; } // Set the audio output mode m_channels = 2; if ( S_OK != m_deckLinkOutput->EnableAudioOutput( bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, m_channels, bmdAudioOutputStreamContinuous ) ) { mlt_log_error( &m_consumer, "Failed to enable audio output\n" ); stop(); return false; } m_fifo = sample_fifo_init(); // Preroll m_isPrerolling = true; m_prerollCounter = 0; m_preroll = preroll < PREROLL_MINIMUM ? PREROLL_MINIMUM : preroll; m_count = 0; m_deckLinkOutput->BeginAudioPreroll(); return true; }
bool IntelHWComposerDrm::detectDrmModeInfo() { ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: detecting drm mode info...\n", __func__); if (mDrmFd < 0) { ALOGE("%s: invalid drm FD\n", __func__); return false; } /*try to get drm resources*/ drmModeResPtr resources = drmModeGetResources(mDrmFd); if (!resources || !resources->connectors) { ALOGE("%s: fail to get drm resources. %s\n", __func__, strerror(errno)); return false; } /*get mipi0 info*/ drmModeConnectorPtr connector = NULL; drmModeEncoderPtr encoder = NULL; drmModeCrtcPtr crtc = NULL; drmModeConnectorPtr connectors[OUTPUT_MAX]; drmModeModeInfoPtr mode = NULL; drmModeFBPtr fbInfo = NULL; for (int i = 0; i < resources->count_connectors; i++) { connector = drmModeGetConnector(mDrmFd, resources->connectors[i]); if (!connector) { ALOGW("%s: fail to get drm connector\n", __func__); continue; } int outputIndex = -1; if (connector->connector_type == DRM_MODE_CONNECTOR_MIPI || connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: got MIPI/LVDS connector\n", __func__); if (connector->connector_type_id == 1) outputIndex = OUTPUT_MIPI0; else if (connector->connector_type_id == 2) outputIndex = OUTPUT_MIPI1; else { ALOGW("%s: unknown connector type\n", __func__); outputIndex = OUTPUT_MIPI0; } } else if (connector->connector_type == DRM_MODE_CONNECTOR_DVID) { ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: got HDMI connector\n", __func__); outputIndex = OUTPUT_HDMI; } /*update connection status*/ setOutputConnection(outputIndex, connector->connection); /*get related encoder*/ encoder = drmModeGetEncoder(mDrmFd, connector->encoder_id); if (!encoder) { ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: fail to get drm encoder\n", __func__); drmModeFreeConnector(connector); setOutputConnection(outputIndex, DRM_MODE_DISCONNECTED); continue; } /*get related crtc*/ crtc = drmModeGetCrtc(mDrmFd, encoder->crtc_id); if (!crtc) { ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: fail to get drm crtc\n", __func__); drmModeFreeEncoder(encoder); drmModeFreeConnector(connector); setOutputConnection(outputIndex, DRM_MODE_DISCONNECTED); continue; } /*set crtc mode*/ setOutputMode(outputIndex, &crtc->mode, crtc->mode_valid); // get fb info fbInfo = drmModeGetFB(mDrmFd, crtc->buffer_id); if (!fbInfo) { ALOGD("%s: fail to get fb info\n", __func__); drmModeFreeCrtc(crtc); drmModeFreeEncoder(encoder); drmModeFreeConnector(connector); setOutputConnection(outputIndex, DRM_MODE_DISCONNECTED); continue; } setOutputFBInfo(outputIndex, fbInfo); /*free all crtc/connector/encoder*/ drmModeFreeFB(fbInfo); drmModeFreeCrtc(crtc); drmModeFreeEncoder(encoder); drmModeFreeConnector(connector); } drmModeFreeResources(resources); drmModeConnection mipi0 = getOutputConnection(OUTPUT_MIPI0); drmModeConnection mipi1 = getOutputConnection(OUTPUT_MIPI1); drmModeConnection hdmi = getOutputConnection(OUTPUT_HDMI); detectMDSModeChange(); ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: mipi/lvds %s, mipi1 %s, hdmi %s, displayMode %d\n", __func__, ((mipi0 == DRM_MODE_CONNECTED) ? "connected" : "disconnected"), ((mipi1 == DRM_MODE_CONNECTED) ? "connected" : "disconnected"), ((hdmi == DRM_MODE_CONNECTED) ? "connected" : "disconnected"), getDisplayMode()); return true; }
bool start( mlt_profile profile = 0 ) { if ( m_started ) return false; try { // Initialize some members m_vancLines = mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( getProducer() ), "vanc" ); if ( m_vancLines == -1 ) m_vancLines = profile->height <= 512 ? 26 : 32; if ( !profile ) profile = mlt_service_profile( MLT_PRODUCER_SERVICE( getProducer() ) ); // Get the display mode BMDDisplayMode displayMode = getDisplayMode( profile, m_vancLines ); if ( displayMode == (BMDDisplayMode) bmdDisplayModeNotSupported ) { mlt_log_info( getProducer(), "profile = %dx%d %f fps %s\n", profile->width, profile->height, mlt_profile_fps( profile ), profile->progressive? "progressive" : "interlace" ); throw "Profile is not compatible with decklink."; } // Determine if supports input format detection #ifdef WIN32 BOOL doesDetectFormat = FALSE; #else bool doesDetectFormat = false; #endif IDeckLinkAttributes *decklinkAttributes = 0; if ( m_decklink->QueryInterface( IID_IDeckLinkAttributes, (void**) &decklinkAttributes ) == S_OK ) { if ( decklinkAttributes->GetFlag( BMDDeckLinkSupportsInputFormatDetection, &doesDetectFormat ) != S_OK ) doesDetectFormat = false; SAFE_RELEASE( decklinkAttributes ); } mlt_log_verbose( getProducer(), "%s format detection\n", doesDetectFormat ? "supports" : "does not support" ); // Enable video capture BMDPixelFormat pixelFormat = bmdFormat8BitYUV; BMDVideoInputFlags flags = doesDetectFormat ? bmdVideoInputEnableFormatDetection : bmdVideoInputFlagDefault; if ( S_OK != m_decklinkInput->EnableVideoInput( displayMode, pixelFormat, flags ) ) throw "Failed to enable video capture."; // Enable audio capture BMDAudioSampleRate sampleRate = bmdAudioSampleRate48kHz; BMDAudioSampleType sampleType = bmdAudioSampleType16bitInteger; int channels = mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( getProducer() ), "channels" ); if ( S_OK != m_decklinkInput->EnableAudioInput( sampleRate, sampleType, channels ) ) throw "Failed to enable audio capture."; // Start capture m_dropped = 0; mlt_properties_set_int( MLT_PRODUCER_PROPERTIES( getProducer() ), "dropped", m_dropped ); m_started = m_decklinkInput->StartStreams() == S_OK; if ( !m_started ) throw "Failed to start capture."; } catch ( const char *error ) { m_decklinkInput->DisableVideoInput(); mlt_log_error( getProducer(), "%s\n", error ); return false; } return true; }
void Lamp::drawMenu(unsigned long index) { //Serial.println("Draw"); unsigned char almhr; almhr= getAlarmHour(); unsigned char almmn; almmn = getAlarmMin(); bool almAM; almAM = getAlarmAM(); bool almOn; almOn = getAlarmOn(); byte dspMode = getDisplayMode(); byte lmpbr = getLampBrightness(); byte lcdbr = getLCDBrightness(); // byte lcdsl = getLCDSleepTime(); // byte audfs = getAudioFadeSpeed(); byte cych = getCycleHoldTime(); byte cycf = getCycleFadeTime(); byte cycs = getCycleSteps(); byte rndh = getRandomHoldTime(); byte rndf = getRandomFadeTime(); byte solh = getColorHue(); byte sols = getColorSat(); char strSec[5] = "sec."; char strON[3] = "ON"; char strOFF[4] = "OFF"; char strAM[5] = " AM"; char strPM[5] = " PM"; char strPad0[2] = "0"; char strBr[11] = "Brightness"; char strHT[11] = "Hold Time"; char strFT[11] = "Fade Time"; char strST[7] = "Steps"; char strTimeH[15] = "Hour Min AM/PM"; char strDateH[14] = "d. D. M. Y."; char strBL[10] = "Backlight"; char* weekdayStr[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat","ERR"}; char* monthStr[] = {"","Jan", "Feb", "Mar","Apr","May","Jun", "Jul","Aug", "Sep","Oct","Nov","Dec","ERR"}; goTo(0); hideCursor(); clearLCD(); // selectLineOne(); switch (index) { case 0x000000: //Main menu // Serial1.println("03:28 PM Alm."); // Serial1.println("Mon Nov 10 2012 "); if (tHour12 < 10) Serial1.print(strPad0); Serial1.print(tHour12); Serial1.print(":"); if (tMinute < 10) Serial1.print(strPad0); Serial1.print(tMinute); if(tHour<12) Serial1.print(strAM); if(tHour>=12)Serial1.print(strPM); if(almOn) Serial1.print(" Alm."); if(!almOn) Serial1.print(""); selectLineTwo(); Serial1.print(weekdayStr[tDay]); Serial1.print(" "); Serial1.print(monthStr[tMonth]); Serial1.print(" "); Serial1.print(tDate); Serial1.print(" "); Serial1.print(tYear +2000); break; case 0x000001: //Clock Settings Serial1.print("Clock Settings"); // Serial1.println(""); break; case 0x000002: //Lamp Settings Serial1.print("Lamp Settings"); // selectLineTwo(); // Serial1.println(""); break; case 0x000011: //set Date/time top menu Serial1.print("Set Date/Time"); selectLineTwo(); if (tHour12 < 10) Serial1.print(strPad0); Serial1.print(tHour12); Serial1.print(":"); if(tMinute < 10) Serial1.print(strPad0); Serial1.print(tMinute); if(tHour<12) Serial1.print("AM "); if(tHour>=12) Serial1.print("PM "); Serial1.print(tDate); Serial1.print("/"); Serial1.print(tMonth); Serial1.print("/"); Serial1.print(tYear); break; case 0x000012: //Set Display mode top menu Serial1.print("Dispay Mode"); selectLineTwo(); if (dspMode==0) Serial1.print("Audio Viz."); if (dspMode==1) Serial1.print("Cycle"); if (dspMode==2) Serial1.print("Random"); if (dspMode==3) Serial1.print("Solid"); break; case 0x000021: //set Alarm top menu Serial1.print("Set Alarm"); selectLineTwo(); //Serial1.print("07:00AM OFF"); if (almhr < 10) Serial1.print(strPad0); Serial1.print(almhr); Serial1.print(":"); if(almmn < 10) Serial1.print(strPad0); Serial1.print(almmn); if(almAM) Serial1.print(strAM); if(!almAM)Serial1.print(strPM); if(almOn) { Serial1.print(" "); Serial1.print(strON); } if(!almOn) { Serial1.print(" "); Serial1.print(strOFF); } break; case 0x000022: //Set Brightness top menu Serial1.print(strBr); selectLineTwo(); Serial1.print(lmpbr,DEC); break; case 0x000032: //set LCD Backlight top menu Serial1.print(strBL); selectLineTwo(); Serial1.print(lcdbr,DEC); break; case 0x000111: //set clock time / current time Serial1.print(strTimeH); selectLineTwo(); if (tHour12 < 10) Serial1.print(strPad0); Serial1.print(tHour12); Serial1.print(" "); if(tMinute < 10) Serial1.print(strPad0); Serial1.print(tMinute); if(tHour<12) Serial1.print(strAM); if(tHour>=12) Serial1.print(strPM); break; case 0x000121: //set alarm time / current time Serial1.print(strTimeH); selectLineTwo(); if (almhr < 10) Serial1.print(strPad0); Serial1.print(almhr); Serial1.print(" "); if(almmn < 10) Serial1.print(strPad0); Serial1.print(almmn); if(almAM) Serial1.print(strAM); if(!almAM) Serial1.print(strPM); break; case 0x000122: //Set lamp Brigthness //should display cursor Serial1.print(strBr); selectLineTwo(); Serial1.print(lmpbr,DEC); showCursor(); goTo(18); break; case 0x000132: //set lcd backlight brightness //should display cursor Serial1.print(strBL); selectLineTwo(); Serial1.print(lcdbr,DEC); // showCursor(); goTo(17); break; case 0x000211: //set clock date menu Serial1.print(strDateH); selectLineTwo(); Serial1.print(weekdayStr[tDay]); Serial1.print(" "); Serial1.print(tDate); Serial1.print(" "); Serial1.print(monthStr[tMonth]); Serial1.print(" "); Serial1.print(tYear); break; case 0x000212: //Cycle display mode Serial1.print("Cycle"); break; case 0x000221: //set alarm on/off menu Serial1.print("Alarm"); selectLineTwo(); if (almOn) Serial1.print(strON); if (!almOn) Serial1.print(strOFF); break; case 0x000312: //random color display mode Serial1.print("Random"); // Serial1.print(""); break; case 0x000412: //solid color display mode Serial1.print("Solid"); // Serial1.print(""); break; case 0x001111: //set clock time / set hour //show cursor at hour Serial1.print(strTimeH); selectLineTwo(); if (tHour12 < 10) Serial1.print(strPad0); Serial1.print(tHour12); Serial1.print(" "); if(tMinute < 10) Serial1.print(strPad0); Serial1.print(tMinute); if(tHour<12) Serial1.print(strAM); if(tHour>=12) Serial1.print(strPM); showCursor(); goTo(17); break; case 0x001121: //set alarm time / hour //show cursor at hour Serial1.print(strTimeH); selectLineTwo(); if (almhr < 10) Serial1.print(strPad0); Serial1.print(almhr); Serial1.print(" "); if(almmn < 10) Serial1.print(strPad0); Serial1.print(almmn); if(almAM) Serial1.print(strAM); if(!almAM) Serial1.print(strPM); showCursor(); goTo(17); break; case 0x001211: //set clock date / day of week //show cursor at d o w Serial1.print(strDateH); selectLineTwo(); //Serial1.print("Mon 3_ Dec 12"); Serial1.print(weekdayStr[tDay]); Serial1.print(" "); Serial1.print(tDate); Serial1.print(" "); Serial1.print(monthStr[tMonth]); Serial1.print(" "); Serial1.print(tYear); showCursor(); goTo(18); break; case 0x001212: //set Cycle hold time //show cursor Serial1.print(strHT); selectLineTwo(); Serial1.print(cych,DEC); Serial1.print(strSec); showCursor(); goTo(17); break; case 0x001221: //set alarm on / off //show cursor Serial1.print("Alarm"); selectLineTwo(); if (almOn) Serial1.print(strON); if (!almOn) Serial1.print(strOFF); showCursor(); goTo(18); break; case 0x001312: //set random mode holde time //show cursor Serial1.print(strHT); selectLineTwo(); Serial1.print(rndh,DEC); Serial1.print(strSec); showCursor(); goTo(17); break; case 0x001412: //set solid mode Hue //show cursor Serial1.print("Hue"); selectLineTwo(); Serial1.print(solh,DEC); showCursor(); goTo(19); break; case 0x002111: //set clock time / min //show curso at min Serial1.print(strTimeH); selectLineTwo(); if (tHour12 < 10) Serial1.print(strPad0); Serial1.print(tHour12); Serial1.print(" "); if(tMinute < 10) Serial1.print(strPad0); Serial1.print(tMinute); if(tHour<12) Serial1.print(strAM); if(tHour>=12) Serial1.print(strPM); showCursor(); goTo(22); break; case 0x002121: //set alarm time / min //show cursor at min Serial1.print(strTimeH); selectLineTwo(); if (almhr < 10) Serial1.print(strPad0); Serial1.print(almhr); Serial1.print(" "); if(almmn < 10) Serial1.print(strPad0); Serial1.print(almmn); if(almAM) Serial1.print(strAM); if(!almAM)Serial1.print(strPM); showCursor(); goTo(22); break; case 0x002211: //set clock date / day //show cursor at day Serial1.print(strDateH); //Serial1.print("Mon 3_ Dec 12"); selectLineTwo(); Serial1.print(weekdayStr[tDay]); Serial1.print(" "); Serial1.print(tDate); Serial1.print(" "); Serial1.print(monthStr[tMonth]); Serial1.print(" "); Serial1.print(tYear); showCursor(); goTo(21); break; case 0x002212: //set cycle mode fade time //show cursor Serial1.print(strFT); selectLineTwo(); Serial1.print(cycf,DEC); Serial1.print(strSec); showCursor(); goTo(17); break; case 0x003212: //set cycle mode steps //show cursor Serial1.print(strST); selectLineTwo(); Serial1.print(cycs,DEC); showCursor(); goTo(18); break; case 0x002312: //set randome mode fade time //show cursor Serial1.print(strFT); selectLineTwo(); Serial1.print(rndf,DEC); Serial1.print(strSec); showCursor(); goTo(17); break; case 0x002412: //set solid mode color sat //show cursor Serial1.print("Saturation"); selectLineTwo(); Serial1.print(sols,DEC); showCursor(); goTo(18); break; case 0x003111: //set clock time am/pm //show cursor Serial1.print(strTimeH); selectLineTwo(); if (tHour12 < 10) Serial1.print(strPad0); Serial1.print(tHour12); Serial1.print(" "); if(tMinute < 10) Serial1.print(strPad0); Serial1.print(tMinute); if(tHour<12) Serial1.print(strAM); if(tHour>=12) Serial1.print(strPM); showCursor(); goTo(26); break; case 0x003121: //set alarm am/pm //show cursor at AM Serial1.print(strTimeH); selectLineTwo(); if (almhr < 10) Serial1.print(strPad0); Serial1.print(almhr); Serial1.print(" "); if(almmn < 10) Serial1.print(strPad0); Serial1.print(almmn); if(almAM) Serial1.print(strAM); if(!almAM)Serial1.print(strPM); showCursor(); goTo(26); break; case 0x003211: //set clock date / month //show cursor at month Serial1.print(strDateH); selectLineTwo(); Serial1.print(weekdayStr[tDay]); Serial1.print(" "); Serial1.print(tDate); Serial1.print(" "); Serial1.print(monthStr[tMonth]); Serial1.print(" "); Serial1.print(tYear); showCursor(); goTo(25); break; case 0x004211: //set clock date / year //show cursor at year Serial1.print(strDateH); selectLineTwo(); Serial1.print(weekdayStr[tDay]); Serial1.print(" "); Serial1.print(tDate); Serial1.print(" "); Serial1.print(monthStr[tMonth]); Serial1.print(" "); Serial1.print(tYear); showCursor(); goTo(28); break; default: break; } // backLightBr(getLCDBrightness()); }
void Lamp::updateMenuIndex(unsigned char dir) { switch (dir) { case 't': //top this->_menuIndex=0x0; this->_menuDepth=0x0; break; case 'c': //set time if(menuPosition()==0x0) break; if (menuPosition()==0x1111 || menuPosition()==0x2111 || menuPosition()==0x3111 || menuPosition()==0x1211 || menuPosition()==0x2211 || menuPosition()==0x3211 || menuPosition()==0x4211) { if (menuPosition() == 0x3111) this->_menuIndex = 0x1111; else if (menuPosition() == 0x4211) this->_menuIndex = 0x1211; else this->_menuIndex = this->_menuIndex + (1 << menuDepth()); break; } //set alarm if (menuPosition()==0x1121 || menuPosition()==0x2121 || menuPosition()==0x3121 || menuPosition()==0x1221) { if (menuPosition() == 0x3121) this->_menuIndex = 0x1121; else if (menuPosition() == 0x1221) this->_menuIndex = 0x1221; else this->_menuIndex = this->_menuIndex + (1 << menuDepth()); break; } //brightness / LCD backlight / lcd sleep time if (menuPosition() == 0x122 || menuPosition() == 0x132 || menuPosition() == 0x142) { break; } //AudioViz if (menuPosition()==0x1112) break; if (menuPosition()==0x12) { this->_menuDepth +=4; //ignore 0x112 replace with 0x212; if (getDisplayMode()==0) this->_menuIndex = 0x212; if (getDisplayMode()==1) this->_menuIndex = 0x212; if (getDisplayMode()==2) this->_menuIndex = 0x312; if (getDisplayMode()==3) this->_menuIndex = 0x412; break; } //Cycle if (menuPosition()==0x1212 || menuPosition()==0x2212 || menuPosition()==0x3212) { if (menuPosition() == 0x1212) this->_menuIndex = 0x2212; else if (menuPosition() == 0x2212) this->_menuIndex = 0x3212; else if (menuPosition() == 0x3212) this->_menuIndex = 0x1212; break; } //Random if (menuPosition()==0x1312 || menuPosition()==0x2312) { if (menuPosition() == 0x1312) this->_menuIndex = 0x2312; else if (menuPosition() == 0x2312) this->_menuIndex = 0x1312; break; } //Solid if (menuPosition()==0x1412 || menuPosition()==0x2412) { if (menuPosition() == 0x1412) this->_menuIndex = 0x2412; else if (menuPosition() == 0x2412) this->_menuIndex = 0x1412; break; } this->_menuDepth +=4; this-> _menuIndex = this->_menuIndex + (1 << menuDepth()); //ignore set weekday // if (menuPosition() == 0x1211) this->_menuIndex = 0x2211; break; case 'h': if (_alarming == true) _alarming = false; if (menuDepth() == 0x0) { this->_menuIndex=0x0; break; } this->_menuIndex =this->_menuIndex - (this->_menuCurrent << menuDepth()); this->_menuDepth -=4; break; //Going Left case 'l': //Clock if (menuPosition()==0x1111 || menuPosition()==0x2111 || menuPosition()==0x3111 || menuPosition()==0x1211 || menuPosition()==0x2211 || menuPosition()==0x3211 || menuPosition()==0x4211) { if (menuPosition()==0x01111 && tHour >0 ) tHour-- ; else if (menuPosition()==0x01111 && tHour ==0 ) tHour = 23; //hour if (menuPosition()==0x02111 && tMinute >0 ) tMinute-- ; else if (menuPosition()==0x02111 && tMinute ==0 ) tMinute = 59; //min if (menuPosition()==0x03111 && tHour >=12) tHour-=12; //am if (menuPosition()==0x01211 && tDay>0 ) tDay-- ; else if (menuPosition()==0x01211 && tDay ==0 ) tDay==6; //day if (menuPosition()==0x02211 && tDate >1 ) tDate-- ; else if (menuPosition()==0x02211 && tDate ==1 ) tDate==31; //day if (menuPosition()==0x03211 && tMonth >1 ) tMonth-- ; else if (menuPosition()==0x03211 && tMonth ==1 ) tMonth=12; //month if (menuPosition()==0x04211 && tYear >0 ) tYear-- ; else if (menuPosition()==0x04211 && tYear ==0 ) tYear=99; //year setDateTime(); break; } //Alarm if (menuPosition()==0x1121 || menuPosition()==0x2121 || menuPosition()==0x3121 || menuPosition()==0x1221) { if (menuPosition()==0x1121 && getAlarmHour() >1 ) setAlarmHour(getAlarmHour() - 1 ); else if (menuPosition()==0x1121 && getAlarmHour()==1) setAlarmHour(12); if (menuPosition()==0x2121 && getAlarmMin() >0 ) setAlarmMin(getAlarmMin() - 1 ); else if (menuPosition()==0x2121 && getAlarmMin()==0) setAlarmMin(59); if (menuPosition()==0x3121) setAlarmAM(true); if (menuPosition()==0x1221) setAlarmOn(false); break; } //brightness / LCD backlight / lcd sleep time if (menuPosition() == 0x122 || menuPosition() == 0x132 || menuPosition() == 0x142) { if (menuPosition()==0x122 && getLampBrightness()>1) setLampBrightness(getLampBrightness() - 1); if (menuPosition()==0x132 && getLCDBrightness()>1) setLCDBrightness(getLCDBrightness() - 1); // if (menuPosition()==0x142 && getLCDSleepTime()>10) setLCDSleepTime(getLCDSleepTime() - 1); delay(5); break; } //AudioViz Fade Speed // if (menuPosition()==0x1112) // { // if (getAudioFadeSpeed() >1 ) setAudioFadeSpeed(getAudioFadeSpeed()-1); // break; // } //Cycle if (menuPosition()==0x1212 || menuPosition()==0x2212 || menuPosition()==0x3212) { if (menuPosition()==0x1212 && getCycleHoldTime() >1 ) setCycleHoldTime(getCycleHoldTime() - 1 ); if (menuPosition()==0x2212 && getCycleFadeTime() >1 ) setCycleFadeTime(getCycleFadeTime() - 1 ); if (menuPosition()==0x3212 && getCycleSteps() >1 ) setCycleSteps(getCycleSteps() - 1 ); break; } //Random if (menuPosition()==0x1312 || menuPosition()==0x2312) { if (menuPosition()==0x1312 && getRandomHoldTime() >1 ) setRandomHoldTime(getRandomHoldTime() - 1 ); if (menuPosition()==0x2312 && getRandomFadeTime() >1 ) setRandomFadeTime(getRandomFadeTime() - 1 ); break; } //Solid if (menuPosition()==0x1412 || menuPosition()==0x2412) { if (menuPosition()==0x1412 && getColorHue() >0 ) setColorHue(getColorHue() - 1 ); if (menuPosition()==0x2412 && getColorSat() >0 ) setColorSat(getColorSat() - 1 ); break; } //limits moving left if (menuPosition() == 0x0) this->_menuIndex = 0x2; else if (menuPosition() == 0x11) this->_menuIndex = 0x21; else if (menuPosition() == 0x111) this->_menuIndex = 0x211; else if (menuPosition() == 0x121) this->_menuIndex = 0x221; else if (menuPosition() == 0x12) this->_menuIndex = 0x32; else if (menuPosition() == 0x212) this->_menuIndex = 0x412; else this->_menuIndex = this->_menuIndex - (1 << menuDepth()); //Display Mode if (menuPosition() == 0x112) setDisplayMode(0x0); if (menuPosition() == 0x212) setDisplayMode(0x1); if (menuPosition() == 0x312) setDisplayMode(0x2); if (menuPosition() == 0x412) setDisplayMode(0x3); break; //Going right case 'r': //Clock if (menuPosition()==0x1111 || menuPosition()==0x2111 || menuPosition()==0x3111 || menuPosition()==0x1211 || menuPosition()==0x2211 || menuPosition()==0x3211 || menuPosition()==0x4211) { if (menuPosition()==0x01111 && tHour <23 ) tHour++ ; else if (menuPosition()==0x01111 && tHour ==23 ) tHour = 0; //hour if (menuPosition()==0x02111 && tMinute <59 ) tMinute++ ; else if (menuPosition()==0x02111 && tMinute ==59 ) tMinute = 0; //min if (menuPosition()==0x03111 && tHour <=12) tHour+=12; //am if (menuPosition()==0x01211 && tDay<6 ) tDay++ ; else if (menuPosition()==0x01211 && tDay ==6 ) tDay==0; //day if (menuPosition()==0x02211 && tDate <31 ) tDate++ ; else if (menuPosition()==0x02211 && tDate ==31 ) tDate==1; //day if (menuPosition()==0x03211 && tMonth <12 ) tMonth++ ; else if (menuPosition()==0x03211 && tMonth ==12 ) tMonth=1; //month if (menuPosition()==0x04211 && tYear <99 ) tYear++ ; else if (menuPosition()==0x04211 && tYear ==99 ) tYear=0; //year setDateTime(); break; } //Alarm if (menuPosition()==0x1121 || menuPosition()==0x2121 || menuPosition()==0x3121 || menuPosition()==0x1221) { if (menuPosition()==0x1121 && getAlarmHour() < 12 ) setAlarmHour(getAlarmHour() + 1 ); else if (menuPosition()==0x1121 && getAlarmHour()==12) setAlarmHour(1); if (menuPosition()==0x2121 && getAlarmMin() < 59 ) setAlarmMin(getAlarmMin() + 1 ); else if (menuPosition()==0x2121 && getAlarmMin()==59) setAlarmMin(0); if (menuPosition()==0x3121) setAlarmAM(false); if (menuPosition()==0x1221) setAlarmOn(true); break; } //brightness / LCD backlight / lcd sleep time if (menuPosition() == 0x122 || menuPosition() == 0x132 || menuPosition() == 0x142) { if (menuPosition()==0x122 && getLampBrightness()<255) setLampBrightness(getLampBrightness() + 1); if (menuPosition()==0x132 && getLCDBrightness()<26) setLCDBrightness(getLCDBrightness() + 1); // if (menuPosition()==0x142 && getLCDSleepTime()<31) setLCDSleepTime(getLCDSleepTime() + 1); delay(5); break; } //AudioViz Fade Speed // if (menuPosition()==0x1112) // { // if (getAudioFadeSpeed() < 255 ) setAudioFadeSpeed(getAudioFadeSpeed()+1); // break; // } //Cycle if (menuPosition()==0x1212 || menuPosition()==0x2212 || menuPosition()==0x3212) { if (menuPosition()==0x1212 && getCycleHoldTime() <30 ) setCycleHoldTime(getCycleHoldTime() + 1 ); if (menuPosition()==0x2212 && getCycleFadeTime() <30 ) setCycleFadeTime(getCycleFadeTime() + 1 ); if (menuPosition()==0x3212 && getCycleSteps() <128 ) setCycleSteps(getCycleSteps() + 1 ); break; } //Random if (menuPosition()==0x1312 || menuPosition()==0x2312) { if (menuPosition()==0x1312 && getRandomHoldTime() <30 ) setRandomHoldTime(getRandomHoldTime() + 1 ); if (menuPosition()==0x2312 && getRandomFadeTime() <30) setRandomFadeTime(getRandomFadeTime() + 1 ); break; } //Solid if (menuPosition()==0x1412 || menuPosition()==0x2412) { if (menuPosition()==0x1412 && getColorHue() <255 ) setColorHue(getColorHue() + 1 ); if (menuPosition()==0x2412 && getColorSat() <255 ) setColorSat(getColorSat() + 1 ); break; } //limits moving right if (menuPosition() == 0x2) this->_menuIndex = 0x0; else if (menuPosition() == 0x21) this->_menuIndex = 0x11; else if (menuPosition() == 0x211) this->_menuIndex = 0x111; else if (menuPosition() == 0x221) this->_menuIndex = 0x121; else if (menuPosition() == 0x32) this->_menuIndex = 0x12; else if (menuPosition() == 0x412) this->_menuIndex = 0x212; else this->_menuIndex = this->_menuIndex + (1 << menuDepth()); //Display Mode if (menuPosition() == 0x112) setDisplayMode(0x0); if (menuPosition() == 0x212) setDisplayMode(0x1); if (menuPosition() == 0x312) setDisplayMode(0x2); if (menuPosition() == 0x412) setDisplayMode(0x3); default: break; } this->_menuCurrent = menuPosition() >> menuDepth(); drawMenu(menuPosition()); }
void Lamp::drawCycle() { long hTime; long fTime; switch (getDisplayMode()) { case lCYCLE: hTime = getCycleHoldTime(); fTime = getCycleFadeTime(); break; case lRANDOM: hTime = getRandomHoldTime(); fTime = getRandomFadeTime(); break; default: break; } long totalCycleLen = (hTime + fTime)*1000; totalCycleLen &=0x0000FFFF; long _step = millis() % totalCycleLen; //end of cycle; if (_step >= hTime*1000 && _step <=(hTime*1000)+10 && _stepped==false) { _stepped = true; switch (getDisplayMode()) { case lCYCLE: _targetHue += getCycleSteps(); break; case lRANDOM: _targetHue += random(-getCycleSteps()*2,getCycleSteps()*2); break; default: break; } // Serial.println(_targetHue); _fadeDirection =0; _fadeSteps = 0; unsigned char _tmp = 0; unsigned char _a = _currentHue; while (_a != _targetHue) { _a++; _tmp++; } _fadeSteps = _tmp; _fadeDirection = 1; _tmp = 0; _a = _currentHue; while (_a != _targetHue) { _a--; _tmp++; } if (_tmp < _fadeSteps) { _fadeSteps = _tmp; _fadeDirection = -1; } } //fade else if (_step >= (hTime*1000)+15) { _stepped=false; if (_currentHue != _targetHue) { long incStep =(fTime*1000)/_fadeSteps ; if (_step % incStep < _prevSubStep) _currentHue+= _fadeDirection; _prevSubStep = _step % incStep; } } _ledColors[0] = hsbToRGB(getColorHue() +_currentHue,getColorSat(),ambBrightness); _ledColors[1] = hsbToRGB(byte(getColorHue() +_currentHue - (getCycleSteps()*(PI/1.5f) )),byte(getColorSat()/1.2f),ambBrightness); _prevStep = _step; }
DisplayConfigPtr DisplayConfigFactory::create(OSVR_ClientContext ctx) { DisplayConfigPtr cfg(new DisplayConfig); try { auto const descriptorString = ctx->getStringParameter("/display"); auto desc = display_schema_1::DisplayDescriptor(descriptorString); cfg->m_viewers.container().emplace_back(Viewer(ctx, HEAD_PATH)); auto &viewer = cfg->m_viewers.container().front(); auto eyesDesc = desc.getEyes(); /// Set up stereo vs mono std::vector<uint8_t> eyeIndices; Eigen::Vector3d offset; if (eyesDesc.size() == 2) { // stereo offset = desc.getIPDMeters() / 2. * Eigen::Vector3d::UnitX(); eyeIndices = {0, 1}; } else { // if (eyesDesc.size() == 1) // mono offset = Eigen::Vector3d::Zero(); eyeIndices = {0}; } /// Handle radial distortion parameters boost::optional<OSVR_RadialDistortionParameters> distort; auto k1 = desc.getDistortion(); if (k1.k1_red != 0 || k1.k1_green != 0 || k1.k1_blue != 0) { OSVR_RadialDistortionParameters params; params.k1.data[0] = k1.k1_red; params.k1.data[1] = k1.k1_green; params.k1.data[2] = k1.k1_blue; distort = params; } /// Compute angular offset about Y of the optical (view) axis util::Angle axisOffset = 0. * util::radians; { auto overlapPct = desc.getOverlapPercent(); if (overlapPct < 1.) { const auto hfov = desc.getHorizontalFOV(); const auto angularOverlap = hfov * overlapPct; axisOffset = (hfov - angularOverlap) / 2.; } } /// Infer the number of display inputs and their association with /// eyes (actually surfaces) based on the descriptor. std::vector<OSVR_DisplayInputCount> displayInputIndices; if (eyesDesc.size() == 2 && display_schema_1::DisplayDescriptor::FULL_SCREEN == desc.getDisplayMode()) { // two eyes, full screen - that means two screens. displayInputIndices = {0, 1}; cfg->m_displayInputs.push_back(DisplayInput( desc.getDisplayWidth(), desc.getDisplayHeight())); cfg->m_displayInputs.push_back(DisplayInput( desc.getDisplayWidth(), desc.getDisplayHeight())); } else { // everything else, assume 1 screen. // Note that it's OK that displayInputIndices.size() >= // eyesDesc.size(), we'll just not end up using the second // entry. displayInputIndices = {0, 0}; cfg->m_displayInputs.push_back(DisplayInput( desc.getDisplayWidth(), desc.getDisplayHeight())); } BOOST_ASSERT_MSG(displayInputIndices.size() >= eyesDesc.size(), "Must have at least as many indices as eyes"); /// Create the actual eye (with implied surface) objects for (auto eye : eyeIndices) { // This little computation turns 0 into -1 and 1 into 1, used as // a coefficient to make the two eyes do opposite things. // Doesn't affect mono, which has a zero offset vector. double offsetFactor = (2. * eye) - 1.; // Set up per-eye distortion parameters, if needed boost::optional<OSVR_RadialDistortionParameters> distortEye( distort); if (distortEye) { distortEye->centerOfProjection.data[0] = eyesDesc[eye].m_CenterProjX; distortEye->centerOfProjection.data[1] = eyesDesc[eye].m_CenterProjY; } // precompute translation offset for this eye auto xlateOffset = (offsetFactor * offset).eval(); // precompute the optical axis rotation for this eye // here, the left eye should get a positive offset since it's a // positive rotation about y, hence the -1 factor. auto eyeAxisOffset = axisOffset * -1. * offsetFactor; // Look up the display index for this eye. auto displayInputIdx = displayInputIndices[eye]; /// Create the ViewerEye[Surface] and add it to the container. viewer.container().emplace_back(ViewerEye( ctx, xlateOffset, HEAD_PATH, computeViewport(eye, desc), computeRect(desc), eyesDesc[eye].m_rotate180, desc.getPitchTilt().value(), distortEye, displayInputIdx, eyeAxisOffset)); } OSVR_DEV_VERBOSE("Display: " << desc.getHumanReadableDescription()); return cfg; } catch (std::exception const &e) { OSVR_DEV_VERBOSE( "Couldn't create a display config internally! Exception: " << e.what()); return DisplayConfigPtr{}; } catch (...) { OSVR_DEV_VERBOSE("Couldn't create a display config internally! " "Unknown exception!"); return DisplayConfigPtr{}; } }
status_t BnMultiDisplayInfoProvider::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch (code) { case MDS_SERVER_GET_VIDEO_STATE: { CHECK_INTERFACE(IMultiDisplayInfoProvider, data, reply); int32_t sessionId = data.readInt32(); MDS_VIDEO_STATE ret = getVideoState(sessionId); reply->writeInt32(ret); return NO_ERROR; } break; case MDS_SERVER_GET_VIDEO_SESSION_NUM: { CHECK_INTERFACE(IMultiDisplayInfoProvider, data, reply); int ret = getVideoSessionNumber(); reply->writeInt32(ret); return NO_ERROR; } break; case MDS_SERVER_GET_VIDEO_SOURCE_INFO: { CHECK_INTERFACE(IMultiDisplayInfoProvider, data, reply); MDSVideoSourceInfo info; int32_t sessionId = data.readInt32(); status_t ret = getVideoSourceInfo(sessionId, &info); reply->write((const void *)&info, sizeof(MDSVideoSourceInfo)); reply->writeInt32(ret); return NO_ERROR; } break; case MDS_SERVER_GET_DISPLAY_MODE: { CHECK_INTERFACE(IMultiDisplayInfoProvider, data, reply); bool wait = (data.readInt32() == 0 ? false : true); MDS_DISPLAY_MODE ret = getDisplayMode(wait); reply->writeInt32(ret); return NO_ERROR; } break; case MDS_SERVER_GET_DECODER_OUTPUT_RESOLUTION: { CHECK_INTERFACE(IMultiDisplayInfoProvider, data, reply); int32_t width = 0; int32_t height = 0; int32_t offX = 0; int32_t offY = 0; int32_t bufW = 0; int32_t bufH = 0; int32_t sessionId = data.readInt32(); status_t ret = getDecoderOutputResolution(sessionId, &width, &height, &offX, &offY, &bufW, &bufH); reply->writeInt32(width); reply->writeInt32(height); reply->writeInt32(offX); reply->writeInt32(offY); reply->writeInt32(bufW); reply->writeInt32(bufH); reply->writeInt32(ret); return NO_ERROR; } break; case MDS_SERVER_GET_VPP_STATE: { CHECK_INTERFACE(IMultiDisplayInfoProvider, data, reply); uint32_t ret = getVppState(); reply->writeInt32(ret); return NO_ERROR; } break; } // switch return BBinder::onTransact(code, data, reply, flags); }