Moved the setBacklightLevel() API function from platform.h to display.h
This commit is contained in:
parent
163a3df607
commit
8019b29947
|
|
@ -109,6 +109,14 @@ bool display_renderingInProgress();
|
||||||
*/
|
*/
|
||||||
void display_setContrast(uint8_t contrast);
|
void display_setContrast(uint8_t contrast);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set level of display backlight.
|
||||||
|
* NOTE: not all the display controllers support backlight control, thus on some
|
||||||
|
* targets this function has no effect.
|
||||||
|
* @param level: display backlight level, normalised value with range 0 - 100.
|
||||||
|
*/
|
||||||
|
void display_setBacklightLevel(uint8_t level);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -142,13 +142,6 @@ void platform_beepStart(uint16_t freq);
|
||||||
*/
|
*/
|
||||||
void platform_beepStop();
|
void platform_beepStop();
|
||||||
|
|
||||||
/**
|
|
||||||
* This function sets the screen backlight to the specified level.
|
|
||||||
* @param level: backlight level, from 0 (backlight off) to 100 (backlight at
|
|
||||||
* full brightness).
|
|
||||||
*/
|
|
||||||
void platform_setBacklightLevel(uint8_t level);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns a pointer to a data structure containing all the
|
* This function returns a pointer to a data structure containing all the
|
||||||
* hardware information.
|
* hardware information.
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ void openrtx_init()
|
||||||
ui_drawSplashScreen(true);
|
ui_drawSplashScreen(true);
|
||||||
gfx_render();
|
gfx_render();
|
||||||
sleepFor(0u, 30u);
|
sleepFor(0u, 30u);
|
||||||
platform_setBacklightLevel(state.settings.brightness);
|
display_setBacklightLevel(state.settings.brightness);
|
||||||
|
|
||||||
#if defined(GPS_PRESENT)
|
#if defined(GPS_PRESENT)
|
||||||
// Detect and initialise GPS
|
// Detect and initialise GPS
|
||||||
|
|
|
||||||
|
|
@ -728,7 +728,7 @@ static void _ui_changeBrightness(int variation)
|
||||||
if(state.settings.brightness > 100) state.settings.brightness = 100;
|
if(state.settings.brightness > 100) state.settings.brightness = 100;
|
||||||
if(state.settings.brightness < 5) state.settings.brightness = 5;
|
if(state.settings.brightness < 5) state.settings.brightness = 5;
|
||||||
|
|
||||||
platform_setBacklightLevel(state.settings.brightness);
|
display_setBacklightLevel(state.settings.brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SCREEN_CONTRAST
|
#ifdef SCREEN_CONTRAST
|
||||||
|
|
@ -839,7 +839,7 @@ static void _ui_enterStandby()
|
||||||
|
|
||||||
standby = true;
|
standby = true;
|
||||||
redraw_needed = false;
|
redraw_needed = false;
|
||||||
platform_setBacklightLevel(0);
|
display_setBacklightLevel(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _ui_exitStandby(long long now)
|
static bool _ui_exitStandby(long long now)
|
||||||
|
|
@ -851,7 +851,7 @@ static bool _ui_exitStandby(long long now)
|
||||||
|
|
||||||
standby = false;
|
standby = false;
|
||||||
redraw_needed = true;
|
redraw_needed = true;
|
||||||
platform_setBacklightLevel(state.settings.brightness);
|
display_setBacklightLevel(state.settings.brightness);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -564,7 +564,7 @@ void _ui_enterStandby()
|
||||||
|
|
||||||
standby = true;
|
standby = true;
|
||||||
redraw_needed = false;
|
redraw_needed = false;
|
||||||
platform_setBacklightLevel(0);
|
display_setBacklightLevel(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _ui_exitStandby(long long now)
|
bool _ui_exitStandby(long long now)
|
||||||
|
|
@ -576,7 +576,7 @@ bool _ui_exitStandby(long long now)
|
||||||
|
|
||||||
standby = false;
|
standby = false;
|
||||||
redraw_needed = true;
|
redraw_needed = true;
|
||||||
platform_setBacklightLevel(state.settings.brightness);
|
display_setBacklightLevel(state.settings.brightness);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,15 @@
|
||||||
#ifndef BACKLIGHT_H
|
#ifndef BACKLIGHT_H
|
||||||
#define BACKLIGHT_H
|
#define BACKLIGHT_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Low-level driver for backlight dimming control.
|
* Low-level driver for backlight dimming control.
|
||||||
* This header file only provides the API for driver initialisation and shutdown,
|
* This header file only provides the API for driver initialisation and shutdown,
|
||||||
* while effective setting of backlight level is provided by target-specific
|
* while effective setting of backlight level is provided by target-specific
|
||||||
* sources by implementating platform_setBacklightLevel().
|
* sources by implementating display_setBacklightLevel().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -38,4 +42,9 @@ void backlight_init();
|
||||||
*/
|
*/
|
||||||
void backlight_terminate();
|
void backlight_terminate();
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* BACKLIGHT_H */
|
#endif /* BACKLIGHT_H */
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ void backlight_terminate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is defined in platform.h
|
* This function is defined in display.h
|
||||||
*/
|
*/
|
||||||
void platform_setBacklightLevel(uint8_t level)
|
void display_setBacklightLevel(uint8_t level)
|
||||||
{
|
{
|
||||||
if(level > 100) level = 100;
|
if(level > 100) level = 100;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,9 +128,9 @@ void backlight_terminate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is defined in platform.h
|
* This function is defined in display.h
|
||||||
*/
|
*/
|
||||||
void platform_setBacklightLevel(uint8_t level)
|
void display_setBacklightLevel(uint8_t level)
|
||||||
{
|
{
|
||||||
if(level > 100)
|
if(level > 100)
|
||||||
level = 100;
|
level = 100;
|
||||||
|
|
@ -144,7 +144,7 @@ void platform_setBacklightLevel(uint8_t level)
|
||||||
* If CCR1 value is zero, a waveform with 99% duty cycle is generated: to
|
* If CCR1 value is zero, a waveform with 99% duty cycle is generated: to
|
||||||
* avoid this the PWM is cut off when backlight level is 1.
|
* avoid this the PWM is cut off when backlight level is 1.
|
||||||
*/
|
*/
|
||||||
if(level > 1)
|
if(pwmLevel > 1)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_BKLIGHT_DIMMING
|
#ifdef ENABLE_BKLIGHT_DIMMING
|
||||||
TIM11->CCR1 = pwmLevel;
|
TIM11->CCR1 = pwmLevel;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include <interfaces/display.h>
|
#include <interfaces/display.h>
|
||||||
#include <interfaces/delays.h>
|
#include <interfaces/delays.h>
|
||||||
#include <interfaces/platform.h>
|
#include <interfaces/platform.h>
|
||||||
|
#include <backlight.h>
|
||||||
#include <hwconfig.h>
|
#include <hwconfig.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <miosix.h>
|
#include <miosix.h>
|
||||||
|
|
@ -127,6 +128,9 @@ static inline __attribute__((__always_inline__)) void writeData(uint8_t val)
|
||||||
|
|
||||||
void display_init()
|
void display_init()
|
||||||
{
|
{
|
||||||
|
/* Initialise backlight driver */
|
||||||
|
backlight_init();
|
||||||
|
|
||||||
/* Clear framebuffer, setting all pixels to 0x00 makes the screen white */
|
/* Clear framebuffer, setting all pixels to 0x00 makes the screen white */
|
||||||
memset(frameBuffer, 0x00, SCREEN_WIDTH * SCREEN_HEIGHT * sizeof(uint16_t));
|
memset(frameBuffer, 0x00, SCREEN_WIDTH * SCREEN_HEIGHT * sizeof(uint16_t));
|
||||||
|
|
||||||
|
|
@ -430,6 +434,9 @@ void display_init()
|
||||||
|
|
||||||
void display_terminate()
|
void display_terminate()
|
||||||
{
|
{
|
||||||
|
/* Shut down backlight */
|
||||||
|
backlight_terminate();
|
||||||
|
|
||||||
/* Shut off FSMC and deallocate framebuffer */
|
/* Shut off FSMC and deallocate framebuffer */
|
||||||
RCC->AHB3ENR &= ~RCC_AHB3ENR_FSMCEN;
|
RCC->AHB3ENR &= ~RCC_AHB3ENR_FSMCEN;
|
||||||
__DSB();
|
__DSB();
|
||||||
|
|
@ -537,3 +544,9 @@ void display_setContrast(uint8_t contrast)
|
||||||
/* This controller does not support contrast regulation */
|
/* This controller does not support contrast regulation */
|
||||||
(void) contrast;
|
(void) contrast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function implemented in backlight_MDx driver
|
||||||
|
*
|
||||||
|
* void display_setBacklightLevel(uint8_t level)
|
||||||
|
*/
|
||||||
|
|
|
||||||
|
|
@ -150,3 +150,8 @@ void display_setContrast(uint8_t contrast)
|
||||||
|
|
||||||
gpio_setPin(LCD_CS);
|
gpio_setPin(LCD_CS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void display_setBacklightLevel(uint8_t level)
|
||||||
|
{
|
||||||
|
(void) level;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,3 +170,8 @@ void display_setContrast(uint8_t contrast)
|
||||||
|
|
||||||
gpio_setPin(LCD_CS);
|
gpio_setPin(LCD_CS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void display_setBacklightLevel(uint8_t level)
|
||||||
|
{
|
||||||
|
(void) level;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,3 +157,8 @@ void display_setContrast(uint8_t contrast)
|
||||||
gpio_setPin(LCD_CS);
|
gpio_setPin(LCD_CS);
|
||||||
spi2_releaseDevice();
|
spi2_releaseDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void display_setBacklightLevel(uint8_t level)
|
||||||
|
{
|
||||||
|
(void) level;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,11 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <backlight.h>
|
||||||
#include <interfaces/gpio.h>
|
#include <interfaces/gpio.h>
|
||||||
#include <interfaces/display.h>
|
#include <interfaces/display.h>
|
||||||
#include <interfaces/delays.h>
|
#include <interfaces/delays.h>
|
||||||
#include "hwconfig.h"
|
#include <hwconfig.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LCD framebuffer, statically allocated.
|
* LCD framebuffer, statically allocated.
|
||||||
|
|
@ -98,6 +99,8 @@ static void display_renderRow(uint8_t row)
|
||||||
|
|
||||||
void display_init()
|
void display_init()
|
||||||
{
|
{
|
||||||
|
backlight_init(); /* Initialise backlight driver */
|
||||||
|
|
||||||
gpio_setMode(LCD_CS, OUTPUT);
|
gpio_setMode(LCD_CS, OUTPUT);
|
||||||
gpio_setMode(LCD_RST, OUTPUT);
|
gpio_setMode(LCD_RST, OUTPUT);
|
||||||
gpio_setMode(LCD_RS, OUTPUT);
|
gpio_setMode(LCD_RS, OUTPUT);
|
||||||
|
|
@ -129,6 +132,8 @@ void display_init()
|
||||||
|
|
||||||
void display_terminate()
|
void display_terminate()
|
||||||
{
|
{
|
||||||
|
backlight_terminate();
|
||||||
|
|
||||||
gpio_setMode(LCD_CS, INPUT);
|
gpio_setMode(LCD_CS, INPUT);
|
||||||
gpio_setMode(LCD_RST, INPUT);
|
gpio_setMode(LCD_RST, INPUT);
|
||||||
gpio_setMode(LCD_RS, INPUT);
|
gpio_setMode(LCD_RS, INPUT);
|
||||||
|
|
@ -171,3 +176,9 @@ void display_setContrast(uint8_t contrast)
|
||||||
sendByteToController(0x81); /* Set Electronic Volume */
|
sendByteToController(0x81); /* Set Electronic Volume */
|
||||||
sendByteToController(contrast >> 2); /* Controller contrast range is 0 - 63 */
|
sendByteToController(contrast >> 2); /* Controller contrast range is 0 - 63 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function implemented in backlight_GDx driver
|
||||||
|
*
|
||||||
|
* void display_setBacklightLevel(uint8_t level)
|
||||||
|
*/
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,15 @@ bool inProgress; /* Flag to signal when rendering is in progress */
|
||||||
bool sdl_ready = false; /* Flag to signal the sdl main loop is running */
|
bool sdl_ready = false; /* Flag to signal the sdl main loop is running */
|
||||||
extern chan_t fb_sync; /* Shared channel to send a frame buffer update */
|
extern chan_t fb_sync; /* Shared channel to send a frame buffer update */
|
||||||
|
|
||||||
|
/* Custom SDL Event to adjust backlight */
|
||||||
|
extern Uint32 SDL_Backlight_Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* Internal helper function which fetches pixel at position (x, y) from framebuffer
|
* Internal helper function which fetches pixel at position (x, y) from framebuffer
|
||||||
* and returns it in SDL-compatible format, which is ARGB8888.
|
* and returns it in SDL-compatible format, which is ARGB8888.
|
||||||
*/
|
*/
|
||||||
uint32_t fetchPixelFromFb(unsigned int x, unsigned int y)
|
static uint32_t fetchPixelFromFb(unsigned int x, unsigned int y)
|
||||||
{
|
{
|
||||||
(void) x;
|
(void) x;
|
||||||
(void) y;
|
(void) y;
|
||||||
|
|
@ -176,3 +179,19 @@ void display_setContrast(uint8_t contrast)
|
||||||
{
|
{
|
||||||
printf("Setting display contrast to %d\n", contrast);
|
printf("Setting display contrast to %d\n", contrast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void display_setBacklightLevel(uint8_t level)
|
||||||
|
{
|
||||||
|
// Saturate level to 100 and convert value to 0 - 255
|
||||||
|
if(level > 100) level = 100;
|
||||||
|
uint16_t value = (2 * level) + (level * 55)/100;
|
||||||
|
|
||||||
|
SDL_Event e;
|
||||||
|
SDL_zero(e);
|
||||||
|
e.type = SDL_Backlight_Event;
|
||||||
|
e.user.data1 = malloc(sizeof(uint8_t));
|
||||||
|
uint8_t *data = (uint8_t *)e.user.data1;
|
||||||
|
*data = ((uint8_t) value);
|
||||||
|
|
||||||
|
SDL_PushEvent(&e);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,10 +195,3 @@ const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: implementation of this API function is provided in
|
|
||||||
* platform/drivers/backlight/backlight_GDx.c
|
|
||||||
*/
|
|
||||||
// void platform_setBacklightLevel(uint8_t level)
|
|
||||||
|
|
|
||||||
|
|
@ -195,10 +195,3 @@ const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: implementation of this API function is provided in
|
|
||||||
* platform/drivers/backlight/backlight_GDx.c
|
|
||||||
*/
|
|
||||||
// void platform_setBacklightLevel(uint8_t level)
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
#include <hwconfig.h>
|
#include <hwconfig.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ADC1_MDx.h>
|
#include <ADC1_MDx.h>
|
||||||
#include <backlight.h>
|
|
||||||
#include <calibInfo_MDx.h>
|
#include <calibInfo_MDx.h>
|
||||||
#include <toneGenerator_MDx.h>
|
#include <toneGenerator_MDx.h>
|
||||||
#include <interfaces/rtc.h>
|
#include <interfaces/rtc.h>
|
||||||
|
|
@ -63,15 +62,11 @@ void platform_init()
|
||||||
nvm_readHwInfo(&hwInfo); /* Load hardware information data */
|
nvm_readHwInfo(&hwInfo); /* Load hardware information data */
|
||||||
toneGen_init(); /* Initialise tone generator */
|
toneGen_init(); /* Initialise tone generator */
|
||||||
rtc_init(); /* Initialise RTC */
|
rtc_init(); /* Initialise RTC */
|
||||||
backlight_init(); /* Initialise backlight driver */
|
|
||||||
audio_init(); /* Initialise audio management module */
|
audio_init(); /* Initialise audio management module */
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
{
|
{
|
||||||
/* Shut down backlight */
|
|
||||||
backlight_terminate();
|
|
||||||
|
|
||||||
/* Shut down LEDs */
|
/* Shut down LEDs */
|
||||||
gpio_clearPin(GREEN_LED);
|
gpio_clearPin(GREEN_LED);
|
||||||
gpio_clearPin(RED_LED);
|
gpio_clearPin(RED_LED);
|
||||||
|
|
@ -202,9 +197,3 @@ const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: implementation of this API function is provided in
|
|
||||||
* platform/drivers/backlight/backlight_MDx.c
|
|
||||||
*/
|
|
||||||
// void platform_setBacklightLevel(uint8_t level)
|
|
||||||
|
|
|
||||||
|
|
@ -230,10 +230,3 @@ const hwInfo_t *platform_getHwInfo()
|
||||||
* platform/drivers/chSelector/chSelector_MD9600.c
|
* platform/drivers/chSelector/chSelector_MD9600.c
|
||||||
*/
|
*/
|
||||||
// int8_t platform_getChSelector()
|
// int8_t platform_getChSelector()
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: implementation of this API function is provided in
|
|
||||||
* platform/drivers/backlight/backlight_MDx.c
|
|
||||||
*/
|
|
||||||
// void platform_setBacklightLevel(uint8_t level)
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,10 @@ void platform_init()
|
||||||
rtc_init(); /* Initialise RTC */
|
rtc_init(); /* Initialise RTC */
|
||||||
chSelector_init(); /* Initialise channel selector handler */
|
chSelector_init(); /* Initialise channel selector handler */
|
||||||
audio_init(); /* Initialise audio management module */
|
audio_init(); /* Initialise audio management module */
|
||||||
backlight_init(); /* Initialise backlight driver */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
{
|
{
|
||||||
/* Shut down backlight */
|
|
||||||
backlight_terminate();
|
|
||||||
|
|
||||||
/* Shut down LEDs */
|
/* Shut down LEDs */
|
||||||
gpio_clearPin(GREEN_LED);
|
gpio_clearPin(GREEN_LED);
|
||||||
gpio_clearPin(RED_LED);
|
gpio_clearPin(RED_LED);
|
||||||
|
|
@ -200,9 +196,3 @@ const hwInfo_t *platform_getHwInfo()
|
||||||
* platform/drivers/chSelector/chSelector_MDUV3x0.c
|
* platform/drivers/chSelector/chSelector_MDUV3x0.c
|
||||||
*/
|
*/
|
||||||
// int8_t platform_getChSelector()
|
// int8_t platform_getChSelector()
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: implementation of this API function is provided in
|
|
||||||
* platform/drivers/backlight/backlight_MDx.c
|
|
||||||
*/
|
|
||||||
// void platform_setBacklightLevel(uint8_t level)
|
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,14 @@
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <interfaces/gpio.h>
|
|
||||||
#include <interfaces/nvmem.h>
|
|
||||||
#include <interfaces/platform.h>
|
#include <interfaces/platform.h>
|
||||||
#include <hwconfig.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <backlight.h>
|
|
||||||
#include <interfaces/rtc.h>
|
|
||||||
#include <interfaces/audio.h>
|
|
||||||
#include <ADC1_Mod17.h>
|
|
||||||
#include <interfaces/nvmem.h>
|
#include <interfaces/nvmem.h>
|
||||||
|
#include <interfaces/audio.h>
|
||||||
|
#include <interfaces/gpio.h>
|
||||||
#include <calibInfo_Mod17.h>
|
#include <calibInfo_Mod17.h>
|
||||||
|
#include <ADC1_Mod17.h>
|
||||||
|
#include <backlight.h>
|
||||||
|
#include <hwconfig.h>
|
||||||
#include <MCP4551.h>
|
#include <MCP4551.h>
|
||||||
|
|
||||||
extern mod17Calib_t mod17CalData;
|
extern mod17Calib_t mod17CalData;
|
||||||
|
|
@ -192,8 +189,3 @@ const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_setBacklightLevel(uint8_t level)
|
|
||||||
{
|
|
||||||
(void) level;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,7 @@
|
||||||
#include <interfaces/nvmem.h>
|
#include <interfaces/nvmem.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
|
|
||||||
/* Custom SDL Event to adjust backlight */
|
|
||||||
extern Uint32 SDL_Backlight_Event;
|
|
||||||
|
|
||||||
static const hwInfo_t hwInfo =
|
static const hwInfo_t hwInfo =
|
||||||
{
|
{
|
||||||
|
|
@ -49,22 +46,6 @@ void platform_terminate()
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_setBacklightLevel(uint8_t level)
|
|
||||||
{
|
|
||||||
// Saturate level to 100 and convert value to 0 - 255
|
|
||||||
if(level > 100) level = 100;
|
|
||||||
uint16_t value = (2 * level) + (level * 55)/100;
|
|
||||||
|
|
||||||
SDL_Event e;
|
|
||||||
SDL_zero(e);
|
|
||||||
e.type = SDL_Backlight_Event;
|
|
||||||
e.user.data1 = malloc(sizeof(uint8_t));
|
|
||||||
uint8_t *data = (uint8_t *)e.user.data1;
|
|
||||||
*data = ((uint8_t) value);
|
|
||||||
|
|
||||||
SDL_PushEvent(&e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simulate a fully charged lithium battery
|
// Simulate a fully charged lithium battery
|
||||||
uint16_t platform_getVbat()
|
uint16_t platform_getVbat()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue