fix(atxxxx): draw at the right address and inside the NTSC screen (#29890)

* fix(atxxxx): write the display memory address low byte unchanged

Above address 255 the low byte was computed as the truncated address minus 0xFF, one more than the address itself. Every character from row 8, column 16 on landed one column right, the last PAL cell was written past the 480-entry display memory, and address 256 was never cleared.

Assisted-by: Claude:claude-opus-5-5

* fix(atxxxx): keep the flight mode and flight time on the NTSC screen

NTSC shows 13 rows, so the flight time on row 14 was never visible once NTSC could be selected. Both elements are now placed from the bottom row, which leaves the PAL layout unchanged. The row count now follows the same OSD_ATXXXX_CFG check as the PAL bit, so boards that start the driver with the parameter at 0 get the NTSC layout they now run in.

Assisted-by: Claude:claude-opus-5-5
This commit is contained in:
Jacob Dahl authored and GitHub committed 2026-11-18 17:11:01 -07:00
1 parent 5d9263851e
commit 0d9ef5f510
2 files changed
+14 -21

No files matched your search

+12 -21
View File
@@ -76,10 +76,8 @@ OSDatxxxx::init()
}
// clear the screen
int num_rows = (_param_osd_atxxxx_cfg.get() == 1 ? OSD_NUM_ROWS_NTSC : OSD_NUM_ROWS_PAL);
for (int i = 0; i < OSD_CHARS_PER_ROW; i++) {
for (int j = 0; j < num_rows; j++) {
for (int j = 0; j < _num_rows; j++) {
add_character_to_screen(' ', i, j);
}
}
@@ -119,11 +117,9 @@ int
OSDatxxxx::init_osd()
{
int ret = PX4_OK;
uint8_t data = OSD_ZERO_BYTE;
if (_param_osd_atxxxx_cfg.get() == 2) {
data |= OSD_PAL_TX_MODE;
}
const bool pal = (_param_osd_atxxxx_cfg.get() == 2);
const uint8_t data = pal ? OSD_PAL_TX_MODE : OSD_ZERO_BYTE;
_num_rows = pal ? OSD_NUM_ROWS_PAL : OSD_NUM_ROWS_NTSC;
ret |= writeRegister(0x00, data);
ret |= writeRegister(0x04, OSD_ZERO_BYTE);
@@ -174,23 +170,14 @@ int
OSDatxxxx::add_character_to_screen(char c, uint8_t pos_x, uint8_t pos_y)
{
uint16_t position = (OSD_CHARS_PER_ROW * pos_y) + pos_x;
uint8_t position_lsb = 0;
int ret = PX4_ERROR;
if (position > 0xFF) {
position_lsb = static_cast<uint8_t>(position) - 0xFF;
ret = writeRegister(0x05, 0x01); //DMAH
} else {
position_lsb = static_cast<uint8_t>(position);
ret = writeRegister(0x05, 0x00); //DMAH
}
int ret = writeRegister(0x05, position > 0xFF ? 0x01 : 0x00); //DMAH
if (ret != 0) {
return ret;
}
ret = writeRegister(0x06, position_lsb); //DMAL
ret = writeRegister(0x06, static_cast<uint8_t>(position)); //DMAL
if (ret != 0) {
return ret;
@@ -477,17 +464,21 @@ OSDatxxxx::update_screen()
clear_line(1, 3, 10);
}
// Placed relative to the bottom row, since NTSC shows 13 rows and PAL 16.
const uint8_t flight_mode_row = _num_rows - 4;
const uint8_t flight_time_row = _num_rows - 2;
const char *flight_mode = "";
if (_arming_state == vehicle_status_s::ARMING_STATE_ARMED) {
float flight_time_sec = static_cast<float>((hrt_absolute_time() - _arming_timestamp) / (1e6f));
ret |= add_flighttime(flight_time_sec, 1, 14);
ret |= add_flighttime(flight_time_sec, 1, flight_time_row);
} else {
flight_mode = get_flight_mode(_nav_state);
}
add_string_to_screen_centered(flight_mode, 12, 10);
add_string_to_screen_centered(flight_mode, flight_mode_row, 10);
return ret;
}
+2
View File
@@ -127,6 +127,8 @@ private:
// flight mode
uint8_t _nav_state{0};
uint8_t _num_rows{OSD_NUM_ROWS_NTSC};
DEFINE_PARAMETERS(
(ParamInt<px4::params::OSD_ATXXXX_CFG>) _param_osd_atxxxx_cfg
)