Exemplo n.º 1
0
//****************************************************************************************
ControlLine::ControlLine(uint8_t pin, uint8_t idx, uint8_t modes, ControlLineMode_t mode)
{
	m_pin = pin;
	m_idx = idx;
	m_modes = modes;
	m_mode = mode;
	m_state = 0;

	// init hardware:
	switch (m_mode)
	{
		case DigitalInput:
			pinMode(m_pin, INPUT_PULLUP); //INPUT
			break;
		case DigitalOutput:
			pinMode(m_pin, OUTPUT);
			break;
		case PWM:
			pinMode(m_pin, OUTPUT);
			break;
		case OneWireBus:
			m_pds = new OneWire(m_pin); // (a 4.7K resistor is necessary)
			break;
		default:
			break;
	}

	QueryState(); // preread state
	SetState(EEPROM.read(EEPROM_OFFSET + m_idx)); // set last saved state (DigitalOut and PWM)
}
Exemplo n.º 2
0
gl::Error Query11::queryCounter()
{
    // This doesn't do anything for D3D11 as we don't support timestamps
    ASSERT(getType() == GL_TIMESTAMP_EXT);
    mResultSum = 0;
    mPendingQueries.push_back(QueryState());
    return gl::Error(GL_NO_ERROR);
}
// -----------------------------------------------------------------------------
// CSimulateMessageServerSession::ServiceL()
// Service request from client.
// -----------------------------------------------------------------------------
//
void CSimulateMessageServerSession::ServiceL(const RMessage2& aMessage)
	{
	switch (aMessage.Function())
		{
		case ESimulateMessageServRequestTime:
			RequestTimeL(aMessage);
			break;
		case ESimulateMessageServSendDriver:
			SendDriver(aMessage);
			break;
		case ESimulateMessageServQueryState:
			QueryState(aMessage);
			break;
		case ESimulateMessageServQueryAllLength:
			QueryAllLength(aMessage);
			break;
		case ESimulateMessageServQueryAllData:
			QueryAllData(aMessage);
			break;
		case ESimulateMessageServQueryRemovedLength:
			QueryRemovedLength(aMessage);
			break;
		case ESimulateMessageServQueryRemovedData:
			QueryRemovedData(aMessage);
			break;
		case ESimulateMessageServQueryAllTasks:
			QueryAllTasks(aMessage);
			break;
		case ESimulateMessageServAddTask:
			AddTask(aMessage);
			break;
		case ESimulateMessageServRemoveTask:
			RemoveTask(aMessage);
			break;
		case ESimulateMessageServClearRemoved:
			ClearRemoved();
			break;
		case ESimulateMessageServActiveSchedule:
			iServer.StartTimer();
			break;
		case ESimulateMessageServDeactiveSchedule:
			iServer.StopTimer();
			break;
		case ESimulateMessageServScheduleReboot:
			iServer.StopTimer();
			iServer.StartTimer();
			break;
		default:
			PanicClient(aMessage, EBadRequest);
			break;
		}
	aMessage.Complete(KErrNone);
	}
Exemplo n.º 4
0
UINT CCallbackTimer::SetMessageID( UINT iNewMessageID )
{
	BOOL fRunningState = QueryState();

	//
	//	Let's only accept positive values. :)
	//
	Stop();
	m_MessageID = iNewMessageID;
	//
	//	Only start again if we were previously in the
	//	started state.
	//
	if( fRunningState )
	{
		Start();
	}

	return(  m_MessageID );
}
Exemplo n.º 5
0
gl::Error Query11::pause()
{
    if (mActiveQuery.query != nullptr)
    {
        ID3D11DeviceContext *context = mRenderer->getDeviceContext();

        // If we are doing time elapsed query the end timestamp
        if (getType() == GL_TIME_ELAPSED_EXT)
        {
            context->End(mActiveQuery.endTimestamp);
        }

        context->End(mActiveQuery.query);

        mPendingQueries.push_back(mActiveQuery);
        mActiveQuery = QueryState();
    }

    return flush(false);
}
Exemplo n.º 6
0
int CCallbackTimer::SetTimerValue( int iNewTimerValue )
{
	BOOL fRunningState = QueryState();

	//
	//	Let's only accept positive values. :)
	//
	if( -1 < iNewTimerValue )
	{
		Stop();
		m_TimerValue = (UINT_PTR) iNewTimerValue;
		//
		//	Only start again if we were previously in the
		//	started state.
		//
		if( fRunningState )
		{
			Start();
		}
	}
	return( (int) m_TimerValue );
}
Exemplo n.º 7
0
// this involves positioning of the hud elements so i'm assuming magicka and stamina
// will need separate positions below the health bar.
void ObjectWidget::UpdateComponent(GFxMovieView * view, float * depth)
{
	TESForm * form = LookupFormByID(formId);
	if(form) {
		TESObjectREFR * reference = DYNAMIC_CAST(form, TESForm, TESObjectREFR);
		if(reference) {
			NiPoint3 markerPos;
			reference->GetMarkerPosition(&markerPos);
			markerPos.z += 25;

			float x_out = 0.0;
			float y_out = 0.0;
			float z_out = 0.0;

			GRectF rect = view->GetVisibleFrameRect();

			WorldPtToScreenPt3_Internal(g_worldToCamMatrix, g_viewPort, &markerPos, &x_out, &y_out, &z_out, 1e-5);

			// Move component, update component stats
			y_out = 1.0 - y_out; // Flip y for Flash coordinate system
			y_out = rect.top + (rect.bottom - rect.top) * y_out;
			x_out = rect.left + (rect.right - rect.left) * x_out;

			*depth = z_out;

			bool isVisible = false;
			bool isFriendly = false;
			QueryState(reference, &isVisible, &isFriendly);

			if ((g_hudExtension->hudFlags & HUDExtension::kFlags_HideName) == HUDExtension::kFlags_HideName || (flags & ObjectWidget::kFlag_HideName) == ObjectWidget::kFlag_HideName) {
				params[kProperty_Name].SetString("");
				UpdateText();
			} else {
				const char * text = CALL_MEMBER_FN(reference, GetReferenceName)();
				if (params[kProperty_Name].GetString() != text) {
					params[kProperty_Name].SetString(text);
					UpdateText();
				}
			}

			if ((flags & ObjectWidget::kFlag_UseHostility) == ObjectWidget::kFlag_UseHostility) {
				bool nowFriendly = IsFriendly();
				if (nowFriendly && !isFriendly) { // Turned hostile
					flags &= ~ObjectWidget::kFlag_Friendly;
					UpdateFlags();
					UpdateColors();
				}
				else if (!nowFriendly && isFriendly) { // Turned friendly
					flags |= ObjectWidget::kFlag_Friendly;
					UpdateFlags();
					UpdateColors();
				}
			}

			double scale = min(((100 - z_out * 100) * 10), 50);//(1.0 - z_out) * 100;//min(((100 - z_out * 100) * 10), 50);
			if(object.IsDisplayObject()) {
				GFxValue::DisplayInfo dInfo;
				dInfo.SetPosition(x_out, y_out);
				dInfo.SetScale(scale, scale);
				dInfo.SetVisible(isVisible);
				object.SetDisplayInfo(&dInfo);

				if((flags & kFlag_UpdatePercent) == kFlag_UpdatePercent)
					UpdateValues();
			}
		}
	}
}
Exemplo n.º 8
0
void ObjectWidget::UpdateProperty(UInt32 type)
{
	switch(type)
	{
	// I'm not sure if you need each data type needs their own separate set of flags or not.
	// I'm assuming the show in combat/hide on death/Line of Sight checks are important but I don't know how
	// I'd apply it to magicka and stamina as well.
	case kPropertyType_Flags:
		{
			// Update visibility if necessary
			if((flags & kFlag_ShowInCombat) == kFlag_ShowInCombat || 
				(flags & kFlag_HideOutOfCombat) == kFlag_HideOutOfCombat || 
				(flags & kFlag_HideOnDeath) == kFlag_HideOnDeath) {
				TESForm * form = LookupFormByID(formId);
				if(form) {
					TESObjectREFR * reference = DYNAMIC_CAST(form, TESForm, TESObjectREFR);
					if(reference) {
						bool isVisible = false;
						bool isFriendly = false;
						QueryState(reference, &isVisible, &isFriendly);
						if(object.IsDisplayObject()) {
							GFxValue::DisplayInfo dInfo;
							dInfo.SetVisible(isVisible);
							object.SetDisplayInfo(&dInfo);
						}
					}
				}
			}
		}
		break;
	// Case fall through so it will keep going through the cases
	// until the break; statement is reached.
	case kPropertyType_HealthCurrentValue:
	case kPropertyType_HealthMaximumValue:
	case kPropertyType_MagickaCurrentValue:
	case kPropertyType_MagickaMaximumValue:
	case kPropertyType_StaminaCurrentValue:
	case kPropertyType_StaminaMaximumValue:
		UpdateValues();
		break;
	// Health Cases
	case kPropertyType_HealthPrimaryColor:
	case kPropertyType_HealthSecondaryColor:
	case kPropertyType_HealthFlashColor:
	case kPropertyType_HealthPrimaryFriendlyColor:
	case kPropertyType_HealthSecondaryFriendlyColor:
	case kPropertyType_HealthFlashFriendlyColor:
	// Magicka Cases
	case kPropertyType_MagickaPrimaryColor:
	case kPropertyType_MagickaSecondaryColor:
	case kPropertyType_MagickaFlashColor:
	case kPropertyType_MagickaPrimaryFriendlyColor:
	case kPropertyType_MagickaSecondaryFriendlyColor:
	case kPropertyType_MagickaFlashFriendlyColor:
	// Stamina Cases
	case kPropertyType_StaminaPrimaryColor:
	case kPropertyType_StaminaSecondaryColor:
	case kPropertyType_StaminaFlashColor:
	case kPropertyType_StaminaPrimaryFriendlyColor:
	case kPropertyType_StaminaSecondaryFriendlyColor:
	case kPropertyType_StaminaFlashFriendlyColor:
		UpdateColors();
		break;
	case kPropertyType_HealthFillMode:
	case kPropertyType_MagickaFillMode:
	case kPropertyType_StaminaFillMode:
		UpdateFillMode();
		break;
	case kPropertyType_StartFlash:
		UpdateFlash();
		break;
	case kPropertyType_Name:
		UpdateText();
		break;
	}
}