 // ---- prototypes -----
 void next_pattern(void);
 
+#if F_CPU == 16000000UL
+#define    TIMER1_INIT         0xF82F
+#else
+#define    TIMER1_INIT         0xFC17
+#endif
+#define    TIMER1_FLAGS        _BV(CS11); // 8Mhz / 8 = 1us per tick.
+
+volatile uint32_t g_time = 0;
+uint16_t g_timer_init = TIMER1_INIT;
+
+ISR (TIMER1_OVF_vect)
+{
+    g_time++;
+    TCNT1 = g_timer_init;
+}
+
+uint32_t cmillis(void)
+{
+    uint32_t temp;
+
+    noInterrupts();
+    temp = g_time;
+    interrupts();
+
+    return temp;
+}
+
 void show_color(color_t *col)
 {
     uint8_t j;

    if (!g_cur_pattern)
        return;
       
    if (g_target && millis() >= g_target)
    {
        g_target += g_delay;
        g_pixels.show();

    g_cur_pattern = g_next_pattern;
    g_next_pattern = NULL;
    
    g_pattern_start = cmillis();
    g_target = g_pattern_start;
    g_error = ERR_OK;
    update_pattern();
