Skip to content

Commit

Permalink
Improve UI:
Browse files Browse the repository at this point in the history
1) More consistent layouting for the (SCAN,ANALYZE,STBC,TX POWER) elements
2) Analyze progress
3) refactor out the qopenhd frequency list
4) recording on bitrate widget (centralize camera stuff around it)
  • Loading branch information
Consti10 committed Nov 3, 2023
1 parent 2145e31 commit 8226822
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 33 deletions.
56 changes: 45 additions & 11 deletions app/telemetry/models/camerastreammodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,50 @@ CameraStreamModel &CameraStreamModel::instance(int cam_index)
assert(false);
}

QString CameraStreamModel::camera_type_to_string(int camera_type)
{
if(camera_type<=0)return "Unknown";
if(camera_type==1)return "DUMMY";
if(camera_type==2)return "RPI_CSI_MMAL";
if(camera_type==3)return "RPI_CSI_VEYE_V4l2";
if(camera_type==4)return "RPI_CSI_LIBCAMERA";
if(camera_type==5)return "JETSON_CSI";
if(camera_type==6)return "ROCKCHIP_CSI";
if(camera_type==7)return "ALLWINNER_CSI";
if(camera_type==8)return "UVC (USB)";
if(camera_type==9)return "UVC_H264";
if(camera_type==10)return "IP";
if(camera_type==11)return "ROCK_HDMI";
if(camera_type==12)return "CUSTOM UNMANAGED";
return "ERROR";
}

QString CameraStreamModel::camera_status_to_string(int camera_status)
{
if(camera_status<0)return "N/A";
if(camera_status==0)return "X";
if(camera_status==1)return "streaming";
if(camera_status==2)return "restarting";
return "ERROR";
}

QString CameraStreamModel::camera_codec_to_string(int camera_codec)
{
if(camera_codec<0)return "ERROR";
if(camera_codec==0)return "h264";
if(camera_codec==1)return "h265";
if(camera_codec==2)return "mjpeg";
return "ERROR";
}

QString CameraStreamModel::camera_recording_mode_to_string(int recording_mode)
{
if(recording_mode<0)return "n/a";
if(recording_mode==0)return "not active";
if(recording_mode==1)return "active";
return "error";
}

void CameraStreamModel::update_mavlink_openhd_stats_wb_video_air(const mavlink_openhd_stats_wb_video_air_t &msg)
{
const auto curr_recommended_bitrate_kbits=msg.curr_recommended_bitrate;
Expand Down Expand Up @@ -88,6 +132,7 @@ void CameraStreamModel::update_mavlink_openhd_camera_status_air(const mavlink_op
set_curr_curr_keyframe_interval(msg.encoding_keyframe_interval);
set_air_recording_active(msg.air_recording_active);
set_camera_type(msg.cam_type);
set_encoding_codec(msg.encoding_format);
{
std::stringstream ss;
ss<<(int)msg.stream_w<<"x"<<(int)msg.stream_h<<"@"<<msg.stream_fps;
Expand Down Expand Up @@ -124,18 +169,7 @@ void CameraStreamModel::update_mavlink_openhd_camera_status_air(const mavlink_op
}else{
qDebug()<<"Invalid video codec: "<<codec_in_openhd;
}
// Feature - log in the HUD if the camera is restarting
set_camera_status(msg.cam_status);
if(msg.cam_status==2){
const auto elapsed=std::chrono::steady_clock::now()-m_last_hud_message_camera_status;
if(elapsed>=std::chrono::seconds(3)){
m_last_hud_message_camera_status=std::chrono::steady_clock::now();
std::stringstream log;
log<<(secondary ? "CAM2" : "CAM1");
log<<" is restarting, please wait";
HUDLogMessagesModel::instance().add_message_info(log.str().c_str());
}
}
}

void CameraStreamModel::update_mavlink_openhd_stats_wb_video_air_fec_performance(const mavlink_openhd_stats_wb_video_air_fec_performance_t &msg)
Expand Down
8 changes: 7 additions & 1 deletion app/telemetry/models/camerastreammodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class CameraStreamModel : public QObject
L_RO_PROP(QString,air_tx_packets_per_second_and_bits_per_second,set_air_tx_packets_per_second_and_bits_per_second,"N/A")
// UI might change slightly depending on the camera type
L_RO_PROP(int,camera_type,set_camera_type,-1)
L_RO_PROP(int,camera_status,set_camera_status,-1)
L_RO_PROP(int,camera_status,set_camera_status,-1)
L_RO_PROP(int,encoding_codec,set_encoding_codec,-1)
//
// These are generated by the OpenHD ground unit
//
Expand All @@ -64,6 +65,11 @@ class CameraStreamModel : public QObject
L_RO_PROP(qint64,count_blocks_recovered,set_count_blocks_recovered,-1)
L_RO_PROP(qint64,count_fragments_recovered,set_count_fragments_recovered,-1)
L_RO_PROP(QString,curr_fec_decode_time_avg_min_max,set_curr_fec_decode_time_avg_min_max,"avg na, min na, max na")
public:
Q_INVOKABLE QString camera_type_to_string(int camera_type);
Q_INVOKABLE QString camera_status_to_string(int camera_status);
Q_INVOKABLE QString camera_codec_to_string(int camera_codec);
Q_INVOKABLE QString camera_recording_mode_to_string(int recording_mode);
//
public:
// generated by wb / link
Expand Down
2 changes: 1 addition & 1 deletion app/telemetry/settings/wblinksettingshelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ void WBLinkSettingsHelper::change_param_air_async(const int comp_id,const std::s
if(std::holds_alternative<int32_t>(param_value)){
ss<<std::get<int32_t>(param_value);
}else{
ss<<std::get<int32_t>(param_value);
ss<<std::get<std::string>(param_value);
}
ss<<",please check uplink";
HUDLogMessagesModel::instance().add_message_warning(ss.str().c_str());
Expand Down
1 change: 1 addition & 0 deletions qml/ui/elements/AppSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Settings {
property bool bitrate_declutter: false
property double bitrate_warn: 0
property double bitrate_caution: 0
property bool camera_bitrate_widget_show_recording: true
//
property bool qrenderstats_show: false
property bool qrenderstats_declutter: false
Expand Down
3 changes: 2 additions & 1 deletion qml/ui/elements/SimpleLeftRightText.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import QtQuick 2.12

Item {
width: parent.width
height: 24
//height: 24
height: 20

property string m_left_text: "FILL ME"
property string m_right_text: "FILL ME"
Expand Down
108 changes: 89 additions & 19 deletions qml/ui/widgets/VideoBitrateWidgetGeneric.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BaseWidget {

hasWidgetDetail: true
hasWidgetAction: true
widgetActionHeight: 400
widgetActionHeight: 450

property var m_camera_stream_model: m_is_for_primary_camera ? _cameraStreamModelPrimary : _cameraStreamModelSecondary

Expand Down Expand Up @@ -108,6 +108,17 @@ BaseWidget {
}
}

ListModel{
id: resolutions_model
ListElement {title: "480p60(16:9)"; value: "848x480@60"}
ListElement {title: "480p60(4:3)"; value: "640x480@60"}
ListElement {title: "720p49(16:9)"; value: "1280x720@49"}
ListElement {title: "720p60(4:3)"; value: "960x720@60"}
ListElement {title: "1080p30(16:9)"; value: "1920x1080@30"}
ListElement {title: "1080p30(4:3)"; value: "1440x1080@30"}
ListElement {title: "1080p49(4:3)"; value: "1440x1080@49"}
}


//----------------------------- DETAIL BELOW ----------------------------------

Expand All @@ -120,6 +131,27 @@ BaseWidget {

BaseWidgetDefaultUiControlElements{
id: idBaseWidgetDefaultUiControlElements
Item {
width: 230
height: 32
Text {
text: qsTr("Show RED recording active")
color: "white"
height: parent.height
font.bold: true
font.pixelSize: detailPanelFontPixels
anchors.left: parent.left
verticalAlignment: Text.AlignVCenter
}
Switch {
width: 32
height: parent.height
anchors.rightMargin: 6
anchors.right: parent.right
checked: settings.camera_bitrate_widget_show_recording
onCheckedChanged: settings.camera_bitrate_widget_show_recording = checked
}
}
}
}

Expand All @@ -134,15 +166,50 @@ BaseWidget {
width:200

SimpleLeftRightText{
m_left_text: qsTr("Res@Framerate:")
m_right_text: m_camera_stream_model.curr_set_video_format_and_codec
m_left_text: qsTr("Status:")
m_right_text: {
if(!_ohdSystemAir.is_alive)return "no air";
return _cameraStreamModelPrimary.camera_status_to_string(m_camera_stream_model.camera_status);
}
}
SimpleLeftRightText{
m_left_text: qsTr("Type:")
m_right_text: {
if(!_ohdSystemAir.is_alive)return "n/a";
return _cameraStreamModelPrimary.camera_type_to_string(m_camera_stream_model.camera_type);
}
}
SimpleLeftRightText{
m_left_text: qsTr("Codec:")
m_right_text: {
if(!_ohdSystemAir.is_alive)return "n/a";
return _cameraStreamModelPrimary.camera_codec_to_string(m_camera_stream_model.encoding_codec);
}
}

//SimpleLeftRightText{
// m_left_text: ""
// m_right_text: ""
//}
Item{
ComboBox{
id: resolution_fps_cb
model: resolutions_model
textRole: "title"
width: 200
Layout.preferredWidth: 200
Layout.minimumWidth: 200
height: 50
currentIndex: 0
displayText: {
if(!_ohdSystemAir.is_alive)return "Res@fps N/A";
return m_curr_video_format;
}
onActivated: {
console.log("onActivated:"+currentIndex);
if(currentIndex<0)return;
const resolution=model.get(currentIndex).value
console.log("Selected resolution: "+resolution);
set_camera_resolution(resolution);
}
enabled: _ohdSystemAir.is_alive;
}
/*Item{
width: parent.width
height: 150
//color: "green"
Expand Down Expand Up @@ -187,7 +254,7 @@ BaseWidget {
highlighted: m_curr_video_format=="1440x1080@30"
}
}
}
}*/
SimpleLeftRightText{
m_left_text: qsTr("Bitrate SET:")
m_right_text: m_camera_stream_model.curr_recomended_video_bitrate_string
Expand Down Expand Up @@ -236,10 +303,7 @@ BaseWidget {
m_left_text: qsTr("AIR RECORD:");
m_right_text: {
if(!_ohdSystemAir.is_alive)return "N/A";
if(m_camera_recording_mode){
return "RECORDING";
}
return "NOT ACTIVE"
return _cameraStreamModelPrimary.camera_recording_mode_to_string(m_camera_stream_model.air_recording_active);
}
}
// For camera 1
Expand Down Expand Up @@ -275,12 +339,6 @@ BaseWidget {
}
}
}

/*Item{
id: placeholder
width:parent.width
height: 10
}*/
Item {
width: parent.width
height: 32
Expand Down Expand Up @@ -338,5 +396,17 @@ BaseWidget {
style: Text.Outline
styleColor: settings.color_glow
}

Rectangle{
width: 12
height: width
radius: width
color: "red";
anchors.right: camera_icon.left
anchors.rightMargin: 2
anchors.verticalCenter: parent.verticalCenter
visible: settings.camera_bitrate_widget_show_recording && m_camera_is_currently_recording
}

}
}

0 comments on commit 8226822

Please sign in to comment.