1
0
Fork 0

KLN89: Add user-adjustable minimum brightness setting.

This commit is contained in:
Dave Luff 2010-12-05 23:40:05 +00:00
parent 7a0c2c2e8a
commit f234f76287
4 changed files with 66 additions and 2 deletions

View 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;

View file

@ -88,6 +88,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()); }
void Knob1Right1();
@ -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

View 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;
}
}
}

View 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;