增加处理亮度的代码

This commit is contained in:
anod 2022-10-17 12:25:22 +08:00
parent 97d2df12bb
commit ad032e22f5
4 changed files with 31 additions and 4 deletions

View File

@ -73,6 +73,7 @@ typedef atp_error_t (*atp_itemprovider_t)(
typedef atp_pageopt_t (*atp_keyhandler_t)(
INPUT(atp_callerdata_t) some_data_provided_by_caller,
INPUT(atp_counter_t) index_of_selected_item,
INPUT(atp_boolean_t) is_x_key_down,
INPUT(atp_boolean_t) is_y_key_down,
INPUT(atp_boolean_t) is_l_key_down,

View File

@ -294,7 +294,7 @@ atp_error_t atp_select( atp_text_t title, atp_counter_t cnt, atp_itemprovider_t
{
if( handler == NULL ) continue;
atp_pageopt_t opt = handler( data, key&KEY_X, key&KEY_Y, key&KEY_L, key&KEY_R, key&KEY_START, key&KEY_SELECT );
atp_pageopt_t opt = handler( data, item_sel, key&KEY_X, key&KEY_Y, key&KEY_L, key&KEY_R, key&KEY_START, key&KEY_SELECT );
switch( opt )
{
case ATP_PAGE_REFRESH:

View File

@ -195,7 +195,7 @@ static void help_page( atp_text_t *wording, atp_counter_t length )
extern void oaf_config_page();
static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_boolean_t x, atp_boolean_t y, atp_boolean_t l, atp_boolean_t r, atp_boolean_t start, atp_boolean_t select )
static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t, atp_boolean_t x, atp_boolean_t y, atp_boolean_t l, atp_boolean_t r, atp_boolean_t start, atp_boolean_t select )
{
if( start )
{

View File

@ -119,15 +119,20 @@ static KHandle g_frameReadyEvent = 0;
// --------------------------
// code for oaf config page
// --------------------------
#define LIGHT_MIN (MCU_getSystemModel() > 3 ? 16 : 20)
#define LIGHT_MAX (MCU_getSystemModel() > 3 ? 142 : 117)
static atp_error_t config_item( atp_callerdata_t data, atp_counter_t index, atp_itemcfg_t *cfg )
{
const char *scaler_val[] = {"上屏无缩放", "上屏GPU放大", "上屏DMA放大", "下屏无缩放"};
static char buf[16];
cfg->extra_text_color = ATP_COLOR_GREEN;
if( index == 0 )
{
ee_snprintf(buf, sizeof(buf), "%d", g_oafConfig.backlight);
cfg->text = "屏幕亮度";
cfg->extra_text = buf;
if( g_oafConfig.backlight == LIGHT_MIN || g_oafConfig == LIGHT_MAX )
cfg->extra_text_color = ATP_COLOR_RED;
}
else if( index == 1 )
{
@ -145,13 +150,34 @@ static atp_error_t config_item( atp_callerdata_t data, atp_counter_t index, atp_
cfg->extra_text = g_oafConfig.saveOverride ? "禁用" : "启用";
}
cfg->value = index;
cfg->extra_text_color = ATP_COLOR_GREEN;
return ATP_SUCCESS;
}
static atp_pageopt_t config_adjust( atp_callerdata_t data, atp_counter_t index, atp_boolean_t x, atp_boolean_t y, atp_boolean_t l, atp_boolean_t r, atp_boolean_t start, atp_boolean_t select )
{
if( index == 0 )
{
u8 light = g_oafConfig.brightness;
if( l )
{
light -= 10;
if( light % 10 ) light = light + (10-light%10);
}
else if( r )
{
light += 10;
if( light % 10 ) light = light - light % 10;
}
if( light > LIGHT_MAX ) light = LIGHT_MAX;
else if( light < LIGHT_MIN ) light = LIGHT_MIN;
g_oafConfig.brightness = light;
}
return ATP_PAGE_UPDATE;
}
void oaf_config_page()
{
atp_select( "参数配置", 4, config_item, NULL, NULL, 0, 0, NULL );
atp_select( "参数配置", 4, config_item, config_adjust, NULL, 0, 0, NULL );
}
static u32 fixRomPadding(u32 romFileSize)