Index: /trunk/FACT++/src/feedback.cc
===================================================================
--- /trunk/FACT++/src/feedback.cc	(revision 18336)
+++ /trunk/FACT++/src/feedback.cc	(revision 18337)
@@ -74,4 +74,6 @@
 
     vector<double> fVoltOffset;
+
+    uint16_t fMoonMode;
 
     uint16_t fCurrentRequestInterval;
@@ -493,4 +495,27 @@
 
         // -------------------------------------------------------------------------------------
+        // Inner patches to be blocked (operated below the operation voltage) in moon mode
+
+        static const array<int, 14> inner0 =
+        {{
+             62,  63, 130, 131, 132, 133, 134,
+            135, 222, 223, 292, 293, 294, 295,
+        }};
+
+        static const array<int, 23> inner1 =
+        {{
+             58,  59,  60,  61, 129, 138, 139, 140, 141, 142, 143, 218,
+            219, 220, 221, 290, 291, 298, 299, 300, 301, 302, 303,
+        }};
+
+        static const array<int, 43> inner2 =
+        {{
+             42,  43,  44,  45,  55,  56,  57,  70,  71,  78,  79,
+             96,  97,  98,  99, 102, 103, 128, 136, 137, 159, 202,
+            203, 204, 205, 214, 216, 217, 228, 230, 231, 256, 257,
+            258, 259, 262, 263, 288, 289, 296, 297, 310, 318
+        }};
+
+        // -------------------------------------------------------------------------------------
 
         // Nominal overvoltage (w.r.t. the bias setup values)
@@ -546,4 +571,10 @@
                 continue;
 
+            // Check if this is a blocked channel
+            const bool blocked =
+                (fMoonMode>0 && std::find(inner0.begin(), inner0.end(), i)!=inner0.end()) ||
+                (fMoonMode>1 && std::find(inner1.begin(), inner1.end(), i)!=inner1.end()) ||
+                (fMoonMode>2 && std::find(inner2.begin(), inner2.end(), i)!=inner2.end());
+
             // Number of G-APDs in this patch
             const int N = hv.count();
@@ -613,5 +644,6 @@
 
             // Nominal operation voltage with correction for temperature dependence
-            const double Uop = fVoltGapd[i] + fVoltOffset[i] + fTempOffset[i];
+            const double Uop = fVoltGapd[i] + fVoltOffset[i] + fTempOffset[i]
+                + (blocked ? -5 : 0);
 
             // Current overvoltage (at a G-APD with the correct 3900 Ohm resistor)
@@ -685,6 +717,10 @@
             vec[i] = Uset;
 
-            // Calculate statistics only for channels with a valid calibration
-            //if (Uov>0)
+            const double iapd = Iapd*1e6; // A --> uA
+
+            data.I[i]   = iapd;
+            data.Uov[i] = Uov;
+
+            if (!blocked)
             {
                 const int g = hv.group();
@@ -699,11 +735,6 @@
                     max[g] = Uov;
 
-                const double iapd = Iapd*1e6; // A --> uA
-
-                data.I[i]  = iapd;
                 data.Iavg += iapd;
                 data.Irms += iapd*iapd;
-
-                data.Uov[i] = Uov;
 
                 med[2][num[2]++] = iapd;
@@ -932,4 +963,18 @@
     }
 
+    int SetMoonMode(const EventImp &evt)
+    {
+        if (!CheckEventSize(evt.GetSize(), "SetMoonMode", 2))
+            return kSM_FatalError;
+
+        fMoonMode = evt.GetUShort();
+        if (fMoonMode>3)
+            fMoonMode=3;
+
+        Info("New moon mode: "+to_string(fMoonMode));
+
+        return GetCurrentState();
+    }
+
     int Calibrate()
     {
@@ -979,4 +1024,7 @@
         out << "Starting feedback with an offset of " << fUserOffset << "V";
         Message(out);
+
+        if (fMoonMode>0)
+            Message("Moon mode "+to_string(fMoonMode)+" turned on.");
 
         return Feedback::State::kWaitingForData;
@@ -1154,4 +1202,5 @@
                     "|U[V]:Offset per bias channels"),
         fVoltOffset(416),
+        fMoonMode(0),
         fCurrentRequestInterval(0),
         fNumCalibIgnore(30),
@@ -1237,4 +1286,8 @@
             (bind(&StateMachineFeedback::LoadCalibration, this))
             ("");
+
+        AddEvent("SET_MOON_MODE", "S:1", Feedback::State::kConnected, Feedback::State::kCalibrated)
+            (bind(&StateMachineFeedback::SetMoonMode, this, placeholders::_1))
+            ("Operate central pixels at 5V below nominal voltage. 0:off, 1:minimal, 2:medium, 3:maximum size.");
 
 
