 void hsv2rgb(float h, float s, float v, float* rp, float* bp, float* gp) {
         float r, g, b;
 
-        if (h < 0 || h >= 1)
-                h = 0;
+        while (h < 0)
+                h += 1;
+        while (h >= 1)
+                h -= 1;
         clamp(&s, 0, 1);
         clamp(&v, 0, 1);
 

                state = HEAD_HIGH;
                break;
        case HEAD_HIGH:
                state = elapsed >= MS(8.9) && elapsed <= MS(9.1) ? HEAD_LOW : IDLE;
                break;
        case HEAD_LOW:
                if (elapsed >= MS(4.4) && elapsed <= MS(4.6)) {
                        state = DATA_HIGH;
                        bits = 0;
                        data[0] = data[1] = data[2] = data[3] = 0;
                } else if (elapsed >= MS(2.15) && elapsed <= MS(2.35)) {
                        state = REPEAT;
                } else {
                        state = IDLE;

        LIGHT_SMOOTH,
};
volatile int command = 0;
volatile int repeated = 0;

const char* command2string(int c) {
        switch (c) {
