Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3329,6 +3329,13 @@ groups:
max: 600
type: int16_t
field: msp_displayport_fullframe_interval
- name: osd_framerate_hz
description: "OSD element refresh rate in Hz. Controls how often OSD elements are updated (except artificial horizon and telemetry which are always updated). Higher values provide smoother updates but increase CPU load. Set to -1 for legacy mode (one element per frame). Default: -1"
default_value: -1
min: -1
max: 60
type: int8_t
field: osd_framerate_hz
- name: osd_units
description: "IMPERIAL, METRIC, UK"
default_value: "METRIC"
Expand Down
36 changes: 35 additions & 1 deletion src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4242,6 +4242,18 @@ uint8_t osdIncElementIndex(uint8_t elementIndex)
return elementIndex;
}

static void osdDrawAllElements(void)
{
for (uint8_t element = 0; element < OSD_ITEM_COUNT; element++) {
osdDrawSingleElement(element);
}

osdDrawSingleElement(OSD_ARTIFICIAL_HORIZON);
if (osdConfig()->telemetry>0){
osdDisplayTelemetry();
}
}

void osdDrawNextElement(void)
{
static uint8_t elementIndex = 0;
Expand Down Expand Up @@ -4304,6 +4316,7 @@ PG_RESET_TEMPLATE(osdConfig_t, osdConfig,
.video_system = SETTING_OSD_VIDEO_SYSTEM_DEFAULT,
.row_shiftdown = SETTING_OSD_ROW_SHIFTDOWN_DEFAULT,
.msp_displayport_fullframe_interval = SETTING_OSD_MSP_DISPLAYPORT_FULLFRAME_INTERVAL_DEFAULT,
.framerate_hz = SETTING_OSD_FRAMERATE_HZ_DEFAULT,

.ahi_reverse_roll = SETTING_OSD_AHI_REVERSE_ROLL_DEFAULT,
.ahi_max_pitch = SETTING_OSD_AHI_MAX_PITCH_DEFAULT,
Expand Down Expand Up @@ -5976,7 +5989,28 @@ static void osdRefresh(timeUs_t currentTimeUs)
displayClearScreen(osdDisplayPort);
fullRedraw = false;
}
osdDrawNextElement();

if (osdConfig()->osd_framerate_hz == -1) {
osdDrawNextElement();
} else {
static uint32_t lastDrawAllTimeUs = 0;
const int8_t hz = osdConfig()->osd_framerate_hz;
const uint32_t drawAllIntervalUs = (hz > 0) ? (1000000 / hz) : 0;

const bool forceDraw = (drawAllIntervalUs == 0);
const bool intervalExceeded = (currentTimeUs - lastDrawAllTimeUs) >= drawAllIntervalUs;

if (forceDraw || intervalExceeded) {
osdDrawAllElements();
lastDrawAllTimeUs = currentTimeUs;
}

osdDrawSingleElement(OSD_ARTIFICIAL_HORIZON);
if (osdConfig()->telemetry>0){
osdDisplayTelemetry();
}
}

displayHeartbeat(osdDisplayPort);
displayCommitTransaction(osdDisplayPort);
#ifdef OSD_CALLS_CMS
Expand Down
1 change: 1 addition & 0 deletions src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ typedef struct osdConfig_s {
videoSystem_e video_system;
uint8_t row_shiftdown;
int16_t msp_displayport_fullframe_interval;
int8_t osd_framerate_hz;

// Preferences
uint8_t main_voltage_decimals;
Expand Down