AppRunLoop

class mono::AppRunLoop

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 exec()

Start executing the run loop.

void CheckUsbDtr()

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

bool 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 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 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 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 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 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 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

void processDynamicTaskQueue()

Execute all tasks in the dynamic task queue

void removeTaskInQueue(IRunLoopTask *task)

Internal method to sow together neightbourghs in the linked list

void process()

Process a single iteratio of the run loop

void checkUsbUartState()

read the UART DTR state if possible

Protected Attributes

bool runLoopActive

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

If set to false, the run loop will exit, and mono might will enter a low power state. TODO: power safe modes and run loops?

bool lastDtrValue

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

bool resetOnUserButton

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

IRunLoopTask *taskQueueHead

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