|
1 | 1 | public class Generate { |
2 | 2 |
|
3 | 3 | public static void main(String[] args) { |
4 | | -// comboDirect(); |
5 | | - comboPWM(); |
| 4 | + //comboDirect(); |
| 5 | + comboSingleOutput(); |
| 6 | + // comboPWM(); |
6 | 7 | } |
7 | 8 |
|
8 | 9 | /** |
@@ -55,6 +56,42 @@ static String codeName(int nib) { |
55 | 56 | return cmd; |
56 | 57 | } |
57 | 58 |
|
| 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 | + |
58 | 95 | /** |
59 | 96 | * Generates codes for Combo PWM mode. |
60 | 97 | */ |
|
0 commit comments