Example #1
0
int VideoColourSpace::SetPictureAttribute(PictureAttribute attribute, int value)
{
    if (!(m_supported_attributes & toMask(attribute)))
        return -1;

    value = std::min(std::max(value, 0), 100);

    switch (attribute)
    {
        case kPictureAttribute_Brightness:
            SetBrightness(value);
            break;
        case kPictureAttribute_Contrast:
            SetContrast(value);
            break;
        case kPictureAttribute_Colour:
            SetSaturation(value);
            break;
        case kPictureAttribute_Hue:
            SetHue(value);
            break;
        case kPictureAttribute_StudioLevels:
            value = std::min(std::max(value, 0), 1);
            SetStudioLevels(value > 0);
            break;
        default:
            value = -1;
    }

    if (value >= 0)
        SaveValue(attribute, value);

    return value;
}
Example #2
0
void CE_CBeam::BeamInit( const char *pSpriteName, float width )
{
	SetColor( 255, 255, 255 );
	SetBrightness( 255 );
	SetNoise( 0 );
	SetFrame( 0 );
	SetScrollRate( 0 );
	SetModelName( MAKE_STRING( pSpriteName ) );
	SetRenderMode( kRenderTransTexture );
	SetTexture( engine->PrecacheModel( pSpriteName ) );
	SetWidth( width );
	SetEndWidth( width );
	SetFadeLength( 0 );			// No fade

	for (int i=0;i<MAX_BEAM_ENTS;i++)
	{
		Set_m_hAttachEntity(i,NULL);
		Set_m_nAttachIndex(i, 0);
	}

	m_nHaloIndex	= 0;
	m_fHaloScale	= BEAM_DEFAULT_HALO_SCALE;
	m_nBeamType		= 0;
	m_nBeamFlags    = 0;
}
Example #3
0
Boolean SettingsHelper::RestoreValue(
    /* [in] */ const String& name,
    /* [in] */ const String& value)
{
    if (ISettingsSystem::SCREEN_BRIGHTNESS.Equals(name)) {
        SetBrightness(StringUtils::ParseInt32(value));
    }
    else if (ISettingsSystem::SOUND_EFFECTS_ENABLED.Equals(name)) {
        SetSoundEffects(StringUtils::ParseInt32(value) == 1);
    }
    else if (ISettingsSecure::LOCATION_PROVIDERS_ALLOWED.Equals(name)) {
        SetGpsLocation(value);
        return FALSE;
    }
    else if (ISettingsSecure::BACKUP_AUTO_RESTORE.Equals(name)) {
        SetAutoRestore(StringUtils::ParseInt32(value) == 1);
    }
    else if (IsAlreadyConfiguredCriticalAccessibilitySetting(name)) {
        return FALSE;
    }
    else if (ISettingsSystem::RINGTONE.Equals(name)
            || ISettingsSystem::NOTIFICATION_SOUND.Equals(name)) {
        SetRingtone(name, value);
        return FALSE;
    }

    return TRUE;
}
Example #4
0
void Flea3Camera::Configure(Config& config) {
  // Video Mode
  SetVideoMode(config.video_mode, config.format7_mode, config.pixel_format,
               config.width, config.height);

  // Update CameraInfo here after video mode is changed
  camera_info_ = GetCameraInfo(camera_);

  // Frame Rate
  SetFrameRate(config.fps);

  // Raw Bayer
  SetRawBayerOutput(config.raw_bayer_output);

  // White Balance
  SetWhiteBalanceRedBlue(config.white_balance, config.auto_white_balance,
                         config.wb_red, config.wb_blue);

  // Exposure
  SetExposure(config.exposure, config.auto_exposure, config.exposure_value);
  SetShutter(config.auto_shutter, config.shutter_ms);
  SetGain(config.auto_gain, config.gain_db);

  SetBrightness(config.brightness);
  SetGamma(config.gamma);

  // Strobe
  SetStrobe(config.strobe_control, config.strobe_polarity);
  // Trigger
  SetTrigger(config.trigger_source, config.trigger_polarity);

  // Save this config
  config_ = config;
}
Example #5
0
void Set_LED_Pattern(uint8_t no, uint16_t delay, uint8_t bri){
	xprintf(INFO "no=%d,delay=%d,bri=%d",no,delay,bri);FFL_();
	if(no==9 || no==10){
		PREV_LED_PATTERN = LED_PATTERN;
		LED_PATTERN = no;
	}else{
		LED_PATTERN = no;
	}
	if(delay!=0){
		MILLI_DELAY = delay;
		TIM_UpdateMatchValue(LPC_TIM2, 0, MILLI_DELAY);
		TIM_ResetCounter(LPC_TIM2);
	}
	else{
		xprintf(INFO "LED delay not changed");FFL_();
	}
	if(bri!=0)
		SetBrightness(bri);
	else{
		xprintf(INFO "Brightness not changed");FFL_();
	}
//	TIM_Cmd(LPC_TIM2,DISABLE);
//	xprintf(INFO "pattern=%d DELAY=%d Bri=%d",no,MILLI_DELAY,bri);FFL_();
	resetLeds();
	LED_Loop=0;
	LED_Loop_v1=0;
	LED_Loop_v2=0;
	LED_Loop_v3=0;
	TIM_Cmd(LPC_TIM0,ENABLE);
	TIM_Cmd(LPC_TIM2,ENABLE);
}
Example #6
0
void CTextureTool::DoDataExchange (CDataExchange *pDX)
{
	int		i, nBrightness;
	char		szBrightness [20];

for (i = 0; i < 4; i++)
	DDX_Double (pDX, IDC_TEXTURE_LIGHT1 + i, m_lights [i], 0, 200, "%1.1f");
DDX_Check (pDX, IDC_TEXTURE_PASTE1ST, m_bUse1st);
DDX_Check (pDX, IDC_TEXTURE_PASTE2ND, m_bUse2nd);
DDX_Check (pDX, IDC_TEXALIGN_SHOWTEXTURE, m_bShowTexture);
DDX_Check (pDX, IDC_TEXALIGN_SHOWCHILDREN, m_bShowChildren);
DDX_Check (pDX, IDC_TEXALIGN_IGNOREPLANE, m_bIgnorePlane);
DDX_Double (pDX, IDC_TEXALIGN_HALIGN, m_alignX);
DDX_Double (pDX, IDC_TEXALIGN_VALIGN, m_alignY);
DDX_Double (pDX, IDC_TEXALIGN_RALIGN, m_alignAngle);
DDX_Radio (pDX, IDC_TEXALIGN_ROT0, m_alignRot2nd);
DDX_Double (pDX, IDC_TEXLIGHT_TIMER, m_nLightTime);
DDX_Text (pDX, IDC_TEXTURE_PASTEBUF, m_szTextureBuf, sizeof (m_szTextureBuf));
//if (!nLayout) 
	{
	DDX_Text (pDX, IDC_TEXLIGHT_EDIT, m_szLight, sizeof (m_szLight));
	DDX_Text (pDX, IDC_TEXLIGHT_COLORINDEX, m_nColorIndex);
	}
sprintf (szBrightness, "%d", m_nBrightness);
DDX_Text (pDX, IDC_TEXTURE_BRIGHTNESS, szBrightness, sizeof (szBrightness));
if (pDX->m_bSaveAndValidate && *szBrightness) {
	m_nBrightness = atoi (szBrightness);
	nBrightness = (m_nBrightness < 0) ? 0 : (m_nBrightness > 100) ? 100 : m_nBrightness;
	((CSliderCtrl *) BrightnessSlider ())->SetPos (nBrightness);
	SetBrightness (nBrightness);
	}
}
Example #7
0
void UiBacklight::Switch( bool on )
{
    if( on )
    {
        SetBrightness( _maxBrightness );
        KillTimer( TimerDimmDown );
    } else {
        RequestTimer( DimmInterval, TimerDimmDown );
    }
	_isOn = on;
}
Example #8
0
REALIGN STDCALL uint32_t DefWindowProcA_wrap(void *hWnd, uint32_t uMsg, uint32_t wParam, uint32_t lParam)
{
	if (uMsg == WM_DESTROY)
	{
#ifdef OPENGL1X
		SetBrightness(-2.0f);
#endif
		SDL_DestroyWindow(sdlWin);
		sdlWin = NULL;
	}
	return 0;
}
Example #9
0
void UiBacklight::SetRange( int minBrightness, int maxBrightness )
{
	LOG( Logger::LOG_DEBUG, "UiBacklight::SetRange( %d, %d )", minBrightness, maxBrightness);
	if( minBrightness < 0 )minBrightness = 0;
	if( minBrightness > 255 )minBrightness = 255;
	if( maxBrightness < minBrightness )maxBrightness = minBrightness;
	if( maxBrightness < 10 )maxBrightness = 10;
	if( maxBrightness > 255 )maxBrightness = 255;
	_minBrightness = minBrightness;
	_maxBrightness = maxBrightness;
	LOG( Logger::LOG_DEBUG, "adjusted range is ( %d, %d )", minBrightness, maxBrightness);
	SetBrightness( _maxBrightness );
}
Example #10
0
CFX_RGBLed::CFX_RGBLed(int redpin, int greenpin, int bluepin, bool commonAnode) : CFX_Led()
{
  m_redpin = redpin;
  m_greenpin = greenpin;
  m_bluepin = bluepin;
  pinMode(m_redpin, OUTPUT);
  pinMode(m_greenpin, OUTPUT);
  pinMode(m_bluepin, OUTPUT);
  m_commonAnode = commonAnode;
  SetColor(m_color);
  SetBrightness(255);
  SetChanged(true);
  Commit();
}
Example #11
0
void CBeam::BeamInit( const char *pSpriteName, int width )
{
	pev->flags |= FL_CUSTOMENTITY;
	SetColor( 255, 255, 255 );
	SetBrightness( 255 );
	SetNoise( 0 );
	SetFrame( 0 );
	SetScrollRate( 0 );
	pev->model = MAKE_STRING( pSpriteName );
	SetTexture( PRECACHE_MODEL( ( char * ) pSpriteName ) );
	SetWidth( width );
	pev->skin = 0;
	pev->sequence = 0;
	pev->rendermode = 0;
}
Example #12
0
static void signal_handler(int sig)
{
	static char errStr[40];
	if (sig == SIGINT || sig == SIGTERM)
	{
		exit(0);
		return;
	}
	if (sig == SIGPIPE)
		return;
	snprintf(errStr, sizeof errStr, "Application closed with a signal: %d", sig);
	fprintf(stderr, "%s\n", errStr);
	SetBrightness(-1.0f);
	SDL_SetWindowFullscreen(sdlWin, SDL_FALSE);
	SDL_ShowSimpleMessageBox(0, "Probably crash!", errStr, NULL);
	raise(SIGKILL);
}
Example #13
0
bool BaseV4L2VideoCapture::SetCaptureFiltersToDefault() {
  if(!SetBrightness(_pVideoCaptureFiltersCapability->GetBrightnessConstraint().dflt))
    return false;
  if(!SetContrast(_pVideoCaptureFiltersCapability->GetContrastConstraint().dflt))
    return false;
  if(!SetHUE(_pVideoCaptureFiltersCapability->GetHueConstraint().dflt))
    return false;
  if(!SetSaturation(_pVideoCaptureFiltersCapability->GetSaturationConstraint().dflt))
    return false;
  if(!SetSharpness(_pVideoCaptureFiltersCapability->GetSharpnessConstraint().dflt))
    return false;
  if(!SetGamma(_pVideoCaptureFiltersCapability->GetGammaConstraint().dflt))
    return false;
  if(!SetBacklightCompensation(_pVideoCaptureFiltersCapability->GetBacklightCompensationConstraint().dflt))
    return false;

  return true;
}
Example #14
0
Led::Led(uint8_t pin, bool invertPWM) {
	this->invertPWM = invertPWM;
	this->pin = pin;

	isOn = false;


	strobe_isOn_before = false;
	strobe_times_remain = 0;
	isStrobing = false;

	fade_time_remain = 0;
	current_value = 0;

	fadeOnOff_current_brightness = 0;
	fadeOnOff_time_remain = 0;

	SetBrightness(brightness);
}
Example #15
0
void UiBacklight::OnTimer( unsigned long cookie )
{
    switch( cookie )
    {
        case TimerSwitchOff:
            if( (time(NULL) - _backlightTimeout - _lastTriggerTime) > 10 )
            {
                //looks like a time warp, retrigger
                Trigger();
            }else{
                Switch( false );
            }
        break;
        case TimerDimmDown:
            SetBrightness( _currentBrightness - DimmStep );
            if( _currentBrightness > _minBrightness )
            {
                RequestTimer( DimmInterval, TimerDimmDown );
            }
        break;
    }
}
Example #16
0
VideoColourSpace::VideoColourSpace(VideoCStd colour_std)
  : m_supported_attributes(kPictureAttributeSupported_None),
    m_changed(false), m_studioLevels(false), m_brightness(0.0f),
    m_contrast(1.0f), m_saturation(1.0f),    m_hue(0.0f),
    m_colourSpace(colour_std)
{
    m_db_settings[kPictureAttribute_Brightness] =
        gCoreContext->GetNumSetting("PlaybackBrightness",   50);
    m_db_settings[kPictureAttribute_Contrast] =
        gCoreContext->GetNumSetting("PlaybackContrast",     50);
    m_db_settings[kPictureAttribute_Colour] =
        gCoreContext->GetNumSetting("PlaybackColour",       50);
    m_db_settings[kPictureAttribute_Hue] =
        gCoreContext->GetNumSetting("PlaybackHue",          0);
    m_db_settings[kPictureAttribute_StudioLevels] =
        gCoreContext->GetNumSetting("PlaybackStudioLevels", 0);

    SetBrightness(m_db_settings[kPictureAttribute_Brightness]);
    SetContrast(m_db_settings[kPictureAttribute_Contrast]);
    SetSaturation(m_db_settings[kPictureAttribute_Colour]);
    SetHue(m_db_settings[kPictureAttribute_Hue]);
    SetStudioLevels(m_db_settings[kPictureAttribute_StudioLevels]);
}
Example #17
0
void Led::Fade(uint8_t target_brightness, unsigned int fade_time) {

	fade_time_remain = 0;

	if (fade_time == 0) {
		SetBrightness(target_brightness);
		return;
	}

	target_brightness = constrain(target_brightness, 0, 255);

	fade_time_remain = fade_time;
	fade_last_step_time = millis();
	fade_target_brightness = target_brightness;


	int bright_diff = abs(brightness - fade_target_brightness);
	if (bright_diff == 0) {
		fade_time_remain = 0;
		return;
	}
	fade_step_duration = round(fade_time_remain / bright_diff);
}
Example #18
0
/**
 * Task to handle the display of LEDs
 */
void LEDs::LEDRunner() {
	// This is kind of ugly :(
	auto ds = DriverStation::GetInstance();
	int mode = 0;
	//float hueOutput = 0;
	auto leds = LEDController::GetInstance();
	leds->SetBrightness(30);
	LEDStrip frontLeft(0, 8);
	LEDStrip rearLeft(8, 16);
	LEDStrip rearRight(24, 16);
	LEDStrip frontRight(40, 8);
	std::vector<Util::Color> tmp;
	while (taskRunning.test_and_set()) {
		Wait(0.2);
		if (ds->IsDisabled()) {
			tmp.clear(); tmp.resize(16, 0xffff00);
			if (!ds->IsDSAttached()) {
				// Not attached to the DS, so, alternate yellow/off
				for (int i = 0; i < 8; i++) {
					tmp[i * 2] = 0x000000;
				}
			}
			rearLeft.Set(tmp);
			rearRight.Set(tmp);
			tmp.resize(8);
			frontRight.Set(tmp);
			frontLeft.Set(tmp);
			mode = Auton::GetInstance()->GetMode();
			tmp.clear();
			tmp.resize(3);
			tmp[0] = mode & 1 ? 0xffff00 : 0x00;
			tmp[1] = mode & 2 ? 0xffff00 : 0x00;
			tmp[2] = mode & 4 ? 0xffff00 : 0x00;
			rearRight.Set(tmp, 0);

			tmp.clear(); tmp.resize(6);
			tmp[0] = ds->IsDSAttached() ? 0x00ff00 : 0x00;
			tmp[1] = ds->IsFMSAttached() ? 0x00ff00 : 0x00;
			float hueOutput = Interpolate(ds->GetBatteryVoltage(), 12.0f, 13.0f, 0.0f, 120.0f);
			//hueOutput = ((int)hueOutput + 5) % 360;
			//float hueOutput
			//printf("Voltage: %f (%f) ", ds->GetBatteryVoltage(), hueOutput);
			tmp[2] = Util::Color(hueOutput, 1.0, 0.75);
			//Util::RGB c = tmp[2];
			//printf("(%d, %d, %d)\n", c.r, c.g, c.b);

			auto position = ds->GetLocation();
			auto alliance = ds->GetAlliance();
			Util::Color allianceColor = alliance == DriverStation::kRed ? 0xff0000 : (alliance == DriverStation::kBlue ? 0x0000ff : 0xffff00);
			if (position) {
				tmp[2 + position] = allianceColor;
			//} else {
				//position += 1;
				//tmp[2 + position] = allianceColor;
				//tmp[2 + position + 1] = allianceColor;
				//tmp[2 + position + 2] = allianceColor;
			}
			rearRight.Set(tmp, 3);
			rearRight.Show();
		} else {
			if (ds->IsAutonomous()) {
				auto alliance = ds->GetAlliance();
				Util::Color allianceColor = alliance == DriverStation::kRed ? 0xff0000 : (alliance == DriverStation::kBlue ? 0x0000ff : 0xffff00);
				tmp.clear();
				tmp.resize(16, allianceColor);
				rearLeft.Set(tmp);
				rearRight.Set(tmp);
				tmp.resize(8);
				frontLeft.Set(tmp);
				frontRight.Set(tmp);
			} else if (ds->IsOperatorControl()) {
				double timeLeft = ds->GetMatchTime();
				tmp.clear();
				tmp.resize(16, 0xffff00);
				if (timeLeft < 0 || timeLeft > 30) {
					// All yellow
				} else if (timeLeft > 20) {
					for (int i = 0; i < 8; i++) {
						tmp[i * 2] = 0x00ff00;
					}
				} else if (timeLeft > 5) {
					// off and green->red
					float hueOutput = Interpolate((float)timeLeft, 5.0f, 20.f, 0.0f, 120.0f);
					for (int i = 0; i < 8; i++) {
						tmp[i * 2 + 1] = 0x00;
						tmp[i * 2] = Util::Color(hueOutput, 1.0, 0.75);
						//tmp[i * 2] = 0x00ff00;
					}
				} else {
					// Just red
					tmp.clear();
					tmp.resize(16, 0xff0000);
				}
				if (Grabber::GetInstance()->Get(Grabber::kMini)) {
					tmp[0] = 0xff00ff;
					tmp[15] = 0xff00ff;
				}
				if (!Grabber::GetInstance()->Get(Grabber::kMain)) {
					tmp[1] = 0x00ffff;
					tmp[14] = 0x00ffff;
				}
				rearLeft.Set(tmp);
				rearRight.Set(tmp);
				tmp.resize(8);
				if (Grabber::GetInstance()->Get(Grabber::kMini)) {
					tmp[7] = 0xff00ff;
				}
				if (!Grabber::GetInstance()->Get(Grabber::kMain)) {
					tmp[6] = 0x00ffff;
				}
				frontLeft.Set(tmp);
				frontRight.Set(tmp);

				//printf("Match Time: %f\n", ds->GetMatchTime());

			}
		}
		frontLeft.Show();
		rearLeft.Show();
		frontRight.Show();
		rearRight.Show();
	}
}
Example #19
0
/** Constructor : Initialize the interrupt code. 
 * should be called in setup();
 */
void LedSign::Init(uint8_t mode)
{
#ifdef MEASURE_ISR_TIME
    pinMode(statusPIN, OUTPUT);
    digitalWrite(statusPIN, LOW);
#endif

	float prescaler = 0.0;
	
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || (__AVR_ATmega1280__)
	TIMSK2 &= ~(1<<TOIE2);
	TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
	TCCR2B &= ~(1<<WGM22);
	ASSR &= ~(1<<AS2);
	TIMSK2 &= ~(1<<OCIE2A);
	
	if ((F_CPU >= 1000000UL) && (F_CPU <= 16000000UL)) {	// prescaler set to 64
		TCCR2B |= ((1<<CS21) | (1<<CS20));
		TCCR2B &= ~(1<<CS22);
		prescaler = 32.0;
	} else if (F_CPU < 1000000UL) {	// prescaler set to 8
		TCCR2B |= (1<<CS21);
		TCCR2B &= ~((1<<CS22) | (1<<CS20));
		prescaler = 8.0;
	} else { // F_CPU > 16Mhz, prescaler set to 128
		TCCR2B |= (1<<CS22);
		TCCR2B &= ~((1<<CS21) | (1<<CS20));
		prescaler = 64.0;
	}
#elif defined (__AVR_ATmega8__)
	TIMSK &= ~(1<<TOIE2);
	TCCR2 &= ~((1<<WGM21) | (1<<WGM20));
	TIMSK &= ~(1<<OCIE2);
	ASSR &= ~(1<<AS2);
	
	if ((F_CPU >= 1000000UL) && (F_CPU <= 16000000UL)) {	// prescaler set to 64
		TCCR2 |= (1<<CS22);
		TCCR2 &= ~((1<<CS21) | (1<<CS20));
		prescaler = 64.0;
	} else if (F_CPU < 1000000UL) {	// prescaler set to 8
		TCCR2 |= (1<<CS21);
		TCCR2 &= ~((1<<CS22) | (1<<CS20));
		prescaler = 8.0;
	} else { // F_CPU > 16Mhz, prescaler set to 128
		TCCR2 |= ((1<<CS22) && (1<<CS20));
		TCCR2 &= ~(1<<CS21);
		prescaler = 128.0;
	}
#elif defined (__AVR_ATmega128__)
	TIMSK &= ~(1<<TOIE2);
	TCCR2 &= ~((1<<WGM21) | (1<<WGM20));
	TIMSK &= ~(1<<OCIE2);
	
	if ((F_CPU >= 1000000UL) && (F_CPU <= 16000000UL)) {	// prescaler set to 64
		TCCR2 |= ((1<<CS21) | (1<<CS20));
		TCCR2 &= ~(1<<CS22);
		prescaler = 64.0;
	} else if (F_CPU < 1000000UL) {	// prescaler set to 8
		TCCR2 |= (1<<CS21);
		TCCR2 &= ~((1<<CS22) | (1<<CS20));
		prescaler = 8.0;
	} else { // F_CPU > 16Mhz, prescaler set to 256
		TCCR2 |= (1<<CS22);
		TCCR2 &= ~((1<<CS21) | (1<<CS20));
		prescaler = 256.0;
	}
#endif

	tcnt2 = 256 - (int)((float)F_CPU * 0.0005 / prescaler);

    // Record whether we are in single or double buffer mode
    displayMode = mode;
    videoFlipPage = false;

    // Point the display buffer to the first physical buffer
    displayBuffer = &leds[0];

    // If we are in single buffered mode, point the work buffer
    // at the same physical buffer as the display buffer.  Otherwise,
    // point it at the second physical buffer.
    if( displayMode & DOUBLE_BUFFER ) {
        workBuffer = &leds[1];
    }
    else {
        workBuffer = displayBuffer;
    }

    // Set up the timer buffering
    frontTimer = &timer[0];
    backTimer = &timer[1];

    videoFlipTimer = false;
    SetBrightness(127);
	
    // Clear the buffer and display it
    LedSign::Clear(0);
    LedSign::Flip(false);

    // Then start the display
	TCNT2 = tcnt2;
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || (__AVR_ATmega1280__)
	TIMSK2 |= (1<<TOIE2);
#elif defined (__AVR_ATmega128__) || defined (__AVR_ATmega8__)
	TIMSK |= (1<<TOIE2);
#endif

    // If we are in double-buffer mode, wait until the display flips before we
    // return
    if (displayMode & DOUBLE_BUFFER)
    {
        while (videoFlipPage) {
            delay(1);
        }
    }

    initialized = true;
}
void ExpandedLEDSerialControllerMega::SetState (State state) {
  switch (state) {
    case kBreathing:
      {
        const float loopDurration = loopSeconds;
        const float halfDurration = loopDurration / 2;

        float timeLoop = float(millis() % int(loopDurration * 1000)) / 1000;
        float timeHalf = float(millis() % int(halfDurration * 1000)) / 1000;

        if (timeLoop <= halfDurration)
          SetBrightness((timeHalf * timeHalf) / (halfDurration * halfDurration));
        else
          SetBrightness(((halfDurration * halfDurration) - (timeHalf * timeHalf)) /
                        (halfDurration * halfDurration));
      }
      break;

    case kBlink:
      {
        const float loopDurration = loopSeconds;
        const float halfDurration = loopDurration / 2;

        float timeLoop = float(millis() % int(loopDurration * 1000)) / 1000;

        if (timeLoop <= halfDurration)
          SetBrightness(1);
        else
          SetBrightness(0);
      }
      break;

    case kSlowBlink:
      {
        const float loopDurration = loopSeconds * 2;
        const float halfDurration = loopDurration / 2;

        float timeLoop = float(millis() % int(loopDurration * 1000)) / 1000;

        if (timeLoop <= halfDurration)
          SetBrightness(1);
        else
          SetBrightness(0);
      }
      break;

    case kSolid:
      SetBrightness(1);
      break;

    case kQuickBlink: {
        const float loopDurration = loopSeconds / 2;
        const float halfDurration = loopDurration / 2;

        float timeLoop = float(millis() % int(loopDurration * 1000)) / 1000;


        if (timeLoop <= halfDurration)
          SetBrightness(1);
        else
          SetBrightness(0);
      }
      break;

    default:
      SetBrightness(0);
      break;
  }
}
Example #21
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CSprite::Spawn( void )
{
	SetSolid( SOLID_NONE );
	SetMoveType( MOVETYPE_NONE );
	m_flFrame = 0;

	Precache();
	SetModel( STRING( GetModelName() ) );
	CollisionProp()->SetSurroundingBoundsType( USE_GAME_CODE );

	m_flMaxFrame = (float)modelinfo->GetModelFrameCount( GetModel() ) - 1;
	AddEffects( EF_NOSHADOW | EF_NORECEIVESHADOW );

#if defined( CLIENT_DLL )
	SetNextClientThink( CLIENT_THINK_ALWAYS );
#endif

#if !defined( CLIENT_DLL )
	if ( GetEntityName() != NULL_STRING && !(m_spawnflags & SF_SPRITE_STARTON) )
	{
		TurnOff();
	}
	else
#endif
	{
		TurnOn();
	}
	
	// Worldcraft only sets y rotation, copy to Z
	if ( GetLocalAngles().y != 0 && GetLocalAngles().z == 0 )
	{
		QAngle angles = GetLocalAngles();

		angles.z = angles.y;
		angles.y = 0;

		SetLocalAngles( angles );
	}

	// Clamp our scale if necessary
	float scale = m_flSpriteScale;
	
	if ( scale < 0 || scale > MAX_SPRITE_SCALE )
	{
#if !defined( CLIENT_DLL ) 
#ifndef _LINUX
		DevMsg( "LEVEL DESIGN ERROR: Sprite %s with bad scale %f [0..%f]\n", GetDebugName(), m_flSpriteScale, MAX_SPRITE_SCALE );
#endif
#endif
		scale = clamp( m_flSpriteScale, 0, MAX_SPRITE_SCALE );
	}

	//Set our state
	SetBrightness( m_clrRender->a );
	SetScale( scale );

#if defined( CLIENT_DLL )
	m_flStartScale = m_flDestScale = m_flSpriteScale;
	m_nStartBrightness = m_nDestBrightness = m_nBrightness;
#endif

}
Example #22
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CSprite::Spawn( void )
{
	SetSolid( SOLID_NONE );
	SetMoveType( MOVETYPE_NONE );
	m_flFrame = 0;

	Precache();
	SetModel( STRING( GetModelName() ) );
	CollisionProp()->SetSurroundingBoundsType( USE_GAME_CODE );

	m_flMaxFrame = (float)modelinfo->GetModelFrameCount( GetModel() ) - 1;
	AddEffects( EF_NOSHADOW | EF_NORECEIVESHADOW );

#if !defined( CLIENT_DLL )
	if ( m_flGlowProxySize > MAX_GLOW_PROXY_SIZE )
	{
		// Clamp on Spawn to prevent per-frame spew
		DevWarning( "env_sprite at setpos %0.0f %0.0f %0.0f has invalid glow size %f - clamping to %f\n",
			GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z, m_flGlowProxySize.Get(), MAX_GLOW_PROXY_SIZE );
		m_flGlowProxySize = MAX_GLOW_PROXY_SIZE;
	}
	if ( GetEntityName() != NULL_STRING && !(m_spawnflags & SF_SPRITE_STARTON) )
	{
		TurnOff();
	}
	else
#endif
	{
		TurnOn();
	}
	
	// Worldcraft only sets y rotation, copy to Z
	if ( GetLocalAngles().y != 0 && GetLocalAngles().z == 0 )
	{
		QAngle angles = GetLocalAngles();

		angles.z = angles.y;
		angles.y = 0;

		SetLocalAngles( angles );
	}

	// Clamp our scale if necessary
	float scale = m_flSpriteScale;
	
	if ( scale < 0 || scale > MAX_SPRITE_SCALE )
	{
#if !defined( CLIENT_DLL ) 
		DevMsg( "LEVEL DESIGN ERROR: Sprite %s with bad scale %f [0..%f]\n", GetDebugName(), m_flSpriteScale, MAX_SPRITE_SCALE );
#endif
		scale = clamp( m_flSpriteScale, 0, MAX_SPRITE_SCALE );
	}

	//Set our state
	SetBrightness( GetRenderAlpha() );
	SetScale( scale );

#if defined( CLIENT_DLL )
	m_flStartScale = m_flDestScale = m_flSpriteScale;
	m_nStartBrightness = m_nDestBrightness = m_nBrightness;
#endif

}
Example #23
0
void CTextureTool::OnVScroll (UINT scrollCode, UINT thumbPos, CScrollBar *pScrollBar)
{
	int	nPos = pScrollBar->GetScrollPos ();
	CRect	rc;

if (pScrollBar == TimerSlider ()) {
	if (m_iLight < 0)
		return;
	switch (scrollCode) {
		case SB_LINEUP:
			nPos++;
			break;
		case SB_LINEDOWN:
			nPos--;
			break;
		case SB_PAGEUP:
			nPos += 5;
			break;
		case SB_PAGEDOWN:
			nPos -= 5;
			break;
		case SB_THUMBPOSITION:
		case SB_THUMBTRACK:
			nPos = 20 - thumbPos;
			break;
		case SB_ENDSCROLL:
			return;
		}
	if (nPos < 0)
		nPos = 0;
	else if (nPos > 20)
		nPos = 20;
	SetLightDelay (nPos * 50);
//	pScrollBar->SetScrollPos (nPos, TRUE);
	}
else if (pScrollBar == BrightnessSlider ()) {
	switch (scrollCode) {
		case SB_LINEUP:
			nPos--;
			break;
		case SB_LINEDOWN:
			nPos++;
			break;
		case SB_PAGEUP:
			nPos -= 10;
			break;
		case SB_PAGEDOWN:
			nPos += 10;
			break;
		case SB_THUMBPOSITION:
		case SB_THUMBTRACK:
			nPos = thumbPos;
			break;
		case SB_ENDSCROLL:
			return;
		}
	if (nPos < 0)
		nPos = 0;
	else if (nPos > 100)
		nPos = 100;
	SetBrightness (nPos);
	UpdateData (FALSE);
//	pScrollBar->SetScrollPos (nPos, TRUE);
	}
else {
	m_alignWnd.GetClientRect (rc);
	switch (scrollCode) {
		case SB_LINEUP:
			nPos--;
			break;
		case SB_LINEDOWN:
			nPos++;
			break;
		case SB_PAGEUP:
			nPos -= rc.Height () / 4;
			break;
		case SB_PAGEDOWN:
			nPos += rc.Height () / 4;
			break;
		case SB_THUMBPOSITION:
		case SB_THUMBTRACK:
			nPos = thumbPos;
			break;
		case SB_ENDSCROLL:
			return;
		}
	pScrollBar->SetScrollPos (nPos, TRUE);
	UpdateAlignWnd ();
	}
}
Example #24
-1
DWORD __stdcall PipeThread( VOID* Parameter )
{
    HANDLE pipeHandle;
    BYTE buffer[1024];
    OBJECT_ATTRIBUTES objAttributes;
    UNICODE_STRING pipeName;
    IO_STATUS_BLOCK isb;
    LARGE_INTEGER timeOut;

    RtlDosPathNameToNtPathName_U(L"\\\\.\\pipe\\Push", &pipeName, NULL, NULL);

    objAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
    objAttributes.RootDirectory = NULL;
    objAttributes.ObjectName = &pipeName;
    objAttributes.Attributes = OBJ_CASE_INSENSITIVE;
    objAttributes.SecurityDescriptor = NULL;
    objAttributes.SecurityQualityOfService = NULL;

    timeOut.QuadPart = 0xfffffffffff85ee0;

    NtCreateNamedPipeFile(
        &pipeHandle,
        GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE,
        &objAttributes,
        &isb,
        FILE_SHARE_READ | FILE_SHARE_WRITE,
        FILE_OPEN_IF,
        FILE_SYNCHRONOUS_IO_NONALERT,
        0,
        0,
        0,
        1,
        1024 * 16,
        1024 * 16,
        &timeOut
        );

    while (pipeHandle != INVALID_HANDLE_VALUE)
    {
        if (ConnectNamedPipe(pipeHandle, NULL) != FALSE)   // wait for someone to connect to the pipe
        {
            IO_STATUS_BLOCK isb;

            while (NtReadFile(
                pipeHandle,
                NULL,
                NULL,
                NULL,
                &isb,
                buffer,
                sizeof(buffer) - 1,
                NULL,
                NULL
                ) == STATUS_SUCCESS)
            {
                /* parse command buffer */

                COMMAND_HEADER *cmdBuffer;
                cmdBuffer = &buffer;

                switch (cmdBuffer->CommandIndex)
                {
                case CMD_STARTHWMON:
                {
                    OnRenderEvent();

                }break;

                case CMD_NOTIFY:
                {
                    UINT16 responseTime;
                    OnProcessEvent(cmdBuffer->ProcessId);
                    File_Write(pipeHandle, &responseTime, 2);
                }break;

                case CMD_SETGPUCLK:
                    if (PushSharedMemory->HarwareInformation.DisplayDevice.EngineClockMax > 1 &&
                        PushSharedMemory->HarwareInformation.DisplayDevice.MemoryClockMax > 1
                        )
                    {
                        GPU_CONFIG_CMD_BUFFER *gpuConfig;
                        gpuConfig = &buffer;

                        GPU_SetEngineClock(gpuConfig->EngineClock);
                        GPU_SetMemoryClock(gpuConfig->MemoryClock);
                        GPU_SetVoltage(gpuConfig->Voltage);
                    }
                    break;

                case CMD_MAXGPUCLK:
                    Hardware_ForceMaxClocks();
                    break;
                case CMD_SETGPUFAN:
                    Adl_SetFanDutyCycle(PushSharedMemory->HarwareInformation.DisplayDevice.FanDutyCycle);
                    break;
                case CMD_GETDSKRSP:
                {
                    UINT32 processId;
                    UINT16 responseTime;

                    processId = cmdBuffer->ProcessId;
                    responseTime = GetDiskResponseTime(processId);

                    File_Write(pipeHandle, &responseTime, 2);
                }break;
                case CMD_CONTROLLERCFG:
                {
                    CONTROLLER_CONFIG_CMD_BUFFER *cmdBuffer;

                    cmdBuffer = &buffer;

                    SetButtonMapping(&cmdBuffer->Map);
                }break;

                case CMD_SAVEPRFL:
                {
                    CONTROLLER_CONFIG_CMD_BUFFER *cmdBuffer;
                    wchar_t fileName[260];

                    cmdBuffer = &buffer;

                    CreatePath(L".\\" GAMES_CONFIG_PATH);
                    GetConfigFileFromProcessId(cmdBuffer->CommandHeader.ProcessId, fileName);

                    WriteConfig(L"ButtonTriangle", cmdBuffer->Map.Triangle, fileName);
                    WriteConfig(L"ButtonCircle", cmdBuffer->Map.Circle, fileName);
                    WriteConfig(L"ButtonCross", cmdBuffer->Map.Cross, fileName);
                    WriteConfig(L"ButtonSquare", cmdBuffer->Map.Square, fileName);
                    WriteConfig(L"DPadUp", cmdBuffer->Map.DpadUp, fileName);
                    WriteConfig(L"DPadRight", cmdBuffer->Map.DpadRight, fileName);
                    WriteConfig(L"DPadDown", cmdBuffer->Map.DpadDown, fileName);
                    WriteConfig(L"DPadLeft", cmdBuffer->Map.DpadLeft, fileName);
                    WriteConfig(L"ButtonL1", cmdBuffer->Map.L1, fileName);
                    WriteConfig(L"ButtonR1", cmdBuffer->Map.R1, fileName);
                    WriteConfig(L"ButtonL2", cmdBuffer->Map.L2, fileName);
                    WriteConfig(L"ButtonR2", cmdBuffer->Map.R2, fileName);
                    WriteConfig(L"ButtonL3", cmdBuffer->Map.L3, fileName);
                    WriteConfig(L"ButtonR3", cmdBuffer->Map.R3, fileName);
                    WriteConfig(L"ButtonSelect", cmdBuffer->Map.Select, fileName);
                    WriteConfig(L"ButtonStart", cmdBuffer->Map.Start, fileName);
                    WriteConfig(L"ButtonPS", cmdBuffer->Map.PS, fileName);
                    WriteConfig(L"LeftStickXpos", cmdBuffer->Map.LStick_Xpos, fileName);
                    WriteConfig(L"LeftStickXneg", cmdBuffer->Map.LStick_Xneg, fileName);
                    WriteConfig(L"LeftStickYpos", cmdBuffer->Map.LStick_Ypos, fileName);
                    WriteConfig(L"LeftStickYneg", cmdBuffer->Map.LStick_Yneg, fileName);
                    WriteConfig(L"RightStickXpos", 0, fileName);
                    WriteConfig(L"RightStickXneg", 0, fileName);
                    WriteConfig(L"RightStickYpos", 0, fileName);
                    WriteConfig(L"RightStickYneg", 0, fileName);

                }break;

                case CMD_BRIGHTNESS:
                {
                    CMD_BUFFER_BRIGHTNESS* cmdBuffer;

                    cmdBuffer = &buffer;

                    SetBrightness(cmdBuffer->Brightness);

                }break;

                }
            }
        }

        DisconnectNamedPipe(pipeHandle);
    }

    return 0;
}