Post 4 made on Tuesday December 20, 2016 at 03:21 |
mrage87 Lurking Member |
Joined: Posts: | November 2016 3 |
|
|
Hi
I've gone back and rewritten the entire program today and manually changed all the values to be based on the formula above. I have yet to test it but tomorrow Ill give it a shot and see what the results are. Probably made a few errors here and there that I need to go over. Its nice that I can actually see a pattern the buttons use in my arrays as well.
Here is my terrible programming (with a lot of test code) if anyone is interested
#include AIRremote.h
// commands for xr2 comcast unsigned int btn0[] = {1,7,0,15,4,4,3,14,1,15,0,0,0,0,0,0}; unsigned int btn1[] = {1,7,0,15,4,4,3,14,1,14,0,0,0,1,0,0}; unsigned int btn2[] = {1,7,0,15,4,4,3,14,1,13,0,0,0,2,0,0}; unsigned int btn3[] = {1,7,0,15,4,4,3,14,1,12,0,0,0,3,0,0}; unsigned int btn4[] = {1,7,0,15,4,4,3,14,1,11,0,0,0,4,0,0}; unsigned int btn5[] = {1,7,0,15,4,4,3,14,1,10,0,0,0,5,0,0}; unsigned int btn6[] = {1,7,0,15,4,4,3,14,1,9 ,0,0,0,6,0,0}; unsigned int btn7[] = {1,7,0,15,4,4,3,14,1,8 ,0,0,0,7,0,0}; unsigned int btn8[] = {1,7,0,15,4,4,3,14,1,7 ,0,0,0,8,0,0}; unsigned int btn9[] = {1,7,0,15,4,4,3,14,1,6 ,0,0,0,9,0,0}; unsigned int btnEnter[] = {1,7,0,15,4,4,3,14,1,8 ,0,0,2,5,0,0}; unsigned int currentRaw[] = {99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; unsigned int currentShort[] = {99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; //Channel List const int savedChannels[] = {136, 255, 814, 823, 832, 839, 854, 855, 863, 866, 872}; unsigned int currentChannel = 0; //Signal/Delay Tuning unsigned int khz = 38; // Freq unsigned int delayAfterButtonPress = 2000; // As stated int burstScrew = 0; // Add or Subtract from all timing defaults in [us] int burstOn = 208; // Burst timing while on unsigned int halfFrame = 13800; // Half Frame Timing unsigned long fullFrame = 80400; //End Frame Timing
// const const int burstOnScrewed = burstScrew + burstOn;
//Hardware Config int PUSHBUTTON1 = 8; int ledPin = 13;
// IRemote Reqs IRsend irsend;
void setup() { pinMode(PUSHBUTTON1, INPUT_PULLUP); pinMode(ledPin, OUTPUT); Serial.begin(9600); buildRawInitial(); // Fills currentRaw array variables }
void loop() { if (digitalRead(PUSHBUTTON1) == LOW) { sendCommands(); } }
void buildRawInitial() { // Fills in BurstOn + Screw for(int i = 0; i < 36; i = i + 2) { currentRaw[i] = burstOnScrewed; } //Fills in Half and FullFrane Timings currentRaw[17] = halfFrame; currentRaw[35] = fullFrame; }
void buildShort(unsigned int selectedBTN) { if (selectedBTN == 1) { memcpy( currentShort, btn1, 16*sizeof(int) ); } else if (selectedBTN == 2) { memcpy( currentShort, btn2, 16*sizeof(int) ); } else if (selectedBTN == 3) { memcpy( currentShort, btn3, 16*sizeof(int) ); } else if (selectedBTN == 4) { memcpy(currentShort, btn4, 16*sizeof(int) ); } else if (selectedBTN == 5) { memcpy(currentShort, btn5, 16*sizeof(int) ); } else if (selectedBTN == 6) { memcpy( currentShort, btn6, 16*sizeof(int) ); } else if (selectedBTN == 7) { memcpy( currentShort, btn7, 16*sizeof(int) ); } else if (selectedBTN == 8) { memcpy(currentShort, btn8, 16*sizeof(int) ); } else if (selectedBTN == 9) { memcpy(currentShort, btn9, 16*sizeof(int) ); } else if (selectedBTN == 0) { memcpy(currentShort, btn0, 16*sizeof(int) ); } else if (selectedBTN == 11) { memcpy(currentShort, btnEnter, 16*sizeof(int) ); }
// Build currentRaw int ix = 0; for(int i = 1; i < 36; i = i + 2) { if (i != 17) { currentRaw[i] = (currentShort[ix] * 138) + 758 + burstScrew; ix = ix + 1; } } }
void sendCommands(){ int testInt = savedChannels[currentChannel]; int press[3] = {999,999,999}; press[0] = testInt / 100; press[1] = (testInt - press[0] * 100) / 10; press[2] = (testInt - (press[0] * 100) - (press[1] * 10)) / 1;
//Send Val 1 buildShort(press[0]); irsend.sendRaw(currentRaw,36, khz); delay(delayAfterButtonPress);
//Send Val 2 buildShort(press[1]); irsend.sendRaw(currentRaw,36, khz); delay(delayAfterButtonPress);
//Send Val 3 buildShort(press[2]); irsend.sendRaw(currentRaw,36, khz); delay(delayAfterButtonPress);
//Send Enter buildShort(11); irsend.sendRaw(currentRaw,36, khz); delay(delayAfterButtonPress);
// Go to next channel currentChannel = currentChannel + 1; if (currentChannel == sizeof(btn1)/sizeof(int)) { currentChannel = 0; } }
Also sorry if this is in the wrong place. I've never posted here before and wasnt sure if it was a remote problem or something else when I initiallycreated the topic.
|
|
|