KIR Vars.h: Difference between revisions

From AnalysIR WiKi
Jump to navigation Jump to search
(Created page with "'''''> KontroLIR Home > back''''' Here we provide some commentary about the variables/contan...")
 
mNo edit summary
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:


Here we provide some commentary about the variables/contants defined in '''KIR_Vars.h'''
Here we provide some commentary about the variables/contants defined in '''KIR_Vars.h'''
Essentially, all non-local varaibles are defined here.
Essentially, all non-local variables are defined here.
 
* rowPins/colPins - provides a mapping from row/col number (1-7) to Arduino pins. The index is zero based, such that Col1 is a offset 0.
* scanCode - is set in function isButtonPressed every time a button is pressed. It contains a unique code  for each logical button made up from col/row number plus the Device Mode offset (altMode).
* altMode - This contains the offset for each mode. MODE1 is 0, MODE2 is 49, MODE3 is 93(49*2) etc. These values are preconfigured in KIR_header.h. The value is updated everytime a device mode is changed.
* col - contains the value of the last col (0-6 for  col 1-7). Set in function isButtonPressed every time a button is pressed.
* row - contains the value of the last row (0-6 for  row 1-7). Set in function isButtonPressed every time a button is pressed.
* toggleFlag - is used to manage signal toggling for subsequent presses of the same button, if the protocol uses toggling. We have demonstrated several uses of this toggle in some extensions to IRremote in file KIR_Infrared_Tx.ino (e.g. for RC5, RC6, MSRC6 etc). If you encounter another protocol using a toggle bit, you can use the same approach.
* pcIntCol - this is set by the PCINT ISR to indicate the col that caused the latest interrupt. This information is later used in isButtonPressed function to determine which Row was pressed, which then uniquely identifies the button on the remote.
* maxRepeats - thsi is essentially a table of values, one for each remote button and mode combination. One set of 49 values must be configured foe each mode defined (5 in the reference). As can be seen most values are zero, which means that if the button is kept pressed only one IR signal will be sent. If the value is not zero, the signal will be repeated up to that number of times, provided the button is kept pressed. This is a clever way of ensuring that only buttons that need a repeat are repeated and also serves to save battery life , if the remote is left down the side of a couch with pressure on the buttons.
 
 
 
 
 


* ''rowPins/colPins'' - provides a mapping from row/col number (1-7) to Arduino pins. The index is zero based, such that Col1 is at offset 0.
* ''scanCode'' - is set in function isButtonPressed every time a button is pressed. It contains a unique code  for each logical button made up from col/row number plus the Device Mode offset (altMode).
* ''altMode'' - This contains the offset for each mode. MODE1 is 0, MODE2 is 49, MODE3 is 93(49*2) etc. These values are preconfigured in KIR_header.h. The value is updated everytime a device mode is changed.
* ''col'' - contains the value of the col (0-6 for  col 1-7). Set in function isButtonPressed every time a button is pressed.
* ''row'' - contains the value of the row (0-6 for  row 1-7). Set in function isButtonPressed every time a button is pressed.
* ''toggleFlag'' - is used to manage signal toggling for subsequent presses of the same button, if the protocol uses toggling. We have demonstrated several uses of this toggle in some extensions to IRremote in file KIR_Infrared_Tx.ino (e.g. for RC5, RC6, MSRC6 etc). If you encounter another protocol using a toggle bit, you can use the same approach.
* ''pcIntCol'' - this is set by the PCINT ISR to indicate the col that caused the latest interrupt. This information is later used in isButtonPressed function to determine which Row was pressed, which then uniquely identifies the button on the remote.
* ''maxRepeats'' - this is essentially a table of values, one for each remote button and device mode combination. One set of 49 values must be configured for each mode defined (5 in the reference firmwre). As can be seen most values are zero, which means that if that button is kept pressed only one IR signal will be sent for each press. If the value is not zero, the signal will be repeated up to that number of times, provided the button is kept pressed. This is a clever way of ensuring that only buttons that need a repeat are repeated and also serves to save battery life, if the remote is left down the side of a couch with pressure on the buttons.
* ''KIR_sigTime'' - used to keep track of elapsed time when sending a signal (compensates for code delays and provides much more accruate signal transmission)
* ''vccValue'' - Keep a record of our VCC. If greater than 4.0V (value of 40) then we are not running on batteries and thus do not sleep. Otherwise we assume battery operation and put KontroLIR to sleep after processing every button press.
*''lowBatteryCheck'' - contains a counter that means we check for a low battery every n times a button is pressed. Each time iti s decremented by 1 and when it reaches zero, we check the battery level and reset the value (to lbCheck which is defined in KIR_hearder.h). If the battery is too low (bateryLowThreshold) we put KontroLIR to permanent sleep to avoid any potential corruption etc.






'''''> [[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 08:56, 9 October 2019

> KontroLIR Home > back

Here we provide some commentary about the variables/contants defined in KIR_Vars.h Essentially, all non-local variables are defined here.

  • rowPins/colPins - provides a mapping from row/col number (1-7) to Arduino pins. The index is zero based, such that Col1 is at offset 0.
  • scanCode - is set in function isButtonPressed every time a button is pressed. It contains a unique code for each logical button made up from col/row number plus the Device Mode offset (altMode).
  • altMode - This contains the offset for each mode. MODE1 is 0, MODE2 is 49, MODE3 is 93(49*2) etc. These values are preconfigured in KIR_header.h. The value is updated everytime a device mode is changed.
  • col - contains the value of the col (0-6 for col 1-7). Set in function isButtonPressed every time a button is pressed.
  • row - contains the value of the row (0-6 for row 1-7). Set in function isButtonPressed every time a button is pressed.
  • toggleFlag - is used to manage signal toggling for subsequent presses of the same button, if the protocol uses toggling. We have demonstrated several uses of this toggle in some extensions to IRremote in file KIR_Infrared_Tx.ino (e.g. for RC5, RC6, MSRC6 etc). If you encounter another protocol using a toggle bit, you can use the same approach.
  • pcIntCol - this is set by the PCINT ISR to indicate the col that caused the latest interrupt. This information is later used in isButtonPressed function to determine which Row was pressed, which then uniquely identifies the button on the remote.
  • maxRepeats - this is essentially a table of values, one for each remote button and device mode combination. One set of 49 values must be configured for each mode defined (5 in the reference firmwre). As can be seen most values are zero, which means that if that button is kept pressed only one IR signal will be sent for each press. If the value is not zero, the signal will be repeated up to that number of times, provided the button is kept pressed. This is a clever way of ensuring that only buttons that need a repeat are repeated and also serves to save battery life, if the remote is left down the side of a couch with pressure on the buttons.
  • KIR_sigTime - used to keep track of elapsed time when sending a signal (compensates for code delays and provides much more accruate signal transmission)
  • vccValue - Keep a record of our VCC. If greater than 4.0V (value of 40) then we are not running on batteries and thus do not sleep. Otherwise we assume battery operation and put KontroLIR to sleep after processing every button press.
  • lowBatteryCheck - contains a counter that means we check for a low battery every n times a button is pressed. Each time iti s decremented by 1 and when it reaches zero, we check the battery level and reset the value (to lbCheck which is defined in KIR_hearder.h). If the battery is too low (bateryLowThreshold) we put KontroLIR to permanent sleep to avoid any potential corruption etc.


> KontroLIR Home > back