Using Flags to Emulate Discrete Power Buttons
Posted: Tue Nov 20, 2012 5:31 pm
I have two devices for which I cannot find discrete power codes, including my Motorola cable STB. This would be problematic for switching between activities where devices would end up getting turned off or on when they should not be.
Here is what I did:
1. Created a flag titled CablePower.
2. In the Watch TV Activity startup button, I created a command to send a power toggle command depending on CablePower flag being "OFF".
3. After a short delay, set the CablePower flag to "ON" if flag is "Off".
4. In the All Power Off activity button, I send a command to send a power toggle command depending on CablePower flag being "On".
5. After a short delay, set the CablePower flag to "OFF" if flag is "ON".
6. On the Cable device remote page I created an On Power and Off Power buttons.
7. In the On Power button, I created a command to send a power toggle command depending on CablePower flag being "OFF".
3. After a short delay, set the CablePower flag to "ON" if flag is "OFF".
4. In the Power Off, I send a command to send a power toggle command depending on CablePower flag being "On".
5. After a short delay, set the CablePower flag to "OFF" if flag is "ON".
So basidally what I do is press the power button only if the power flag is in the proper state, and then update the flag to the current state. It seems to be working so far. The trick was to ensure the correct begining state for the flag. I could not set the flag to off when the app is launched since it would always set it to off when I reopened the app after the iPad went to sleep. So I created a page with buttons to set the flag on or off. So far I only used it for the intiial setting, and will remove the page if it continues to operate as expected.
I hope this helps!
Ray
Here is what I did:
1. Created a flag titled CablePower.
2. In the Watch TV Activity startup button, I created a command to send a power toggle command depending on CablePower flag being "OFF".
3. After a short delay, set the CablePower flag to "ON" if flag is "Off".
4. In the All Power Off activity button, I send a command to send a power toggle command depending on CablePower flag being "On".
5. After a short delay, set the CablePower flag to "OFF" if flag is "ON".
6. On the Cable device remote page I created an On Power and Off Power buttons.
7. In the On Power button, I created a command to send a power toggle command depending on CablePower flag being "OFF".
3. After a short delay, set the CablePower flag to "ON" if flag is "OFF".
4. In the Power Off, I send a command to send a power toggle command depending on CablePower flag being "On".
5. After a short delay, set the CablePower flag to "OFF" if flag is "ON".
So basidally what I do is press the power button only if the power flag is in the proper state, and then update the flag to the current state. It seems to be working so far. The trick was to ensure the correct begining state for the flag. I could not set the flag to off when the app is launched since it would always set it to off when I reopened the app after the iPad went to sleep. So I created a page with buttons to set the flag on or off. So far I only used it for the intiial setting, and will remove the page if it continues to operate as expected.
I hope this helps!
Ray