Skip to content

Commit

Permalink
Gain offset options (#40)
Browse files Browse the repository at this point in the history
* gain_offset_options: adding negative offset to settings mgmt

* gain_offset_selection: changed globals for gain offset and temporarily removed gui for gain offset

* gain_offset: building up menu

* gain_offset: multi option gain offset menu

* gain_offset: fixes for new compiler

* gain_offset: adding retrieving current value to sliders

* gain_offset: fixe for neg offset mask and update sliders

* gain_offset: event handler of rgb and unified spinbox

* gain_offset_options: propagate action to slider option in gain offset

---------

Co-authored-by: Marcelo Lorenzati <[email protected]>
  • Loading branch information
mlorenzati and mlorenzatiglb authored Feb 23, 2024
1 parent 2d56f47 commit 673bb73
Show file tree
Hide file tree
Showing 17 changed files with 232 additions and 113 deletions.
10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "0.2.0",
"configurations": [

{
{
"name": "Pico Debug",
"device": "RP2040",
"gdbPath": "arm-none-eabi-gdb",
Expand All @@ -12,16 +12,16 @@
"type": "cortex-debug",
"servertype": "openocd",
"configFiles": [
"/interface/picoprobe.cfg",
"/target/rp2040.cfg"
"interface/cmsis-dap.cfg",
"target/rp2040.cfg"
],
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
"runToMain": true,
"searchDir": ["/Program Files (x86)/openocd/tcl/"],
"runToEntryPoint": "main",
"postRestartCommands": [
"break main",
"continue"
]
}
]
}
}
37 changes: 2 additions & 35 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,5 @@
}
},
"cmake.buildBeforeRun": true,
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"files.associations": {
"stdlib.h": "c",
"stdio.h": "c",
"fastadc.h": "c",
"common_configs.h": "c",
"nanosystick.h": "c",
"wm8213afe.h": "c",
"systick.h": "c",
"array": "c",
"string": "c",
"string_view": "c",
"ranges": "c",
"rgbscan.h": "c",
"random": "c",
"address_mapped.h": "c",
"gpio.h": "c",
"pico.h": "c",
"config.h": "c",
"version.h": "c",
"platform.h": "c",
"optional": "c",
"ostream": "c",
"system_error": "c",
"functional": "c",
"tuple": "c",
"type_traits": "c",
"utility": "c",
"flash.h": "c",
"vector": "c",
"initializer_list": "c",
"retro_logo_128x128_rgb.h": "c"
},
"cortex-debug.variableUseNaturalFormat": true
}
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.12)
# Pull in PICO SDK (must be before project)
include(pico_sdk_import.cmake)

project(pico-rgb2hdmi VERSION "0.6.3" LANGUAGES C CXX)
project(pico-rgb2hdmi VERSION "0.6.4" LANGUAGES C CXX)
configure_file(config/version.h.in src/version.h)

set(CMAKE_C_STANDARD 11)
Expand Down Expand Up @@ -33,12 +33,12 @@ pico_sdk_init()
# Comment this if you don't care about binary security
find_program(SHA1SUM NAMES sha1sum)
if (NOT SHA1SUM)
message(FATAL_ERROR "sha1sum was not found")
message(STATUS "sha1sum was not found")
endif()

find_program(STR2HEX NAMES xxd)
if (NOT STR2HEX)
message(FATAL_ERROR "xxd was not found")
message(STATUS "xxd was not found")
endif()

set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DRGB2HDMI_DEBUG")
Expand Down
8 changes: 4 additions & 4 deletions config/common_configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,28 +190,28 @@
.flags.symbols_per_word = DEFAULT_SYMBOLS_PER_WORD == 2, \
.displays = {{ \
.gain = { .red = AFE_PGA_GAIN_RGB, .green = AFE_PGA_GAIN_RGB, .blue = AFE_PGA_GAIN_RGB}, \
.offset = { .red = AFE_OFFSET_DAC, .green = AFE_OFFSET_DAC, .blue = AFE_OFFSET_DAC}, \
.offset = { .red = AFE_OFFSET_DAC, .green = AFE_OFFSET_DAC, .blue = AFE_OFFSET_DAC, .negative = AFE_RLC_DAC_NEG}, \
.v_front_porch = V_FRONT_PORCH, .v_back_porch = V_BACK_PORCH, \
.h_front_porch = HSYNC_FRONT_PORCH, .h_back_porch = HSYNC_BACK_PORCH, \
.refresh_rate = REFRESH_RATE, \
.fine_tune = 0 \
}, { \
.gain = { .red = AFE_PGA_GAIN_RGB, .green = AFE_PGA_GAIN_RGB, .blue = AFE_PGA_GAIN_RGB}, \
.offset = { .red = AFE_OFFSET_DAC, .green = AFE_OFFSET_DAC, .blue = AFE_OFFSET_DAC}, \
.offset = { .red = AFE_OFFSET_DAC, .green = AFE_OFFSET_DAC, .blue = AFE_OFFSET_DAC, .negative = AFE_RLC_DAC_NEG }, \
.v_front_porch = V_FRONT_PORCH, .v_back_porch = V_BACK_PORCH, \
.h_front_porch = HSYNC_FRONT_PORCH, .h_back_porch = HSYNC_BACK_PORCH, \
.refresh_rate = REFRESH_RATE, \
.fine_tune = 0 \
}, { \
.gain = { .red = AFE_PGA_GAIN_RGB, .green = AFE_PGA_GAIN_RGB, .blue = AFE_PGA_GAIN_RGB}, \
.offset = { .red = AFE_OFFSET_DAC, .green = AFE_OFFSET_DAC, .blue = AFE_OFFSET_DAC}, \
.offset = { .red = AFE_OFFSET_DAC, .green = AFE_OFFSET_DAC, .blue = AFE_OFFSET_DAC, .negative = AFE_RLC_DAC_NEG}, \
.v_front_porch = V_FRONT_PORCH, .v_back_porch = V_BACK_PORCH, \
.h_front_porch = HSYNC_FRONT_PORCH, .h_back_porch = HSYNC_BACK_PORCH, \
.refresh_rate = REFRESH_RATE, \
.fine_tune = 0 \
}, { \
.gain = { .red = AFE_PGA_GAIN_RGB_SOG, .green = AFE_PGA_GAIN_RGB_SOG, .blue = AFE_PGA_GAIN_RGB_SOG}, \
.offset = { .red = AFE_OFFSET_DAC_SOG_RED, .green = AFE_OFFSET_DAC_SOG_GREEN, .blue = AFE_OFFSET_DAC_SOG_BLUE}, \
.offset = { .red = AFE_OFFSET_DAC_SOG_RED, .green = AFE_OFFSET_DAC_SOG_GREEN, .blue = AFE_OFFSET_DAC_SOG_BLUE, .negative = AFE_RLC_DAC_NEG}, \
.v_front_porch = V_FRONT_PORCH, .v_back_porch = V_BACK_PORCH, \
.h_front_porch = HSYNC_FRONT_PORCH, .h_back_porch = HSYNC_BACK_PORCH, \
.refresh_rate = REFRESH_RATE, \
Expand Down
4 changes: 4 additions & 0 deletions release_notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ pico rgb2hdmi

An rpi pico microprocessed rgb 2 hdmi plus rgb 2 usb on the fly converter
-------------------------------------------------------------------------
Date: 2024/02/22
Version: 0.6.4
- Menu system for total control of gain, positive and negative offset, with RGB and unified options
-------------------------------------------------------------------------
Date: 2023/09/01
Version: 0.6.3
- Option to disable license validation on flash
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ bool command_is_license_valid() {
}

void command_validate_license(const uint8_t *security_key) {
int token = -1;
#ifdef USE_LICENSE
int token = -1;
command_license_is_valid = security_key_is_valid(security_key, token) <= 0;
#else
command_license_is_valid = true;
Expand Down
8 changes: 4 additions & 4 deletions src/gui/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,9 @@ gui_object_t *gui_event(gui_status_t status, gui_object_t *origin) {
gui_event(update_status.bits, update_dest);
}

// Check if it was a focus request and it's not focusable
// WARNING: Request focus over a list of chained elements with at least one focusable
if (status.focused && !origin->base.properties.focusable && !status.go_next & !status.go_previous) {
// Check if it was a focus request and it's not focusable/enabled
// WARNING: Request focus over a list of chained elements with at least one focusable/enabled
if (status.focused && (!origin->base.properties.focusable || !origin->base.status.enabled) && !status.go_next & !status.go_previous) {
status.go_next = 1;
}

Expand All @@ -513,7 +513,7 @@ gui_object_t *gui_event(gui_status_t status, gui_object_t *origin) {
test_focused = test_focused->previous;
}

if (test_focused->base.properties.focusable) {
if (test_focused->base.properties.focusable && test_focused->base.status.enabled) {
status.go_next = 0;
status.go_previous = 0;
next_focused = test_focused;
Expand Down
49 changes: 33 additions & 16 deletions src/menu/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,16 @@ void menu_video_signal_callback(rgbscan_signal_event_type type) {
}
// ----------- TIMER CALLBACK END -----------

bool menu_change_view(gui_status_t status, gui_base_t *origin, menu_button_group_type type){
bool menu_change_view(gui_status_t status, gui_base_t *origin, menu_button_group_type new_type){
if (!status.activated && origin->status.activated) {
menu_left_buttons_group = menu_create_left_button_group(menu_nav_stack[menu_button_index - 1], type);
menu_left_buttons_group = menu_create_left_button_group(menu_nav_stack[menu_button_index - 1], new_type);
gui_obj_draw(menu_window);
gui_obj_draw(menu_left_buttons_group);
if (menu_main_view_group.base.status.visible) {
gui_obj_draw(menu_main_view_group);
}
menu_focused_object = gui_focused(&menu_left_buttons_group_elements[0]);

//Once we consume this event, we dispose it due to new changes
return false;
}
Expand Down Expand Up @@ -169,14 +170,14 @@ bool on_back_event(gui_status_t status, gui_base_t *origin, gui_object_t *destin
if (menu_button_index >= 2) {
cancel_repeating_timer(&menu_vsync_hsync_timer); //blindly stopping the timer for all back events for now
menu_button_group_type previous = menu_nav_stack[menu_button_index - 1];
menu_button_group_type new = menu_nav_stack[menu_button_index - 2];
menu_button_group_type new_type = menu_nav_stack[menu_button_index - 2];
menu_button_index -= 2;
menu_left_buttons_group = menu_create_left_button_group(previous, new);
menu_left_buttons_group = menu_create_left_button_group(previous, new_type);
gui_obj_draw(menu_window);
gui_obj_draw(menu_left_buttons_group);
menu_focused_object = gui_focused(&menu_left_buttons_group_elements[0]);

//Once we consume this event, we reequest no more propagations
//Once we consume this event, we reequest no more propagations
return false;
}
}
Expand Down Expand Up @@ -231,19 +232,34 @@ gui_object_t menu_create_left_button_group(menu_button_group_type previous, menu
break;
case menu_button_sub_group_gain_offset: {
gui_object_t elements[] = {
gui_create_text(&menu_overlay_ctx, 0, 0, 100, 12, &menu_colors_list, menu_common_label_props, "Gain"),
gui_create_spinbox(&menu_overlay_ctx, 0, 0, 100, 12, &menu_colors_list, menu_spinbox_props, &spinbox_gain),
gui_create_text(&menu_overlay_ctx, 0, 0, 100, 12, &menu_colors_list, menu_common_label_props, "Offset"),
gui_create_spinbox(&menu_overlay_ctx, 0, 0, 100, 12, &menu_colors_list, menu_spinbox_props, &spinbox_offset),
gui_create_button(&menu_overlay_ctx, 0, 0, 100, 12, &menu_colors_list, menu_common_nshared_props, "Back")
};
gui_create_slider(&menu_overlay_ctx, 0, 0, 200, 12, &menu_colors_list, menu_spinbox_props, &gain_offset_slider_option),
gui_create_label(&menu_overlay_ctx, 0, 0, 200, 11, &menu_colors_list, menu_common_label_props, menu_gain_offset_rgb_opt_print),
gui_create_spinbox(&menu_overlay_ctx, 0, 0, 200, 12, &menu_colors_list, menu_spinbox_props, &spinbox_gain_offset_red),
gui_create_spinbox(&menu_overlay_ctx, 0, 0, 200, 12, &menu_colors_list, menu_spinbox_props, &spinbox_gain_offset_green),
gui_create_spinbox(&menu_overlay_ctx, 0, 0, 200, 12, &menu_colors_list, menu_spinbox_props, &spinbox_gain_offset_blue),
gui_create_label(&menu_overlay_ctx, 0, 0, 200, 11, &menu_colors_list, menu_common_label_props, menu_gain_offset_unified_opt_print),
gui_create_spinbox(&menu_overlay_ctx, 0, 0, 200, 12, &menu_colors_list, menu_spinbox_props, &spinbox_gain_offset_unified),
gui_create_button(&menu_overlay_ctx, 0, 0, 200, 12, &menu_colors_list, menu_common_nshared_props, "Back")
};
menu_elements_copy(elements, menu_left_buttons_group_elements);
gui_list_t group_list = initalizeGuiDynList(menu_left_buttons_group_elements, arraySize(elements));
menu_left_buttons_group_list = group_list;
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[0].base, &menu_left_buttons_group_elements[0], on_gain_offset_option_event);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[0].base, &menu_left_buttons_group_elements[1], NULL);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[0].base, &menu_left_buttons_group_elements[2], NULL);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[0].base, &menu_left_buttons_group_elements[3], NULL);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[0].base, &menu_left_buttons_group_elements[4], NULL);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[0].base, &menu_left_buttons_group_elements[5], NULL);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[0].base, &menu_left_buttons_group_elements[6], NULL);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[2].base, &menu_left_buttons_group_elements[2], on_gain_offset_rgb_spinbox_event);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[3].base, &menu_left_buttons_group_elements[3], on_gain_offset_rgb_spinbox_event);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[4].base, &menu_left_buttons_group_elements[4], on_gain_offset_rgb_spinbox_event);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[6].base, &menu_left_buttons_group_elements[6], on_gain_offset_unified_spinbox_event);
gui_event_subscribe(button_status, &menu_left_buttons_group_elements[7].base, &menu_left_buttons_group_elements[7], on_back_event);
gain_offset_slider_option = 0;

gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[1].base, &menu_left_buttons_group_elements[1], on_gain_offset_event);
gui_event_subscribe(spinbox_status, &menu_left_buttons_group_elements[3].base, &menu_left_buttons_group_elements[3], on_gain_offset_event);
gui_event_subscribe(button_status, &menu_left_buttons_group_elements[4].base, &menu_left_buttons_group_elements[4], on_back_event);
// We enable the slider option selector, since the reconfiguration of options is propagating an unwanted event
gui_activate(&menu_left_buttons_group_elements[0]); gui_deactivate(&menu_left_buttons_group_elements[0]);
}
break;
case menu_button_sub_group_diagnostic: {
Expand Down Expand Up @@ -487,8 +503,9 @@ int menu_initialize(uint *pins, menu_event_type *events, uint8_t count) {
spinbox_horizontal = GET_VIDEO_PROPS().horizontal_front_porch;
spinbox_vertical = GET_VIDEO_PROPS().vertical_front_porch;
spinbox_pix_width = GET_VIDEO_PROPS().horizontal_front_porch + GET_VIDEO_PROPS().horizontal_back_porch;
spinbox_offset = wm8213_afe_get_offset(color_part_all);
spinbox_gain = wm8213_afe_get_gain(color_part_all);

// Gain offset sliders are set when already on the screen, not here

spinbox_display_no = settings_get()->flags.default_display + 1;
spinbox_fine_tune = GET_VIDEO_PROPS().fine_tune / 1000;

Expand Down
2 changes: 1 addition & 1 deletion src/menu/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
int menu_initialize(uint *pins, menu_event_type *events, uint8_t count);
void menu_elements_copy_(const gui_object_t *src, gui_object_t *dst, uint8_t size);
gui_object_t menu_create_left_button_group(menu_button_group_type previous, menu_button_group_type new);
gui_object_t menu_create_main_view_group(gui_base_t *left_group, menu_button_group_type type);
gui_object_t menu_create_main_view_group(gui_base_t *left_group, menu_button_group_type new_type);
void menu_video_signal_callback(rgbscan_signal_event_type type);
#endif
Loading

0 comments on commit 673bb73

Please sign in to comment.