Просмотр исходного кода

Initialize camera LED intensity without runtime mutex use in global constructor

SybexXx 1 день назад
Родитель
Сommit
cd75d08693
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      code/components/jomjol_controlcamera/ClassControllCamera.cpp

+ 5 - 1
code/components/jomjol_controlcamera/ClassControllCamera.cpp

@@ -282,7 +282,11 @@ CCamera::CCamera(void)
     CCstatus.ImageQuality = camera_config.jpeg_quality;
     CCstatus.ImageFrameSize = camera_config.frame_size;
     CCstatus.CamXclkFreqMhz = xclk;
-    CCstatus.ImageLedIntensity = SetLEDIntensity(LedIntensity);
+    // The global camera object can be constructed before task scheduling is
+    // fully available. Initialize the PWM value without taking its runtime mutexes.
+    LedIntensity = static_cast<int>(
+        static_cast<float>(std::min(std::max(0, LedIntensity), 100)) / 100.0f * 8191.0f);
+    CCstatus.ImageLedIntensity = LedIntensity;
     CCstatus.WaitBeforePicture = 2;
     SetImageWidthHeightFromResolution(CCstatus);