Defining a New Page

The pages of commands that are displayed on the screen of the Ultimate Remote are defined in a file called my_pages.h. Open that particular tab. Near the top of the page you will see a series of #include statements that look like this.

// These files contain the IR codes for the various devices we want to use.
#include "sa_cable_codes.h"
#include "samsung_necx_codes.h"
#include "sony_amp_codes.h"
#include "samsung_bluray_codes.h"
#include "adafruit_mini_codes.h"

Notice that in the Arduino IDE, there is a tab for each of these files. We have already added a tab for the RCA TV codes but that doesn't inform the compiler where and how to make use of that information. We need to edit our list of #include statements to add our file. At the bottom of that list enter the following:

#include "rca_tv_codes.h"

Just below that section of code you will find the following list of include statements.

// IRLib2 includes.
// Start out with the base sending library followed by the individual protocols we will use and then
//  tie everything together with the combo file.
#include <IRLibSendBase.h>
#include <IRLib_P01_NEC.h>    
#include <IRLib_P02_Sony.h>
#include <IRLib_P05_Panasonic_Old.h>
#include <IRLib_P07_NECx.h>
#include <IRLib_P08_Samsung36.h>
#include <IRLib_P12_CYKM.h>
#include <IRLibCombo.h>     // After all protocols, include this

These include files are part of IRLib2 and they contain the code that tells your device how to send signals for the particular protocol. Our RCA TV uses NEC protocol and as you can see we've already included IRLib_P01_NEC.h so we don't need to make any changes here. But if you're particular device used a different protocol, perhaps protocol 3, which is called RC5, you would also have to add the following statement to the list.

#include <IRLib_P03_RC5.h>
Warning: You MUST put these include statements in numerical order by their protocol number and conclude with "IRLibCombo.h" or IRLib2 will not compile or operate properly. See the documentation for IRLib2 for further information.

These individual protocol files are stored in arduino/libraries/IRLibProtocols.

You should now continue to scroll down the my_pages.h file. The next thing you will find is a series of definitions that make some of the other coding in this file a little easier. For now you can ignore that section.

It is followed by a series of defines that enumerate the pages. It looks like this:

//These are names of the pages
#define PAGE_CBL 0
#define PAGE_MSAR 1
#define PAGE_KB 2
#define PAGE_AMP 3
#define PAGE_TV 4
#define PAGE_BLU 5
#define PAGE_TEST 6
// The BLE page isn't really a page. It shifts the device into Bluetooth switch control mode. 
// It has to be the last page in the list for everything to work right.
#define PAGE_BLE 7

We will want to add a #define PAGE_RCA_TV. You can order the pages in any order you want, but the PAGE_BLE absolutely must be the highest numbered page. So we will make our new page 7 and change PAGE_BLE to be 8 as follows:

#define PAGE_TEST 6
#define PAGE_RCA_TV 7
// The BLE page isn't really a page. It shifts the device into Bluetooth switch control mode. 
// It has to be the last page in the list for everything to work right.
#define PAGE_BLE 8

The next section of code reads as follows:

// Each page of commands can have a variable width up to COL_MAX. Define the widths here.
const uint8_t Page_Widths[PAGE_BLE+1]= {10, 10, 14, 10, 10, 10, 3};

It defines the width of each of your pages. Most of our pages are 10 commands wide because we developed this on a version of the Ultimate Remote that would only do 10 columns wide. Anything too wide can make it more difficult to navigate especially if you are only using 2 instead of 3 buttons to control the remote. We are going to make this new page 10 columns wide. Note that the third page is a keyboard page which is 14 columns wide. The final page is the "Extra" page that is only 3 columns wide. We have added our page after that extra test page so we will modify this array to say that our new page is 10 columns wide by editing it as follows:

const uint8_t Page_Widths[PAGE_BLE+1]= {10, 10, 14, 10, 10, 10, 3, 10};

Now that we have set up the new page, we will show you how to define the rows of commands for that page in the next section of this tutorial.

This guide was first published on Sep 23, 2019. It was last updated on Sep 23, 2019.

This page (Adding a New Page of Commands) was last updated on Aug 29, 2019.

Text editor powered by tinymce.