KontrolIR V1.00.ino: Difference between revisions

From AnalysIR WiKi
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
'''''> [[KontroLIR - Arduino compatible IR remote control|KontroLIR Home]] > [[Customizing the Firmware|back]]'''''
'''''> [[KontroLIR - Arduino compatible IR remote control|KontroLIR Home]] > [[Customizing the Firmware|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 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.
* 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.
* 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.
 
'''Loop'''




'''''> [[KontroLIR - Arduino compatible IR remote control|KontroLIR Home]] > [[Customizing the Firmware|back]]'''''
'''''> [[KontroLIR - Arduino compatible IR remote control|KontroLIR Home]] > [[Customizing the Firmware|back]]'''''

Revision as of 03:48, 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 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.
  • 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.
  • 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.

Loop


> KontroLIR Home > back