 
 void loop()
 {
-  handleRfRemoteButtons();
-
   if (!readFrame()) {
     nextFile();
+    startMillis = millis();
     return;
   }
 
-  handleRfRemoteButtons();
+  PendingOperations pending_operations;
+  noInterrupts();
+  memcpy(&pending_operations, &GlobalPendingOperations, sizeof(pending_operations));
+  memset(&GlobalPendingOperations, 0, sizeof(GlobalPendingOperations));
+  interrupts();
+
+  performPendingOperations(pending_operations);
 
   adjustFrameColors();
-
-  while (millis() - startMillis < 49UL) {
-    handleRfRemoteButtons();
-  }
 
   while (millis() - startMillis < 50UL) {
     // busy loop until its time to paint the lights


    case COLOR_CEILING_MODE: {
      switch (button_states) {
        case Pressed::d: Mode = NORMAL_MODE;
        default: return;
        case Pressed::a: r_intensity.lowerCeil(); break;
        case Pressed::b: g_intensity.lowerCeil(); break;
        case Pressed::c: b_intensity.lowerCeil(); break;
      }
    } break;

    case COLOR_FLOOR_MODE: {
      switch (button_states) {
        case Pressed::d: Mode = NORMAL_MODE;
        default: return;
        case Pressed::a: r_intensity.raiseFloor(); break;
        case Pressed::b: g_intensity.raiseFloor(); break;
        case Pressed::c: b_intensity.raiseFloor(); break;
      }
    } break;

    case MISC_MODE: {
      switch (button_states) {
        case Pressed::d: Mode = NORMAL_MODE;
        default: return;
        case Pressed::a: negative = !negative; break;
        case Pressed::b: resetDefaultSettings(); break;
      }
    } break;
  }

  printSettingsIfDebug();
}

void nextFile()

  MACRO_MODE,
  MISC_MODE,
} Mode;

struct PendingOperations
{
  uint8_t cycle_brightness;
  uint8_t skip_video;

  uint8_t cycle_ceiling_red;
  uint8_t cycle_ceiling_green;
  uint8_t cycle_ceiling_blue;

  uint8_t cycle_floor_red;
  uint8_t cycle_floor_green;
  uint8_t cycle_floor_blue;

  uint8_t toggle_negative;
  uint8_t reset_settings;
};

volatile PendingOperations GlobalPendingOperations;

apa106<D, 6>   LEDstrip;
rgb frame[200];
