]> git.mxchange.org Git - flightgear.git/commitdiff
KLN89: Add user-adjustable minimum brightness setting.
authorDave Luff <daveluff@ntlworld.com>
Sun, 5 Dec 2010 23:40:05 +0000 (23:40 +0000)
committerDave Luff <daveluff@ntlworld.com>
Sun, 5 Dec 2010 23:40:05 +0000 (23:40 +0000)
src/Instrumentation/KLN89/kln89.cxx
src/Instrumentation/KLN89/kln89.hxx
src/Instrumentation/KLN89/kln89_page_set.cxx
src/Instrumentation/render_area_2d.cxx

index 0778cea26e0b00ff15c94c3d02a0dc4c3b37e6a5..57985a729225ff467e92d60849130018bd244727 100644 (file)
@@ -227,6 +227,7 @@ KLN89::KLN89(RenderArea2D* instrument)
        // Configuration.  Eventually this may be user-achivable in order that settings can be persistent between sessions.
        _suaAlertEnabled = false;
        _altAlertEnabled = false;
+       _minDisplayBrightness = 4;
        
        // Mega-hack - hardwire airport town and state names for the FG base area since we don't have any data for these at the moment
        // TODO - do this better one day!
@@ -308,6 +309,17 @@ void KLN89::update(double dt) {
        // Run any positional calc's required first
        DCLGPS::update(dt);
        
+       // Set the display brightness.  This should be reduced in response to falling light
+       // (i.e. nighttime), or the user covering the photocell that detects the light level.
+       // At the moment I don't know how to detect nighttime or actual light level, so only
+       // respond to the photocell being obscured.
+       // TODO - reduce the brightness in response to nighttime / lowlight.
+       float rgba[4] = {1.0, 0.0, 0.0, 1.0};
+       if(fgGetBool("/instrumentation/kln89/photocell-obscured")) {
+               rgba[0] -= (9 - _minDisplayBrightness) * 0.05;
+       }
+       _instrument->SetPixelColor(rgba);
+       
        _cum_dt += dt;
        if(_blink) {
                if(_cum_dt > 0.2) {
@@ -624,6 +636,22 @@ void KLN89::DtoInitiate(const string& id) {
        DCLGPS::DtoInitiate(id);
 }
 
+void KLN89::SetMinDisplayBrightness(int n) {
+       _minDisplayBrightness = n;
+       if(_minDisplayBrightness < 1) _minDisplayBrightness = 1;
+       if(_minDisplayBrightness > 9) _minDisplayBrightness = 9;
+}
+
+void KLN89::DecrementMinDisplayBrightness() {
+       _minDisplayBrightness--;
+       if(_minDisplayBrightness < 1) _minDisplayBrightness = 1;
+}
+
+void KLN89::IncrementMinDisplayBrightness() {
+       _minDisplayBrightness++;
+       if(_minDisplayBrightness > 9) _minDisplayBrightness = 9;
+}
+
 void KLN89::DrawBar(int page) {
        int px = 1 + (page * 15);
        int py = 1;
index d66cc8cc666e12ffd0df56daba165fdefb19ddb5..052d1b90c3b78aa3322314c53ed48ee298d47fa1 100644 (file)
@@ -87,6 +87,11 @@ public:
        
        inline void SetAltAlertEnabled(bool b) { _altAlertEnabled = b; }
        inline bool GetAltAlertEnabled() { return(_altAlertEnabled); }
+
+       void SetMinDisplayBrightness(int n);    // Set minDisplayBrightness (between 1 and 9)
+       void DecrementMinDisplayBrightness();   // Decrease by 1
+       void IncrementMinDisplayBrightness();   // Increase by 1
+       inline int GetMinDisplayBrightness() { return(_minDisplayBrightness); }
        
        inline bool GetMsgAlert() const { return(!_messageStack.empty()); }
        
@@ -296,6 +301,7 @@ private:
        // Configuration settings that the user can set via. the KLN89 SET pages.
        bool _suaAlertEnabled;          // Alert user to potential SUA entry
        bool _altAlertEnabled;          // Alert user to min safe alt violation
+       int _minDisplayBrightness;      // Minimum display brightness in low light.
 };
 
 #endif  // _KLN89_HXX
index e6bc9c05b9b0c2e7e3ad2ad1ca0834f65454dc16..3ab3228d77df35a0f2642713908092ea75104108 100644 (file)
@@ -168,6 +168,17 @@ void KLN89SetPage::Update(double dt) {
        case 11:
                _kln89->DrawText("MIN DISPLAY", 2, 2, 3);
                _kln89->DrawText("BRIGHTNESS ADJ", 2, 1, 2);
+               if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
+                       if(!_kln89->_blink) {
+                               _kln89->DrawChar('0' + _kln89->GetMinDisplayBrightness(), 2, 6, 0);
+                       }
+                       _kln89->Underline(2, 6, 0, 1);
+               } else {
+                       _kln89->DrawChar('0' + _kln89->GetMinDisplayBrightness(), 2, 6, 0);
+               }
+               if(_kln89->GetMinDisplayBrightness() == 4) {
+                       _kln89->DrawText("Default", 2, 8, 0);
+               }
                break;
        }
        
@@ -208,6 +219,7 @@ void KLN89SetPage::CrsrPressed() {
        case 10:
                break;
        case 11:
+               _maxULinePos = 1;
                break;
        }
 }
@@ -249,6 +261,11 @@ void KLN89SetPage::Knob2Left1() {
                                _kln89->SetDistVelUnitsSI(!_kln89->GetDistVelUnitsSI());
                        }
                        break;
+               case 11:
+                       if(_uLinePos == 1) {
+                               _kln89->DecrementMinDisplayBrightness();
+                       }
+                       break;
                }
        }
 }
@@ -290,6 +307,11 @@ void KLN89SetPage::Knob2Right1() {
                                _kln89->SetDistVelUnitsSI(!_kln89->GetDistVelUnitsSI());
                        }
                        break;
+               case 11:
+                       if(_uLinePos == 1) {
+                               _kln89->IncrementMinDisplayBrightness();
+                       }
+                       break;
                }
        }
 }
index c3230fb67b873bc3e6a3cffa4236477c70a9e0ff..8ad68a74bedc3cdb8293bed2fd9ef4c191c2c35c 100644 (file)
@@ -45,13 +45,14 @@ RenderArea2D::RenderArea2D(int logx, int logy, int sizex, int sizey, int posx, i
     _clipy1 = 0;
     _clipy2 = _logy - 1;
     
+    // Default to black background / white text.
     _backgroundColor[0] = 0.0;
     _backgroundColor[1] = 0.0;
     _backgroundColor[2] = 0.0;
     _backgroundColor[3] = 1.0;
     _pixelColor[0] = 1.0;
-    _pixelColor[1] = 0.0;
-    _pixelColor[2] = 0.0;
+    _pixelColor[1] = 1.0;
+    _pixelColor[2] = 1.0;
     _pixelColor[3] = 1.0;
     
     _ra2d_debug = false;
@@ -117,6 +118,13 @@ void RenderArea2D::Flush() {
     drawing_list.clear();
 }
 
+void RenderArea2D::SetPixelColor(const float* rgba) {
+    _pixelColor[0] = rgba[0];
+    _pixelColor[1] = rgba[1];
+    _pixelColor[2] = rgba[2];
+    _pixelColor[3] = rgba[3];
+}
+
 // Set clipping region in logical units
 void RenderArea2D::SetClipRegion(int x1, int y1, int x2, int y2) {
     _clipx1 = x1;