Simu: add support for backlight off
This commit is contained in:
committed by
Raphael Coeffic
parent
3ae39a3050
commit
dc75b4916d
+23
-23
@@ -531,48 +531,48 @@ void OpenTxSim::refreshDisplay()
|
||||
lightEnabled = (bool)isBacklightEnabled();
|
||||
TRACE("backlight %s", lightEnabled ? "ON" : "OFF");
|
||||
}
|
||||
|
||||
|
||||
#if !defined(COLORLCD)
|
||||
FXColor offColor = isBacklightEnabled() ? BL_COLOR : FXRGB(200, 200, 200);
|
||||
#if LCD_DEPTH == 1
|
||||
FXColor onColor = FXRGB(0, 0, 0);
|
||||
#endif
|
||||
for (int x=0; x<LCD_W; x++) {
|
||||
for (int y=0; y<LCD_H; y++) {
|
||||
for (int x = 0; x < LCD_W; x++) {
|
||||
for (int y = 0; y < LCD_H; y++) {
|
||||
#if defined(COLORLCD)
|
||||
pixel_t z = simuLcdBuf[y * LCD_W + x];
|
||||
if (1) {
|
||||
if (z == 0) {
|
||||
setPixel(x, y, FXRGB(0, 0, 0));
|
||||
}
|
||||
else if (z == 0xFFFF) {
|
||||
setPixel(x, y, FXRGB(255, 255, 255));
|
||||
}
|
||||
else {
|
||||
FXColor color = FXRGB(((z & 0xF800) >> 8) + ((z & 0xE000) >> 13), ((z & 0x07E0) >> 3) + ((z & 0x0600) >> 9), (((z & 0x001F) << 3) & 0x00F8) + ((z & 0x001C) >> 2));
|
||||
setPixel(x, y, color);
|
||||
}
|
||||
}
|
||||
#elif LCD_DEPTH == 4
|
||||
pixel_t * p = &simuLcdBuf[y / 2 * LCD_W + x];
|
||||
pixel_t z = simuLcdBuf[y * LCD_W + x];
|
||||
FXColor color =
|
||||
FXRGB(((z & 0xF800) >> 8) + ((z & 0xE000) >> 13),
|
||||
((z & 0x07E0) >> 3) + ((z & 0x0600) >> 9),
|
||||
(((z & 0x001F) << 3) & 0x00F8) + ((z & 0x001C) >> 2));
|
||||
setPixel(x, y, color);
|
||||
#else
|
||||
#if LCD_DEPTH == 4
|
||||
pixel_t *p = &simuLcdBuf[y / 2 * LCD_W + x];
|
||||
uint8_t z = (y & 1) ? (*p >> 4) : (*p & 0x0F);
|
||||
if (z) {
|
||||
FXColor color;
|
||||
if (isBacklightEnabled())
|
||||
color = FXRGB(47-(z*47)/15, 123-(z*123)/15, 227-(z*227)/15);
|
||||
color = FXRGB(47 - (z * 47) / 15, 123 - (z * 123) / 15,
|
||||
227 - (z * 227) / 15);
|
||||
else
|
||||
color = FXRGB(200-(z*200)/15, 200-(z*200)/15, 200-(z*200)/15);
|
||||
color = FXRGB(200 - (z * 200) / 15, 200 - (z * 200) / 15,
|
||||
200 - (z * 200) / 15);
|
||||
setPixel(x, y, color);
|
||||
}
|
||||
#else
|
||||
if (simuLcdBuf[x+(y/8)*LCD_W] & (1<<(y%8))) {
|
||||
#else // LCD_DEPTH == 1
|
||||
if (simuLcdBuf[x + (y / 8) * LCD_W] & (1 << (y % 8))) {
|
||||
setPixel(x, y, onColor);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
setPixel(x, y, offColor);
|
||||
}
|
||||
#endif // !defined(COLORLCD)
|
||||
}
|
||||
}
|
||||
#if defined(COLORLCD)
|
||||
if (!lightEnabled) { bmp->fade(0, 50); }
|
||||
#endif
|
||||
|
||||
bmp->render();
|
||||
bmf->setImage(bmp);
|
||||
|
||||
@@ -329,8 +329,7 @@ void boardOff()
|
||||
|
||||
bool isBacklightEnabled()
|
||||
{
|
||||
if(globalData.unexpectedShutdown)
|
||||
return true;
|
||||
if (globalData.unexpectedShutdown) return true;
|
||||
return boardBacklightOn;
|
||||
}
|
||||
|
||||
|
||||
@@ -557,16 +557,24 @@ void backlightEnable(uint8_t dutyCycle = 0);
|
||||
#else
|
||||
#define BACKLIGHT_LEVEL_MIN 46
|
||||
#endif
|
||||
#if defined(SIMU)
|
||||
#define BACKLIGHT_ENABLE()
|
||||
#define BACKLIGHT_DISABLE()
|
||||
#define isBacklightEnabled(...) true
|
||||
#else
|
||||
extern bool boardBacklightOn;
|
||||
#define BACKLIGHT_ENABLE() {boardBacklightOn = true; backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : BACKLIGHT_LEVEL_MAX - currentBacklightBright);}
|
||||
#define BACKLIGHT_DISABLE() {boardBacklightOn = false; backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && (g_eeGeneral.backlightMode != e_backlight_mode_off)) ? 0 : g_eeGeneral.blOffBright);}
|
||||
#define BACKLIGHT_ENABLE() \
|
||||
{ \
|
||||
boardBacklightOn = true; \
|
||||
backlightEnable(globalData.unexpectedShutdown \
|
||||
? BACKLIGHT_LEVEL_MAX \
|
||||
: BACKLIGHT_LEVEL_MAX - currentBacklightBright); \
|
||||
}
|
||||
#define BACKLIGHT_DISABLE() \
|
||||
{ \
|
||||
boardBacklightOn = false; \
|
||||
backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX \
|
||||
: ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && \
|
||||
(g_eeGeneral.backlightMode != e_backlight_mode_off)) \
|
||||
? 0 \
|
||||
: g_eeGeneral.blOffBright); \
|
||||
}
|
||||
bool isBacklightEnabled();
|
||||
#endif
|
||||
|
||||
#if !defined(SIMU)
|
||||
void usbJoystickUpdate();
|
||||
|
||||
@@ -71,6 +71,10 @@ void lcdOn(){
|
||||
backlightEnable(BACKLIGHT_LEVEL_MAX);
|
||||
}
|
||||
|
||||
bool isBacklightEnabled() {
|
||||
return lastDutyCycle != 0;
|
||||
bool boardBacklightOn;
|
||||
|
||||
bool isBacklightEnabled()
|
||||
{
|
||||
if (globalData.unexpectedShutdown) return true;
|
||||
return boardBacklightOn;
|
||||
}
|
||||
|
||||
@@ -417,21 +417,32 @@ void lcdOn();
|
||||
|
||||
// Backlight driver
|
||||
void backlightInit();
|
||||
#if defined(SIMU) || !defined(__cplusplus)
|
||||
#define backlightEnable(...)
|
||||
#define isBacklightEnabled() (true)
|
||||
#else
|
||||
void backlightEnable(uint8_t dutyCycle = 0);
|
||||
void backlightEnable(uint8_t dutyCycle);
|
||||
bool isBacklightEnabled();
|
||||
#endif
|
||||
|
||||
#define BACKLIGHT_LEVEL_MAX 100
|
||||
#define BACKLIGHT_FORCED_ON BACKLIGHT_LEVEL_MAX + 1
|
||||
#define BACKLIGHT_LEVEL_MIN 1
|
||||
|
||||
#define BACKLIGHT_ENABLE() backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : BACKLIGHT_LEVEL_MAX - currentBacklightBright)
|
||||
#define BACKLIGHT_DISABLE() backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && (g_eeGeneral.backlightMode != e_backlight_mode_off)) ? 0 : g_eeGeneral.blOffBright)
|
||||
extern bool boardBacklightOn;
|
||||
|
||||
#define BACKLIGHT_ENABLE() \
|
||||
{ \
|
||||
boardBacklightOn = true; \
|
||||
backlightEnable(globalData.unexpectedShutdown \
|
||||
? BACKLIGHT_LEVEL_MAX \
|
||||
: BACKLIGHT_LEVEL_MAX - currentBacklightBright) \
|
||||
}
|
||||
|
||||
#define BACKLIGHT_DISABLE() \
|
||||
{ \
|
||||
boardBacklightOn = false; \
|
||||
backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX \
|
||||
: ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && \
|
||||
(g_eeGeneral.backlightMode != e_backlight_mode_off)) \
|
||||
? 0 \
|
||||
: g_eeGeneral.blOffBright) \
|
||||
}
|
||||
|
||||
#if !defined(SIMU)
|
||||
void usbJoystickUpdate();
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
bool isBacklightEnabled() { return false; }
|
||||
bool boardBacklightOn = false;
|
||||
bool isBacklightEnabled() { return boardBacklightOn; }
|
||||
|
||||
void backlightEnable(unsigned char) {}
|
||||
void backlightEnable(unsigned char, unsigned char) {}
|
||||
void backlightDisable() {}
|
||||
|
||||
Reference in New Issue
Block a user