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