AppRunLoop

class

This is the event run-loop for all mono applications. This class is instantiated and used inside the IApplicationContext interface. You should not interact with this class directly.

The run loop handles non-critical periodicly tasks. Classes can install tasks in the run-loop. Such classes are usually repetitive timers or lazy interrupt handlers.

Some standard system tasks are handled staticly inside the loop, like the USB serial reads.

Public Functions

void AppRunLoop::exec()

Start executing the run loop.

void AppRunLoop::CheckUsbDtr()

Do a single check of the DTR on the virtual UART.

bool AppRunLoop::addDynamicTask(IRunLoopTask *task)

Add a task to the dynamic task queue. This task is repeated over and over, until it reports that its should not be scheduled.

The task is added to a linked list, runtime is n.

Return
Always true at this point

bool AppRunLoop::removeDynamicTask(IRunLoopTask *task)

Remove a task from the dynamic task queue. This will search the queue for he pointer provided, and remove it.

Return
true if the object was found and removed, false otherwise.
Parameters
  • task -

    A pointer to the object, that should be removed

void AppRunLoop::setResetOnUserButton(bool roub)

Sets the Reset on User Button mode.

If true the run loop will check the user button, and if pressed it will trigger a software reset.

Parameters
  • roub -

    true will reset on user button, false is normal functionality.

void AppRunLoop::quit()

Terminate the run loop. Application events and more will stop working

You should use this, if you use your own embedded run loops.

Public Members

bool mono::AppRunLoop::resetOnDTR

As default behaviour the run loop will force a reset on high-to-low transition on the serial ports DTR (Data Terminal Ready) line.

This property controls this feature, setting it to true will enable software reset via the serial connection. This means the monoprog programmer can reset the device and connect to the bootloader.

Setting this to false means monoprog cannot automatically reset into the bootloader, you must press the reset button yourself.

uint32_t mono::AppRunLoop::TouchSystemTime

The CPU time used on proccessing touch input. This includes:

  • ADC sampling (approx 16 samples)
  • Touch value evaluation, and possible convertion into events
  • Traversing the responder chain
  • Handling TouchBegin, TouchEnd & TouchMove, and any function they call

This time includes the execution of your code if you have any button handlers or touch based event callbacks.

uint32_t mono::AppRunLoop::DynamicTaskQueueTime

The CPU time used on processing the dynamic task queue The time spend here include all queued tasks and callbacks. these could be:

  • Timer callback
  • Any QueueInterrupt you might have in use
  • All display painting routines (repainting of views subclasses)
  • Any custom active IRunLoopTask you might use

Nearly all callbacks are executed with origin inside the dynamic task queue. Expect that the majority of your code are executed here.

Protected Functions

bool runLoopActive mono::AppRunLoop::__DEPRECATED("Will be removed in future releases", "")

As long as this is true the stadard run loop will run

If set to false, the run loop will exit and main() will return, which you should absolutely not do!.

void AppRunLoop::processDynamicTaskQueue()

Execute all tasks in the dynamic task queue

void AppRunLoop::removeTaskInQueue(IRunLoopTask *task)

Internal method to sow together neightbourghs in the linked list

void AppRunLoop::process()

Process a single iteration of the run loop

void AppRunLoop::checkUsbUartState()

read the UART DTR state if possible

Protected Attributes

bool mono::AppRunLoop::lastDtrValue

The last seen serial DTR value. Reset can only happen in transitions.

bool mono::AppRunLoop::resetOnUserButton

Set to true if you want the run loop to call software reset when pressing the user button. Initial value is false

IRunLoopTask *mono::AppRunLoop::taskQueueHead

A pointer to the head task of the dynamic task queue. If no task are in the queue, this is NULL