diff --git a/app/telemetry/models/aohdsystem.cpp b/app/telemetry/models/aohdsystem.cpp index 6869e8e1c..677049012 100644 --- a/app/telemetry/models/aohdsystem.cpp +++ b/app/telemetry/models/aohdsystem.cpp @@ -298,7 +298,7 @@ void AOHDSystem::process_onboard_computer_status(const mavlink_onboard_computer_ set_air_reported_fc_sys_id(air_reported_sys_id); const uint8_t ohd_platform=msg.link_type[0]; set_ohd_platform(ohd_platform); - const auto platform_as_str=openhd::x_platform_type_to_string(ohd_platform); + const auto platform_as_str=x_platform_type_to_string(ohd_platform); set_ohd_platform_type_as_string(platform_as_str.c_str()); } diff --git a/app/telemetry/models/camerastreammodel.cpp b/app/telemetry/models/camerastreammodel.cpp index e27e28556..9bcd1658a 100644 --- a/app/telemetry/models/camerastreammodel.cpp +++ b/app/telemetry/models/camerastreammodel.cpp @@ -246,3 +246,48 @@ std::string CameraStreamModel::resolution_framerate_to_string(const ResolutionFr ss<<(int)data.width<<"x"<<(int)data.height<<"@"< list{ + QCameraNameAndType{"XLOL",1} + }; + auto tmp= QManufacturerForPlatform{ + "LOL", + list + }; + QVariantList ret; + return ret; +} + +QStringList CameraStreamModel::get_manufacturer_choices(int platform_type) +{ + auto all_choices=get_camera_choices_for_platform(platform_type,m_camera_index!=0); + QStringList ret; + for(auto& choice: all_choices){ + ret.push_back(choice.manufacturer_name.c_str()); + } + return ret; +} + +QList CameraStreamModel::get_manufacturer_cameras_type(int platform_type, int index) +{ + auto all_choices=get_camera_choices_for_platform(platform_type,m_camera_index!=0); + QList ret; + if(index>=all_choices.size())index=0; + for(auto& choice: all_choices[index].cameras){ + ret.push_back(choice.type); + } + return ret; +} + +QStringList CameraStreamModel::get_manufacturer_cameras_names(int platform_type, int index) +{ + auto all_choices=get_camera_choices_for_platform(platform_type,m_camera_index!=0); + QStringList ret; + if(index>=all_choices.size())index=0; + for(auto& choice: all_choices[index].cameras){ + ret.push_back(choice.name.c_str()); + } + return ret; +} diff --git a/app/telemetry/models/camerastreammodel.h b/app/telemetry/models/camerastreammodel.h index 8ee61f83f..ad320d3ed 100644 --- a/app/telemetry/models/camerastreammodel.h +++ b/app/telemetry/models/camerastreammodel.h @@ -2,11 +2,23 @@ #define AIRCAMERAMODEL_H #include +#include #include "../tutil/mavlink_include.h" #include "util/lqutils_include.h" +struct QCameraNameAndType{ + QString name; + int type; +}; +struct QManufacturerForPlatform{ + QString manufacturer_name; + QList cameras; +}; +Q_DECLARE_METATYPE(QCameraNameAndType); +Q_DECLARE_METATYPE(QManufacturerForPlatform); + // NOTE1: This class exists to avoid duplicated code for primary and secondary camera(stream)-stats displayed in the HUD // NOTE2: Here we have only stats for one camera / camera stream that are transmitted via lossy // telemetry messages, aka in regular intervalls. @@ -114,6 +126,11 @@ class CameraStreamModel : public QObject private: std::chrono::steady_clock::time_point m_last_tx_frame_drop_calculation=std::chrono::steady_clock::now(); int m_last_tx_frame_drop_calculation_count=-1; +public: + Q_INVOKABLE QVariantList get_camera_choices(int platform_type); + Q_INVOKABLE QStringList get_manufacturer_choices(int platform_type); + Q_INVOKABLE QList get_manufacturer_cameras_type(int platform_type,int index); + Q_INVOKABLE QStringList get_manufacturer_cameras_names(int platform_type,int index); }; #endif // AIRCAMERAMODEL_H diff --git a/app/telemetry/models/openhd_core/camera.hpp b/app/telemetry/models/openhd_core/camera.hpp index a27be10a6..c1c2e2441 100644 --- a/app/telemetry/models/openhd_core/camera.hpp +++ b/app/telemetry/models/openhd_core/camera.hpp @@ -12,6 +12,8 @@ #include #include +#include "platform.hpp" + /** * NOTE: This file is copied into QOpenHD to populate the UI. */ @@ -79,6 +81,8 @@ static constexpr int X_CAM_TYPE_X20_RUNCAM_NANO = 70; // static constexpr int X_CAM_TYPE_ROCK_HDMI_IN = 80; static constexpr int X_CAM_TYPE_ROCK_IMX219 = 81; +static constexpr int X_CAM_TYPE_ROCK_RK3566_PLACEHOLDER1 = 82; +static constexpr int X_CAM_TYPE_ROCK_RK3566_PLACEHOLDER2 = 83; // // OpenIPC specific starts here static constexpr int X_CAM_TYPE_OPENIPC_SOMETHING = 90; @@ -146,6 +150,10 @@ static std::string x_cam_type_to_string(int camera_type) { return "ROCK_HDMI_IN"; case X_CAM_TYPE_ROCK_IMX219: return "ROCK_IMX219"; + case X_CAM_TYPE_ROCK_RK3566_PLACEHOLDER1: + return "ROCK_PLACEHOLDER1"; + case X_CAM_TYPE_ROCK_RK3566_PLACEHOLDER2: + return "ROCK_PLACEHOLDER2"; case X_CAM_TYPE_DISABLED: return "DISABLED"; case X_CAM_TYPE_OPENIPC_SOMETHING: @@ -297,6 +305,19 @@ struct XCamera { ret.push_back(ResolutionFramerate{1280, 720, 60}); ret.push_back(ResolutionFramerate{1920, 1080, 60}); return ret; + } else if (camera_type == X_CAM_TYPE_ROCK_IMX219) { + std::vector ret; + ret.push_back(ResolutionFramerate{640, 480, 30}); + ret.push_back(ResolutionFramerate{848, 480, 30}); + ret.push_back(ResolutionFramerate{1280, 720, 30}); + ret.push_back(ResolutionFramerate{1920, 1080, 30}); + return ret; + } else if (camera_type == X_CAM_TYPE_ROCK_HDMI_IN) { + // Standard hdmi in resolutions for now + std::vector ret; + ret.push_back(ResolutionFramerate{1280, 720, 60}); + ret.push_back(ResolutionFramerate{1920, 1080, 60}); + return ret; } // Not mapped yet // return something that might work or might not work @@ -399,4 +420,111 @@ static std::string get_v4l2_device_name_string(int value) { return ss.str(); } +/** + * On platforms with many cameras (e.g. rpi) we need a differentiation by + * manufacturer to make a nice UI - otherwise, the choices are overwhelming. + * Manufacturer is not really the right name for all categories that result + * here, but it is 'okay' for the UI in qopenhd. + */ +struct CameraNameAndType { + std::string name; + int type; +}; +struct ManufacturerForPlatform { + std::string manufacturer_name; + std::vector cameras; +}; +/** + * Return: a list of categories for this platform. + * Each category has a list of valid camera types (for this platform). + * @param platform_type unique platform type + * @param is_secondary selection is different for secondary cam,most notably, we + * only support usb, develop and a 'disabled' type. + */ +static std::vector get_camera_choices_for_platform( + int platform_type, bool is_secondary) { + std::vector usb_cameras{ + CameraNameAndType{"INFIRAY USB", X_CAM_TYPE_USB_INFIRAY}, + CameraNameAndType{"INFIRAY USB T2", X_CAM_TYPE_USB_INFIRAY_T2}, + CameraNameAndType{"EXP USB GENERIC", X_CAM_TYPE_USB_GENERIC}}; + ManufacturerForPlatform MANUFACTURER_USB{"USB", usb_cameras}; + std::vector debug_cameras{ + CameraNameAndType{"Dummy (debug)", 0}, + CameraNameAndType{"External (DEV)", 2}, + // CameraNameAndType{"External IP (DEV)",3}, + CameraNameAndType{"DEV Filecamera", 4}, + }; + ManufacturerForPlatform MANUFACTURER_DEBUG{"DEV/DEBUG", debug_cameras}; + // Secondary can only be used with USB and / or the debug cameras. CSI is not + // usable for secondary. + if (is_secondary) { + // Not really a manufacturer, but ui looks okay with this + std::vector disable_camera{ + CameraNameAndType{"DISABLE", X_CAM_TYPE_DISABLED}, + }; + ManufacturerForPlatform MANUFACTURER_DISABLE{"DISABLE", disable_camera}; + return std::vector{ + MANUFACTURER_DISABLE, MANUFACTURER_USB, MANUFACTURER_DEBUG}; + } + if (platform_type == X_PLATFORM_TYPE_RPI_OLD || + platform_type == X_PLATFORM_TYPE_RPI_4 || + platform_type == X_PLATFORM_TYPE_RPI_CM4) { + std::vector arducam_cameras{ + CameraNameAndType{"SKYMASTERHDR", 40}, + CameraNameAndType{"SKYVISIONPRO", 41}, + CameraNameAndType{"IMX477m", 42}, + CameraNameAndType{"IMX462", 43}, + CameraNameAndType{"IMX327", 44}, + CameraNameAndType{"IMX290", 45}, + CameraNameAndType{"IMX462_LOWLIGHT_MINI", 46}}; + std::vector veye_cameras{ + CameraNameAndType{"2MP", 60}, + CameraNameAndType{"CSIMX307", 61}, + CameraNameAndType{"CSSC132", 62}, + CameraNameAndType{"MVCAM", 63}, + }; + std::vector rpif_cameras{ + CameraNameAndType{"V1 OV5647", 30}, + CameraNameAndType{"V2 IMX219", 31}, + CameraNameAndType{"V3 IMX708", 32}, + CameraNameAndType{"HQ IMX477", 33}, + }; + std::vector hdmi_to_csi_cameras{ + CameraNameAndType{"GENERIC HDMI to CSI", 20}}; + return std::vector{ + ManufacturerForPlatform{"ARDUCAM", arducam_cameras}, + ManufacturerForPlatform{"VEYE", veye_cameras}, + ManufacturerForPlatform{"RPI FOUNDATION", rpif_cameras}, + ManufacturerForPlatform{"HDMI TO CSI", hdmi_to_csi_cameras}, + MANUFACTURER_USB, + MANUFACTURER_DEBUG}; + } else if (platform_type == X_PLATFORM_TYPE_ALWINNER_X20) { + std::vector runcam_cameras{ + CameraNameAndType{"RUNCAM NANO", X_CAM_TYPE_X20_RUNCAM_NANO}, + }; + return std::vector{ + ManufacturerForPlatform{"RUNCAM", runcam_cameras}}; + } else if (platform_type == X_PLATFORM_TYPE_ROCKCHIP_RK3566_RADXA_ZERO3W) { + std::vector arducam_cameras{ + CameraNameAndType{"IMX219", X_CAM_TYPE_ROCK_IMX219}, + CameraNameAndType{"PLACEHOLDER1", X_CAM_TYPE_ROCK_RK3566_PLACEHOLDER1}, + CameraNameAndType{"PLACEHOLDER2", X_CAM_TYPE_ROCK_RK3566_PLACEHOLDER2}, + }; + return std::vector{ + ManufacturerForPlatform{"ARDUCAM", arducam_cameras}, MANUFACTURER_USB, + MANUFACTURER_DEBUG}; + } else if (platform_type == X_PLATFORM_TYPE_ROCKCHIP_RK3588_RADXA_ROCK5) { + std::vector hdmi_cameras{ + CameraNameAndType{"HDMI IN", X_CAM_TYPE_ROCK_HDMI_IN}, + }; + return std::vector{ + ManufacturerForPlatform{"HDMI IN", hdmi_cameras}, MANUFACTURER_USB, + MANUFACTURER_DEBUG}; + } else if (platform_type == X_PLATFORM_TYPE_X86) { + return std::vector{MANUFACTURER_USB, + MANUFACTURER_DEBUG}; + } + return std::vector{MANUFACTURER_DEBUG}; +} + #endif // OPENHD_CAMERA_HPP diff --git a/app/telemetry/models/openhd_core/platform.hpp b/app/telemetry/models/openhd_core/platform.hpp index 4efc18222..cf6dbd635 100644 --- a/app/telemetry/models/openhd_core/platform.hpp +++ b/app/telemetry/models/openhd_core/platform.hpp @@ -4,7 +4,7 @@ #include -namespace openhd{ + // When this one shows up a bit more work has to be done to run openhd on the platform (probably) ;) static constexpr int X_PLATFORM_TYPE_UNKNOWN=0; @@ -30,7 +30,7 @@ static constexpr int X_PLATFORM_TYPE_ALWINNER_X20=30; // @Buldo is working on openipc / sigmastar, 36..40 static constexpr int X_PLATFORM_TYPE_SIGMASTAR_UNDEFINED=36; -std::string x_platform_type_to_string(int platform_type) { +static std::string x_platform_type_to_string(int platform_type) { switch (platform_type) { case X_PLATFORM_TYPE_UNKNOWN:return "UNKNOWN"; case X_PLATFORM_TYPE_X86:return "X86"; @@ -49,7 +49,7 @@ std::string x_platform_type_to_string(int platform_type) { } return "ERR-UNDEFINED"; } -} + diff --git a/qml/ui/configpopup/openhd_settings/ChooseCameraDialoque.qml b/qml/ui/configpopup/openhd_settings/ChooseCameraDialoque.qml index 996f6d104..10b7bc58c 100644 --- a/qml/ui/configpopup/openhd_settings/ChooseCameraDialoque.qml +++ b/qml/ui/configpopup/openhd_settings/ChooseCameraDialoque.qml @@ -17,11 +17,6 @@ Card { cardNameColor: "black" visible: false - // Supported platform types: - readonly property int mPLATFORM_TYPE_RPI:0; - readonly property int mPLATFORM_TYPE_ROCK:1; - readonly property int mPLATFORM_TYPE_X20:2; - readonly property int mPLATFORM_TYPE_X86:3; property int m_platform_type: 0; // Secondary camera only supports a few options - we can omit @@ -40,34 +35,15 @@ Card { function set_ohd_platform_type(){ const ohd_platform_type=_ohdSystemAir.ohd_platform_type; console.log("Platform:"+ohd_platform_type) - if(ohd_platform_type>=10 && ohd_platform_type<20){ - m_platform_type=mPLATFORM_TYPE_RPI; - return true; - } - if(ohd_platform_type>=20 && ohd_platform_type<30){ - m_platform_type=mPLATFORM_TYPE_ROCK; - return true; - } - if(ohd_platform_type==1){ - m_platform_type=mPLATFORM_TYPE_X86; - return true; - } - if(ohd_platform_type==30){ - m_platform_type=mPLATFORM_TYPE_X20; + m_platform_type=ohd_platform_type; + if(ohd_platform_type>=1){ return true; } return false; } function get_platform_name(){ - if(m_platform_type==mPLATFORM_TYPE_RPI){ - return "RPI"; - }else if(m_platform_type==mPLATFORM_TYPE_ROCK){ - return "ROCK"; - }else if(m_platform_type==mPLATFORM_TYPE_X20){ - return "X20"; - } - return "X86"; + return _ohdSystemAir.ohd_platform_type_as_string } // For debugging @@ -91,102 +67,14 @@ Card { // The manufacturer model(s) don't need a value ListModel{ - id: model_manufacturers_rpi - ListElement {title: "ARDUCAM"} - ListElement {title: "VEYE"} - ListElement {title: "RPI FOUNDATION"} - ListElement {title: "GEEKWORM"} - ListElement {title: "USB"} - ListElement {title: "DEV/DEBUG"} - } - ListModel{ - id: model_manufacturers_rock - ListElement {title: "ARDUCAM"} - ListElement {title: "RADXA"} - ListElement {title: "USB"} - ListElement {title: "DEV/DEBUG"} + id: model_manufacturers + ListElement {title: "DUMMY_MANUFACTURER"} } ListModel{ - id: model_manufacturers_x20 - ListElement {title: "RUNCAM"} - } - ListModel{ // X86 doesn't reall have manufacturers - id: model_manufacturers_x86 - ListElement {title: "USB"} - ListElement {title: "DEV/DEBUG"} - } - ListModel{ // Secondary camera doesn't reall have manufacturers - id: model_manufacturers_secondary_cam - ListElement {title: "SECONDARY CAM"} + id: model_cameras_for_this_manufacturer + ListElement {title: "CAM TYPE"; value: 0} } - // Actual CAMERA model(s) - // Value needs to map to the corrseponding openhd camera type ! - ListModel{ - id: rpi_arducam_cameras - ListElement {title: "SKYMASTERHDR"; value: 40} - ListElement {title: "SKYVISIONPRO"; value: 41} - ListElement {title: "IMX477m"; value: 42} - ListElement {title: "IMX462"; value: 43} - ListElement {title: "IMX327"; value: 44} - ListElement {title: "IMX290"; value: 45} - ListElement {title: "IMX462_LOWLIGHT_MINI"; value: 46} - } - ListModel{ - id: rpi_veye_cameras - ListElement {title: "2MP"; value: 60} - ListElement {title: "CSIMX307"; value: 61} - ListElement {title: "CSSC132"; value: 62} - ListElement {title: "MVCAM"; value: 63} - } - ListModel{ - id: rpi_rpif_cameras - ListElement {title: "V1 OV5647"; value: 30} - ListElement {title: "V2 IMX219"; value: 31} - ListElement {title: "V3 IMX708"; value: 32} - ListElement {title: "HQ IMX477"; value: 33} - } - ListModel{ - id: rpi_geekworm_cameras - ListElement {title: "HDMI to CSI"; value: 20} - } - ListModel{ - id: cameras_usb - ListElement {title: "INFIRAY USB"; value: 11} - ListElement {title: "EXP USB GENERIC"; value: 10} - } - ListModel{ - id: cameras_debug - ListElement {title: "Dummy (debug)"; value: 0} - ListElement {title: "External (DEV)"; value: 2} - ListElement {title: "External IP (DEV)"; value: 3} - ListElement {title: "DEV Filecamera"; value: 4} - } - ListModel{ - id: x20_runcam_cameras - ListElement {title: "RUNCAM NANO"; value: 70} - } - ListModel{ - id: rock_arducam_cameras - ListElement {title: "ARDUCAM ROCK 0"; value: 0} - ListElement {title: "ARDUCAM ROCK 1"; value: 1} - } - ListModel{ - id: rock_raxca_cameras - ListElement {title: "HDMI IN"; value: 0} - } - ListModel{ - id: generic_secondary_camera_options - ListElement {title: "DISABLED (Default)"; value: 255} - ListElement {title: "EXP USB GENERIC"; value: 10} - ListElement {title: "INFIRAY USB"; value: 11} - ListElement {title: "INFIRAY USB T2"; value: 12} - ListElement {title: "Dummy (debug)"; value: 0} - ListElement {title: "External (DEV)"; value: 2} - ListElement {title: "External IP (DEV)"; value: 3} - } - - function initialize_and_show(){ console.log("Choose camera dialoque opened with "+get_platform_name()); comboBoxManufacturers.model=get_manufacturers_model(); @@ -211,12 +99,7 @@ Card { combobox_cameras.model=get_cameras_model(0); combobox_cameras.currentIndex=0; } - if(m_is_for_secondary_camera){ - comboBoxManufacturers.model=model_manufacturers_secondary_cam; - combobox_cameras.model=generic_secondary_camera_options; - }else{ - comboBoxManufacturers.enabled=true; - } + comboBoxManufacturers.enabled=true; // If there is only one manufacturer choice, disable the combobox. if(comboBoxManufacturers.model.count<=1){ comboBoxManufacturers.enabled=false; @@ -226,65 +109,34 @@ Card { m_user_selected_camera_type=-1; visible=true; enabled=true; + populate_main_camera_selector() } + function get_manufacturers_model(){ - if(m_is_for_secondary_camera){ - return model_manufacturers_secondary_cam - } - if(m_platform_type==mPLATFORM_TYPE_RPI){ - return model_manufacturers_rpi; - }else if(m_platform_type==mPLATFORM_TYPE_ROCK){ - return model_manufacturers_rock - }else if(m_platform_type==mPLATFORM_TYPE_X20){ - return model_manufacturers_x20 - }else if(m_platform_type==mPLATFORM_TYPE_X86){ - return model_manufacturers_x86 + var manufacturers=m_cam_model.get_manufacturer_choices(m_platform_type); + model_manufacturers.clear(); + for(var i=0;i