kopia lustrzana https://github.com/OpenRTX/OpenRTX
Move brightness from state_t to settings_t, add Contrast
rodzic
8ded5fc9b6
commit
1f240ba132
|
@ -0,0 +1,31 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, *
|
||||||
|
* Niccolò Izzo IU2KIN, *
|
||||||
|
* Frederik Saraci IU2NRO, *
|
||||||
|
* Silvano Seva IU2KWO *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SETTINGS_H
|
||||||
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t brightness;
|
||||||
|
uint8_t contrast;
|
||||||
|
}
|
||||||
|
settings_t;
|
||||||
|
|
||||||
|
#endif /* SETTINGS_H */
|
|
@ -40,7 +40,6 @@ typedef struct
|
||||||
float rssi;
|
float rssi;
|
||||||
|
|
||||||
uint8_t ui_screen;
|
uint8_t ui_screen;
|
||||||
uint8_t backlight_level;
|
|
||||||
uint8_t tuner_mode;
|
uint8_t tuner_mode;
|
||||||
|
|
||||||
//time_t rx_status_tv;
|
//time_t rx_status_tv;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
#include <hwconfig.h>
|
#include <hwconfig.h>
|
||||||
|
#include <settings.h>
|
||||||
|
|
||||||
// Maximum menu entry length
|
// Maximum menu entry length
|
||||||
#define MAX_ENTRY_LEN 16
|
#define MAX_ENTRY_LEN 16
|
||||||
|
@ -119,6 +120,7 @@ typedef struct ui_state_t
|
||||||
} ui_state_t;
|
} ui_state_t;
|
||||||
|
|
||||||
extern layout_t layout;
|
extern layout_t layout;
|
||||||
|
extern settings_t settings;
|
||||||
extern const char *menu_items[6];
|
extern const char *menu_items[6];
|
||||||
extern const char *settings_items[2];
|
extern const char *settings_items[2];
|
||||||
extern const char *display_items[2];
|
extern const char *display_items[2];
|
||||||
|
|
|
@ -40,7 +40,6 @@ void state_init()
|
||||||
state.charge = battery_getCharge(state.v_bat);
|
state.charge = battery_getCharge(state.v_bat);
|
||||||
state.rssi = rtx_getRssi();
|
state.rssi = rtx_getRssi();
|
||||||
|
|
||||||
state.backlight_level = 255;
|
|
||||||
state.channelInfoUpdated = true;
|
state.channelInfoUpdated = true;
|
||||||
state.channel.mode = FM;
|
state.channel.mode = FM;
|
||||||
state.channel.bandwidth = BW_25;
|
state.channel.bandwidth = BW_25;
|
||||||
|
|
|
@ -137,6 +137,7 @@ const color_t yellow_fab413 = {250, 180, 19, 255};
|
||||||
|
|
||||||
layout_t layout;
|
layout_t layout;
|
||||||
ui_state_t ui_state;
|
ui_state_t ui_state;
|
||||||
|
settings_t settings;
|
||||||
bool layout_ready = false;
|
bool layout_ready = false;
|
||||||
bool redraw_needed = true;
|
bool redraw_needed = true;
|
||||||
|
|
||||||
|
@ -271,6 +272,11 @@ void ui_init()
|
||||||
// This syntax is called compound literal
|
// This syntax is called compound literal
|
||||||
// https://stackoverflow.com/questions/6891720/initialize-reset-struct-to-zero-null
|
// https://stackoverflow.com/questions/6891720/initialize-reset-struct-to-zero-null
|
||||||
ui_state = (const struct ui_state_t){ 0 };
|
ui_state = (const struct ui_state_t){ 0 };
|
||||||
|
settings = (settings_t){ 0 };
|
||||||
|
// Initialize settings_t
|
||||||
|
// TODO: settings_t should be read from flash memory or from a factory default
|
||||||
|
settings.brightness = 255;
|
||||||
|
settings.contrast = 84;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_drawSplashScreen()
|
void ui_drawSplashScreen()
|
||||||
|
@ -490,8 +496,6 @@ void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx) {
|
||||||
|
|
||||||
void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) {
|
void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) {
|
||||||
ui_state.input_number = input_getPressedNumber(msg);
|
ui_state.input_number = input_getPressedNumber(msg);
|
||||||
// Backlight
|
|
||||||
int32_t new_blight = state.backlight_level;
|
|
||||||
// CTCSS Encode/Decode Selection
|
// CTCSS Encode/Decode Selection
|
||||||
bool tone_tx_enable = state.channel.fm.txToneEn;
|
bool tone_tx_enable = state.channel.fm.txToneEn;
|
||||||
bool tone_rx_enable = state.channel.fm.rxToneEn;
|
bool tone_rx_enable = state.channel.fm.rxToneEn;
|
||||||
|
@ -533,16 +537,12 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) {
|
||||||
*sync_rtx = true;
|
*sync_rtx = true;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
new_blight += 25;
|
settings.brightness = (settings.brightness + 25 > 255) ? 255 : settings.brightness + 25;
|
||||||
new_blight = (new_blight > 255) ? 255 : new_blight;
|
platform_setBacklightLevel(settings.brightness);
|
||||||
state.backlight_level = new_blight;
|
|
||||||
platform_setBacklightLevel(state.backlight_level);
|
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
new_blight -= 25;
|
settings.brightness = (settings.brightness - 25 < 0) ? 0 : settings.brightness - 25;
|
||||||
new_blight = (new_blight < 0) ? 0 : new_blight;
|
platform_setBacklightLevel(settings.brightness);
|
||||||
state.backlight_level = new_blight;
|
|
||||||
platform_setBacklightLevel(state.backlight_level);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,12 @@ int _ui_getDisplayEntryName(char *buf, uint8_t max_len, uint8_t index)
|
||||||
int _ui_getDisplayValueName(char *buf, uint8_t max_len, uint8_t index)
|
int _ui_getDisplayValueName(char *buf, uint8_t max_len, uint8_t index)
|
||||||
{
|
{
|
||||||
if(index >= display_num) return -1;
|
if(index >= display_num) return -1;
|
||||||
snprintf(buf, max_len, "%s", display_items[index]);
|
uint8_t value = 0;
|
||||||
|
if(strcmp(display_items[index], "Brightness"))
|
||||||
|
value = settings.brightness;
|
||||||
|
else if(strcmp(display_items[index], "Contrast"))
|
||||||
|
value = settings.contrast;
|
||||||
|
snprintf(buf, max_len, "%d", value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue