KontrolIR V1.00.ino: Difference between revisions

From AnalysIR WiKi
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 4: Line 4:


'''Setup'''
'''Setup'''
* first we init the MCU frequncy divider to match the setting selected in the IDE.  The crystal used is 16MHz, so for 8MHz operation the clock needs to be divided by 2.We suggest using 8Mhz with this firmware for the best balance between battery life and IR performance. With other firmware loaded, by all means use 16MHz.
* First we init the MCU frequncy divider to match the setting selected in the Arduino IDE.  The crystal used is 16MHz, so for 8MHz operation the clock needs to be divided by a factor of 2. We suggest using 8Mhz with this firmware for the best balance between battery and IR performance. With other firmware loaded ''(e.g. IRremote)'', by all means use 16MHz etc.
* Then we initialise all non-keypad related pins - for the optional IRreceivers and I2C EEPROM snd their related power supply via GPIO. the defaul state for these devices is powered dowm.
* Then we initialise all non-keypad related pins - for the optional IR receivers and I2C EEPROM snd their related power supply via GPIO. The default state for these devices is powered dowm.
* Next we init the keypad buttons. each button is mapped to a particular Row/Col combination.(see section on pin outs) The 7 Cols are defaulted to INPUT_PULLUP and the 7 Rows are defaulted to OUTPUT LOW. This allows us to make use of PCINT interrupts on the COL pins to detect when a button is pressed during PWR_DOWN mode. Once the MCU wakes up, we cimmediately check to see which COL was pulled LOW and search each ROW to find the actual button that was pressed. If more than one button was pressed we take the first one found.
* Next we init the keypad buttons. Each button is mapped to a particular Row/Col combination.''(see section on pin outs)'' The 7 Cols are defaulted to INPUT_PULLUP and the 7 Rows are defaulted to OUTPUT LOW. This allows us to make use of PCINT interrupts on the COL pins to detect when a button is pressed during PWR_DOWN mode. Once the MCU wakes up ''(Triggered by the PCINT)'', we cimmediately check to see which COL was pulled LOW and search each ROW to find the actual button that was pressed. If more than one button was pressed we assume the first one found is the one that was pressed.


'''Loop'''
'''Loop'''

Revision as of 04:53, 8 October 2019

> KontroLIR Home > back

This is the min Arduino sketch file, containing both the setup and loop functions.

Setup

  • First we init the MCU frequncy divider to match the setting selected in the Arduino IDE. The crystal used is 16MHz, so for 8MHz operation the clock needs to be divided by a factor of 2. We suggest using 8Mhz with this firmware for the best balance between battery and IR performance. With other firmware loaded (e.g. IRremote), by all means use 16MHz etc.
  • Then we initialise all non-keypad related pins - for the optional IR receivers and I2C EEPROM snd their related power supply via GPIO. The default state for these devices is powered dowm.
  • Next we init the keypad buttons. Each button is mapped to a particular Row/Col combination.(see section on pin outs) The 7 Cols are defaulted to INPUT_PULLUP and the 7 Rows are defaulted to OUTPUT LOW. This allows us to make use of PCINT interrupts on the COL pins to detect when a button is pressed during PWR_DOWN mode. Once the MCU wakes up (Triggered by the PCINT), we cimmediately check to see which COL was pulled LOW and search each ROW to find the actual button that was pressed. If more than one button was pressed we assume the first one found is the one that was pressed.

Loop


> KontroLIR Home > back