Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/dspinellis/lego-lirc

  • Loading branch information
dspinellis committed Jan 10, 2015
2 parents 889ab15 + e498e77 commit 9935cdf0f4226d12532813264c59b10239620d78
Showing with 39 additions and 2 deletions.
  1. +39 −2 lirc-code-gen/src/Generate.java
@@ -1,8 +1,9 @@
public class Generate {

public static void main(String[] args) {
// comboDirect();
comboPWM();
//comboDirect();
comboSingleOutput();
// comboPWM();
}

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

/**
* Generates codes for single output mode
*/
static void comboSingleOutput() {
// Nibble 1 -- Address = 0, Escape = 0, Channel = #, Channel = #.
for (int nibble1 = 0; nibble1 < 4; nibble1++) {
// Nibble 2 -- Output A/B: 0b0100 through 0b0101.
for (int nibble2 = 4; nibble2 <= 5; nibble2++) {
// Nibble 3 -- Output A: 0b0000 through 0b1111.
for (int nibble3 = 0; nibble3 < 16; nibble3++) {
// Print name of code (raw hex string).
System.out.print("\t");
System.out.print((nibble1 & 3) + 1); // Channel
System.out.print((nibble2 & 1) == 0 ? "R" : "B"); // Red / Blue
System.out.print("_");
if (nibble3 == 8)
System.out.print("BRAKE"); // Brake then float
else if ((nibble3 & 8) != 0) {
System.out.print("M"); // Minus
System.out.print(8 - (nibble3 & 7));
} else
System.out.print(nibble3 & 7);

// Print hex formatted code:
System.out.print("\t\t0x");
System.out.print(nibble1);
System.out.print(nibble2);
System.out.print(Integer.toHexString(nibble3).toUpperCase());
// LRC = 0xF xor Nibble 1 xor Nibble 2 xor Nibble 3
System.out.println(Integer.toHexString(
0xF ^ nibble1 ^ nibble2 ^ nibble3).toUpperCase());
}
}
}
}

/**
* Generates codes for Combo PWM mode.
*/

0 comments on commit 9935cdf

Please sign in to comment.
You can’t perform that action at this time.