当前位置: 首页>>代码示例>>C++>>正文


C++ Timer::AddTicks方法代码示例

本文整理汇总了C++中Timer::AddTicks方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::AddTicks方法的具体用法?C++ Timer::AddTicks怎么用?C++ Timer::AddTicks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timer的用法示例。


在下文中一共展示了Timer::AddTicks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(void)
{
	// Enable watchdog (restart avr if program hangs for 2 seconds)
	wdt_enable(WDTO_2S);
	
	Buttons buttons;
	DHT22sensor sensor;
	
	//uart_init(UART_BAUD_SELECT(USART_BAUDRATE, F_CPU));
	extConnector.Init();
	
	// Initialize all connected devices
	//alarm.Init(OnAlarmStarted, OnAlarmEnded);
	alarm.ClearAllFlags();
	sevSegMenu.Init();
	ledIndicators.Init();
	buttons.Init();
	
	sensor.Init();
	sensorRefreshTimer.Init();
	sensorRefreshTimer.SetCounterTop(DHT22_REFRESHTIME);
	
	timerHum.Init();
	timerTemp.Init();
	
	speaker.InitSpeaker();
	speaker.PlayTone();
	
	//sensorResultAverageTemperature.Init();
	//sensorResultAverageHumidity.Init();
	
	MULTIPLEX_Setup();
	Timer_Setup();
	
	//ReadDefaultSettings(); done in readsettings if needed
	ReadSettings();
	
	triacTemp.InitPorts(&TRIAC_TEMP_PORT, &TRIAC_TEMP_DDR, TRIAC_TEMP_PIN, &regSettingsTemp.normallyClosed.variable);
	triacHum.InitPorts(&TRIAC_HUM_PORT, &TRIAC_HUM_DDR, TRIAC_HUM_PIN, &regSettingsHum.normallyClosed.variable);
	
	DHT22result sensorResult = {0,0};
	
	sei();
	//alarm.SetAlarmFlag(AlarmType_SOFTWARE_FAIL);
	//DHT22result tempResult = {0,0};
	while (1)
	{
		wdt_reset();
		uint8_t sendSensorDataOverUart = 0;
		
		if (!sensorRefreshTimer.IsRunning())
		{
			SensorResult sr = sensor.ReadSensor(&sensorResult);
			switch(sr)
			{
				case SensorOK:
				alarm.ClearAlarmFlag(AlarmType_SENSOR_FAILURE);
				bootCompleted = 1; // Enable regulation updates
				sendSensorDataOverUart = 1;
				sensorRefreshTimer.ResetCounter();
				//sensorAverage.ProcessValue(&sensorResult);
				break;
				
				default:
				alarm.SetAlarmFlag(AlarmType_SENSOR_FAILURE);
				
				sprintf_P(buffor, PSTR("E%u"), sr); // Newline gets added in SendAlarmInfo
				extConnector.uPuts(buffor); //uart_puts
				SendAlarmInfo();
				
				case SensorBusy:
				sensorRefreshTimer.AddTicks(20); // Reduce the error flood
				break;
			}
		}
		
		// If alarm is because of bad regulation, show normal menu instead of error code
		sevSegMenu.SetAlarm(alarm.GetActiveCriticalFlags());
		
		// Beep the speaker if buttons are pressed
		ButtonEvent currentButtonEvent = buttons.ProcessInputs();
		
		if (currentButtonEvent > BUTTON_MULTIPLE && currentButtonEvent < BUTTON_LEFT_RAPID )
		{
			speaker.PlayTone();
		}
		
		sevSegMenu.MainMenuUpdate(currentButtonEvent, &sensorResult);
		
		//////////////////////////////////////////////////////////////////////////
		// Regulation
		//_delay_ms(1);
		RegulationResult resTemp, resHum;
		
		resTemp = RegulationUpdate(AlarmType_TEMPERATURE_REGULATION, &sensorResult);
		resHum = RegulationUpdate(AlarmType_HUMIDITY_REGULATION, &sensorResult);
		
		//////////////////////////////////////////////////////////////////////////
		// Repaint LEDs
		sevSegMenu.TurnOnMenuLeds();
//.........这里部分代码省略.........
开发者ID:Klocman,项目名称:MSREG,代码行数:101,代码来源:MSREG_universal.cpp


注:本文中的Timer::AddTicks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。