本文整理汇总了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, ®SettingsTemp.normallyClosed.variable);
triacHum.InitPorts(&TRIAC_HUM_PORT, &TRIAC_HUM_DDR, TRIAC_HUM_PIN, ®SettingsHum.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();
//.........这里部分代码省略.........