aboutsummaryrefslogtreecommitdiff
path: root/misc_functions.cpp
blob: a2e19a038eaffb2b459b4945cc833de1386c6b8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "misc_functions.h"

#include <QTime>
#include <QCoreApplication>

void delay(int p_milliseconds)
{
  QTime dieTime = QTime::currentTime().addMSecs(p_milliseconds);

  while(QTime::currentTime() < dieTime)
    QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}

//alternates between true and false every time it is called. useful for certain optimization
bool cyclic_function()
{
  static bool cycle = true;

  if (cycle)
  {
    cycle = false;
    return cycle;
  }

  else
  {
    cycle = true;
    return cycle;
  }
}