Merge branch 'DiSlord_tinySA-V4-SI4463' of https://github.com/erikkaashoek/tinySA into DiSlord_tinySA-V4-SI4463

Removed_REF_marker
DiSlord 5 years ago
commit 856924f2cc

@ -501,9 +501,37 @@ static const uint8_t ili9341_init_seq[] = {
#define LCD_INIT ili9341_init_seq #define LCD_INIT ili9341_init_seq
#endif #endif
#ifdef __LCD_BRIGHTNESS__
#if HAL_USE_DAC == FALSE
#error "Need set HAL_USE_DAC in halconf.h for use __LCD_BRIGHTNESS__"
#endif
static const DACConfig dac1cfg1 = {
init: 0,
datamode: DAC_DHRM_12BIT_RIGHT
};
static void lcd_initBrightness(void){
dacStart(&DACD2, &dac1cfg1);
}
#define BRIGHTNESS_MIN_LEVEL 0
#define BRIGHTNESS_MAX_LEVEL 3300
// Brightness control range 0 - 100
void lcd_setBrightness(uint16_t b){
b = BRIGHTNESS_MIN_LEVEL + b*((BRIGHTNESS_MAX_LEVEL-BRIGHTNESS_MIN_LEVEL)/100);
dacPutChannelX(&DACD2, 0, b);
}
#else
#define lcd_initBrightness()
#endif
void ili9341_init(void) void ili9341_init(void)
{ {
spi_init(); spi_init();
// Init Brightness if LCD support
lcd_initBrightness();
LCD_DC_DATA; LCD_DC_DATA;
LCD_RESET_ASSERT; LCD_RESET_ASSERT;
chThdSleepMilliseconds(10); chThdSleepMilliseconds(10);
@ -514,7 +542,7 @@ void ili9341_init(void)
p += 2 + p[1]; p += 2 + p[1];
chThdSleepMilliseconds(5); chThdSleepMilliseconds(5);
} }
// ili9341_clear_screen(); ili9341_clear_screen();
LCD_CS_HIGH; LCD_CS_HIGH;
} }

@ -885,6 +885,7 @@ config_t config = {
.ext_zero_level = 128, .ext_zero_level = 128,
#endif #endif
#ifdef TINYSA4 #ifdef TINYSA4
._brightness = DEFAULT_BRIGHTNESS,
.vbat_offset = 220, .vbat_offset = 220,
.frequency_IF1 = DEFAULT_IF, .frequency_IF1 = DEFAULT_IF,
.frequency_IF2 = 0, .frequency_IF2 = 0,
@ -2265,6 +2266,13 @@ int main(void)
// ui_mode_menu(); // Show menu when autostarting mode // ui_mode_menu(); // Show menu when autostarting mode
ui_mode_normal(); ui_mode_normal();
/*
* Set LCD display brightness
*/
#ifdef __LCD_BRIGHTNESS__
lcd_setBrightness(config._brightness);
#endif
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL); chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL);

@ -80,6 +80,7 @@
#ifdef TINYSA4 #ifdef TINYSA4
#define __USE_RTC__ // Enable RTC clock #define __USE_RTC__ // Enable RTC clock
#define __USE_SD_CARD__ // Enable SD card support #define __USE_SD_CARD__ // Enable SD card support
#define __LCD_BRIGHTNESS__ // LCD or hardware allow change brightness, add menu item for this
#define __HARMONIC__ #define __HARMONIC__
#define __VBW__ #define __VBW__
#define __SWEEP_RESTART__ #define __SWEEP_RESTART__
@ -695,6 +696,7 @@ typedef struct config {
int8_t cor_am; int8_t cor_am;
int8_t cor_wfm; int8_t cor_wfm;
int8_t cor_nfm; int8_t cor_nfm;
uint8_t _brightness;
uint8_t high_out_adf4350; uint8_t high_out_adf4350;
float sweep_voltage; float sweep_voltage;
float switch_offset; float switch_offset;
@ -857,6 +859,9 @@ typedef uint16_t pixel_t;
#define LCD_HEIGHT 240 #define LCD_HEIGHT 240
#endif #endif
// Default LCD brightness if display support it
#define DEFAULT_BRIGHTNESS 70
#define LCD_BG_COLOR 0 #define LCD_BG_COLOR 0
#define LCD_FG_COLOR 1 #define LCD_FG_COLOR 1
#define LCD_GRID_COLOR 2 #define LCD_GRID_COLOR 2
@ -966,6 +971,7 @@ void ili9341_drawfont(uint8_t ch, int x, int y);
void ili9341_read_memory(int x, int y, int w, int h, uint16_t* out); void ili9341_read_memory(int x, int y, int w, int h, uint16_t* out);
void ili9341_line(int x0, int y0, int x1, int y1); void ili9341_line(int x0, int y0, int x1, int y1);
void show_version(void); void show_version(void);
void lcd_setBrightness(uint16_t b);
/* /*
* flash.c * flash.c
@ -1185,7 +1191,7 @@ typedef struct properties {
//sizeof(properties_t) == 0x1200 //sizeof(properties_t) == 0x1200
#define CONFIG_MAGIC 0x434f4e4f /* 'CONF' */ #define CONFIG_MAGIC 0x434f4e50 /* 'CONF' */
extern int16_t lastsaveid; extern int16_t lastsaveid;
//extern properties_t *active_props; //extern properties_t *active_props;

@ -1702,6 +1702,39 @@ static UI_FUNCTION_ADV_CALLBACK(menu_settings_bpf_acb){
toggle_tracking(); toggle_tracking();
} }
#ifdef __LCD_BRIGHTNESS__
static UI_FUNCTION_CALLBACK(menu_brightness_cb)
{
(void)item;
(void)data;
int16_t value = config._brightness;
ili9341_set_foreground(LCD_MENU_TEXT_COLOR);
ili9341_set_background(LCD_MENU_COLOR);
ili9341_fill(LCD_WIDTH/2-80, LCD_HEIGHT/2-20, 160, 40);
ili9341_drawstring_7x13("BRIGHTNESS", LCD_WIDTH/2-35, LCD_HEIGHT/2-13);
ili9341_drawstring_7x13(S_LARROW" USE LEVELER BUTTON "S_RARROW, LCD_WIDTH/2-72, LCD_HEIGHT/2+2);
while (TRUE) {
int status = btn_check();
if (status & (EVT_UP|EVT_DOWN)) {
do {
if (status & EVT_UP ) value+=5;
if (status & EVT_DOWN) value-=5;
if (value < 0) value = 0;
if (value > 100) value = 100;
lcd_setBrightness(value);
status = btn_wait_release();
} while (status != 0);
}
if (status == EVT_BUTTON_SINGLE_CLICK)
break;
}
config._brightness = (uint8_t)value;
lcd_setBrightness(value);
redraw_request|= REDRAW_AREA;
ui_mode_normal();
}
#endif
static UI_FUNCTION_ADV_CALLBACK(menu_settings_pulse_acb){ static UI_FUNCTION_ADV_CALLBACK(menu_settings_pulse_acb){
(void)item; (void)item;
(void)data; (void)data;
@ -2561,7 +2594,9 @@ static const menuitem_t menu_config[] = {
#ifndef TINYSA4 #ifndef TINYSA4
{ MT_SUBMENU, 0, S_RARROW" DFU", menu_dfu}, { MT_SUBMENU, 0, S_RARROW" DFU", menu_dfu},
#endif #endif
#ifdef __LCD_BRIGHTNESS__
{ MT_CALLBACK, 0, "BRIGHTHESS", menu_brightness_cb},
#endif
{ MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };

Loading…
Cancel
Save

Powered by TurnKey Linux.