51 ModuleParams(nullptr),
52 ScheduledWorkItem(MODULE_NAME,
px4::device_bus_to_wq(get_device_id()))
66 const char *myoptarg =
nullptr;
67 int spi_bus = OSD_BUS;
69 while ((ch = px4_getopt(argc, argv,
"b:", &myoptind, &myoptarg)) != EOF) {
72 spi_bus = (uint8_t)atoi(myoptarg);
80 PX4_ERR(
"alloc failed");
84 if (osd->
init() != PX4_OK) {
90 _task_id = task_id_is_work_queue;
123 for (
int j = 0; j < num_rows; j++) {
148 if (data != 1 || ret != PX4_OK) {
149 PX4_ERR(
"probe failed (%i %i)", ret, data);
161 if (_param_osd_atxxxx_cfg.get() == 2) {
180 int ret = transfer(&cmd[0], &cmd[0], count + 1);
187 memcpy(&data[0], &cmd[1], count);
200 int ret = transfer(&cmd[0],
nullptr, 2);
214 uint8_t position_lsb = 0;
217 if (position > 0xFF) {
218 position_lsb =
static_cast<uint8_t
>(
position) - 0xFF;
222 position_lsb =
static_cast<uint8_t
>(
position);
244 int len = strlen(str);
246 if (len > max_length) {
251 int before = (max_length - len) / 2;
253 for (
int i = 0; i < before; ++i) {
257 for (
int i = 0; i < len; ++i) {
269 for (
int i = 0; i < length; ++i) {
282 buf[
sizeof(buf) - 1] =
'\0';
284 for (
int i = 0; buf[i] !=
'\0'; i++) {
294 buf[
sizeof(buf) - 1] =
'\0';
296 for (
int i = 0; buf[i] !=
'\0'; i++) {
312 buf[
sizeof(buf) - 1] =
'\0';
314 for (
int i = 0; buf[i] !=
'\0'; i++) {
328 buf[
sizeof(buf) - 1] =
'\0';
330 for (
int i = 0; buf[i] !=
'\0'; i++) {
369 if (battery.connected) {
396 if (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED &&
401 }
else if (vehicle_status.arming_state != vehicle_status_s::ARMING_STATE_ARMED &&
419 case vehicle_status_s::NAVIGATION_STATE_MANUAL:
420 flight_mode =
"MANUAL";
423 case vehicle_status_s::NAVIGATION_STATE_ALTCTL:
424 flight_mode =
"ALTITUDE";
427 case vehicle_status_s::NAVIGATION_STATE_POSCTL:
428 flight_mode =
"POSITION";
431 case vehicle_status_s::NAVIGATION_STATE_AUTO_RTL:
432 flight_mode =
"RETURN";
435 case vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION:
436 flight_mode =
"MISSION";
439 case vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER:
440 case vehicle_status_s::NAVIGATION_STATE_AUTO_RCRECOVER:
441 case vehicle_status_s::NAVIGATION_STATE_AUTO_RTGS:
442 case vehicle_status_s::NAVIGATION_STATE_DESCEND:
443 case vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF:
444 case vehicle_status_s::NAVIGATION_STATE_AUTO_LAND:
445 case vehicle_status_s::NAVIGATION_STATE_AUTO_FOLLOW_TARGET:
446 case vehicle_status_s::NAVIGATION_STATE_AUTO_PRECLAND:
447 flight_mode =
"AUTO";
450 case vehicle_status_s::NAVIGATION_STATE_AUTO_LANDENGFAIL:
451 case vehicle_status_s::NAVIGATION_STATE_AUTO_LANDGPSFAIL:
452 flight_mode =
"FAILURE";
455 case vehicle_status_s::NAVIGATION_STATE_ACRO:
456 flight_mode =
"ACRO";
459 case vehicle_status_s::NAVIGATION_STATE_TERMINATION:
460 flight_mode =
"TERMINATE";
463 case vehicle_status_s::NAVIGATION_STATE_OFFBOARD:
464 flight_mode =
"OFFBOARD";
467 case vehicle_status_s::NAVIGATION_STATE_STAB:
468 flight_mode =
"STABILIZED";
471 case vehicle_status_s::NAVIGATION_STATE_RATTITUDE:
472 flight_mode =
"RATTITUDE";
540 printf(
"%s\n\n", reason);
543 PRINT_MODULE_DESCRIPTION(
546 OSD driver for the ATXXXX chip that is mounted on the OmnibusF4SD board for example. 548 It can be enabled with the OSD_ATXXXX_CFG parameter. 551 PRINT_MODULE_USAGE_NAME("atxxxx",
"driver");
552 PRINT_MODULE_USAGE_COMMAND_DESCR(
"start",
"Start the driver");
553 PRINT_MODULE_USAGE_PARAM_INT(
'b', -1, 0, 100,
"SPI bus (default: use board-specific bus)",
true);
554 PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
int add_flighttime(float flight_time, uint8_t pos_x, uint8_t pos_y)
float _battery_voltage_filtered_v
uORB::Subscription _local_position_sub
bool _local_position_valid
#define OSD_SPI_BUS_SPEED
static constexpr uint32_t OSD_UPDATE_RATE
int main(int argc, char **argv)
static int print_usage(const char *reason=nullptr)
int readRegister(unsigned reg, uint8_t *data, unsigned count)
static int custom_command(int argc, char *argv[])
void add_string_to_screen_centered(const char *str, uint8_t pos_y, int max_length)
int add_altitude(uint8_t pos_x, uint8_t pos_y)
void init()
Activates/configures the hardware registers.
#define DEVICE_LOG(FMT,...)
int atxxxx_main(int argc, char *argv[])
#define OSD_SYMBOL_FLIGHT_TIME
bool updated()
Check if there is a new update.
#define OSD_CHARS_PER_ROW
#define OSD_SYMBOL_BATT_3
float _battery_discharge_mah
#define OSD_NUM_ROWS_NTSC
void clear_line(uint8_t pos_x, uint8_t pos_y, int length)
int writeRegister(unsigned reg, uint8_t data)
static int task_spawn(int argc, char *argv[])
int add_battery_info(uint8_t pos_x, uint8_t pos_y)
static const char * get_flight_mode(uint8_t nav_state)
uint64_t _arming_timestamp
uORB::Subscription _vehicle_status_sub
#define OSD_SYMBOL_ARROW_NORTH
bool copy(void *dst)
Copy the struct.
int add_character_to_screen(char c, uint8_t pos_x, uint8_t pos_y)
OSDatxxxx(int bus=OSD_BUS)
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
uORB::Subscription _battery_sub