For anyone else who wants to go from a hex IR code to a decimal 'count' pattern to a decimal 'duration' pattern:
Samsung Power hex code (From remotecentral.com):
0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e
Convert to decimal using the hex2dec method in irdude:
38028,169,168,21,63,21,63,21,63,21,21,21,21,21,21,21,21,21,21,21,63,21,63,21,63,21,21,21,21,21,21,21,21,21,21,21,21,21,63,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,63,21,63,21,63,21,63,21,63,21,63,21,1794,169,168,21,21,21,3694
Use the first argument as your frequency and put the rest in an int array for your Count Pattern:
private static final int SAMSUNG_FREQ = 38028;
private static final int[] SAMSUNG_POWER_TOGGLE_COUNT = {169,168,21,63,21,63,21,63,21,21,21,21,21,21,21,21,21,21,21,63,21,63,21,63,21,21,21,21,21,21,21,21,21,21,21,21,21,63,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,63,21,63,21,63,21,63,21,63,21,63,21,1794,169,168,21,21,21,3694};
Use the frequency to find the pulses per second:
Frequency: 38028;
Second: 1,000,000 Microseconds
Second/Frequency = Pulses
1000000/38028 = ~26.3 Pulses
Convert the Count Pattern to Duration Pattern by multiplying each value by the pulses:
169 * 26.3 = 4444
168 * 26.3 = 4418
21 * 26.3 = 552
...
If you want a quick way to get a string with all of the Duration values, then just run your hex code through the hex2dec method and then use that output in this method:
protected String count2duration(String countPattern) {
List<String> list = new ArrayList<String>(Arrays.asList(countPattern.split(",")));
int frequency = Integer.parseInt(list.get(0));
int pulses = 1000000/frequency;
int count;
int duration;
list.remove(0);
for (int i = 0; i < list.size(); i++) {
count = Integer.parseInt(list.get(i));
duration = count * pulses;
list.set(i, Integer.toString(duration));
}
String durationPattern = "";
for (String s : list) {
durationPattern += s + ",";
}
Log.d(TAG, "Frequency: " + frequency);
Log.d(TAG, "Duration Pattern: " + durationPattern);
return durationPattern;
}
That will print the string of decimal duration values to the log. I would then just copy that (not including the first value) and make a static final int array like this:
private static final int[] SAMSUNG_POWER_TOGGLE_DURATION = {4495,4368,546,1638,546,1638,546,1638,546,546,546,546,546,546,546,546,546,546,546,1638,546,1638,546,1638,546,546,546,546,546,546,546,546,546,546,546,546,546,1638,546,546,546,546,546,546,546,546,546,546,546,546,546,1664,546,546,546,1638,546,1638,546,1638,546,1638,546,1638,546,1638,546,46644,4394,4368,546,546,546,96044};
So now that you have your two patterns as static final int arrays, you can transmit:
ConsumerIrManager mCIR;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get a reference to the ConsumerIrManager
mCIR = (ConsumerIrManager) this.getSystemService(Context.CONSUMER_IR_SERVICE);
setContentView(R.layout.consumer_ir);
// Set the OnClickListener for the button so we see when it's pressed.
findViewById(R.id.send_button).setOnClickListener(mSendClickListener);
}
View.OnClickListener mSendClickListener = new View.OnClickListener() {
public void onClick(View v) {
if (!mCIR.hasIrEmitter()) {
Log.e(TAG, "No IR Emitter found
");
return;
}
if (Build.VERSION.SDK_INT == 19) {
int lastIdx = Build.VERSION.RELEASE.lastIndexOf(".");
int VERSION_MR = Integer.valueOf(Build.VERSION.RELEASE.substring(lastIdx+1));
if (VERSION_MR < 3) {
// Before version of Android 4.4.2
mCIR.transmit(SAMSUNG_FREQ, SAMSUNG_POWER_TOGGLE_COUNT);
} else {
// Later version of Android 4.4.3
mCIR.transmit(SAMSUNG_FREQ, SAMSUNG_POWER_TOGGLE_DURATION);
}
}
}
};
Note: I'm not sure which pattern 4.4.4 needs.