********************
Template Device
********************

.. index:: Template Device

Overview
====================

This section discusses the template device driver for the iDigi Dia.  This device driver serves as a
starting point to learn about the structure of device drivers in the Dia as
well as to be used as a template in order to create new drivers.

The template device is a virtual device driver.  It connects to no hardware
peripheral.  The driver is comprised of the following two features:

   *  A counter which updates at a configurable rate.
   *  A pair of two settable channel properties which when set are
      added together and output to a third, gettable channel property.

.. note:: A ``template_driver`` should probably not be left in your
   ``dia.yml`` file for a production system.  It is intended more for
   demonstration and will generate activity that is unlikely to be
   useful.

Configuration
====================

A typical template device configuration block looks like this::

  - name: template
    driver: devices.template_device:TemplateDevice
    settings:
        count_init: 0
        update_rate: 0.1

Settings
--------------------

count_init
  Defines what the initial value of the counter should be
  after the driver starts or after a reset
    
update_rate
  Defines how fast the counter should update, in seconds

Channels
====================

adder_reg1

adder_reg2
    The inputs that generate ``adder_total``

adder_total
    The sum of ``adder_reg1`` and ``adder_reg2``

counter
    The automatically updating value

counter_reset
    Resets ``counter`` to ``counter_init``

global_reset
    Resets all channels to their initial state


