Skip to content

Commit 9935cdf

Browse files
committed
Merge branch 'master' of https://github.com/dspinellis/lego-lirc
2 parents 889ab15 + e498e77 commit 9935cdf

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

lirc-code-gen/src/Generate.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
public class Generate {
22

33
public static void main(String[] args) {
4-
// comboDirect();
5-
comboPWM();
4+
//comboDirect();
5+
comboSingleOutput();
6+
// comboPWM();
67
}
78

89
/**
@@ -55,6 +56,42 @@ static String codeName(int nib) {
5556
return cmd;
5657
}
5758

59+
/**
60+
* Generates codes for single output mode
61+
*/
62+
static void comboSingleOutput() {
63+
// Nibble 1 -- Address = 0, Escape = 0, Channel = #, Channel = #.
64+
for (int nibble1 = 0; nibble1 < 4; nibble1++) {
65+
// Nibble 2 -- Output A/B: 0b0100 through 0b0101.
66+
for (int nibble2 = 4; nibble2 <= 5; nibble2++) {
67+
// Nibble 3 -- Output A: 0b0000 through 0b1111.
68+
for (int nibble3 = 0; nibble3 < 16; nibble3++) {
69+
// Print name of code (raw hex string).
70+
System.out.print("\t");
71+
System.out.print((nibble1 & 3) + 1); // Channel
72+
System.out.print((nibble2 & 1) == 0 ? "R" : "B"); // Red / Blue
73+
System.out.print("_");
74+
if (nibble3 == 8)
75+
System.out.print("BRAKE"); // Brake then float
76+
else if ((nibble3 & 8) != 0) {
77+
System.out.print("M"); // Minus
78+
System.out.print(8 - (nibble3 & 7));
79+
} else
80+
System.out.print(nibble3 & 7);
81+
82+
// Print hex formatted code:
83+
System.out.print("\t\t0x");
84+
System.out.print(nibble1);
85+
System.out.print(nibble2);
86+
System.out.print(Integer.toHexString(nibble3).toUpperCase());
87+
// LRC = 0xF xor Nibble 1 xor Nibble 2 xor Nibble 3
88+
System.out.println(Integer.toHexString(
89+
0xF ^ nibble1 ^ nibble2 ^ nibble3).toUpperCase());
90+
}
91+
}
92+
}
93+
}
94+
5895
/**
5996
* Generates codes for Combo PWM mode.
6097
*/

0 commit comments

Comments
 (0)