         analogWrite(RED_PIN, 255 * r);
         analogWrite(GREEN_PIN, 255 * g);
         analogWrite(BLUE_PIN, 255 * b);
-
-        if (cmd)
-                Serial.println(command2string(cmd));
-}
+}

        *bp = v * (1 - s + s * b);
}

enum {
        MODE_STATIC,
        MODE_SMOOTH,
        MODE_FLASH,
        MODE_FADE
};

void setup() {
        Serial.begin(9600);
        pinMode(IR_PIN, INPUT);

        TCCR1C = 0;
        TCNT1 = 0;
        TIMSK1 = 0;

        TCCR3A = 0;
        TCCR3B = 5;
        TCCR3C = 0;
        TCNT3 = 0;
        TIMSK3 = 0;
}

void loop() {
        enum {
                MODE_STATIC,
                MODE_SMOOTH,
                MODE_FLASH,
                MODE_FADE
        };

        const float SMOOTH_FREQ = 0.05,
                    FADE_FREQ = 0.1,
                    STROBE_FREQ = 3,
                    FLASH_FREQ = 4;

        static int mode = MODE_STATIC, strobe_on = 0;
        static float brightness = 1, time = 0, strobe = 0,
                     a_r = 0, a_g = 0, a_b = 0,
                     b_r = 0, b_g = 0, b_b = 0;

        int cmd = command;
        command = 0;

        if (cmd) {
                Serial.print("IR command: ");
                Serial.println(command2string(cmd));
        }

        float elapsed = timer3() * (1024 / 1.6e7);
        time += elapsed;

        switch (cmd) {
        case LIGHT_RED:
                a_r = 1;
                a_g = a_b = 0;
                mode = MODE_STATIC;
                break;
        case LIGHT_GREEN:
                a_r = a_b = 0;
                a_g = 1;
                mode = MODE_STATIC;
                break;
        case LIGHT_BLUE:
                a_r = a_g = 0;
                a_b = 1;
                mode = MODE_STATIC;
                break;
        case LIGHT_SMOOTH:
                mode = MODE_SMOOTH;
                break;
        case LIGHT_OFF:
                a_r = a_g = a_b = 0;
                mode = MODE_STATIC;
                break;
        case LIGHT_BRIGHTER:
