Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cruise mode heading adjustment and heading error OSD indicators #3380

Merged
merged 1 commit into from Jun 23, 2018

Conversation

Projects
None yet
2 participants
@shellixyz
Copy link
Collaborator

commented Jun 16, 2018

No description provided.

@shellixyz shellixyz force-pushed the shellixyz:nav_cruise_mode_osd_items branch 3 times, most recently from ebf4b26 to bf53f0e Jun 19, 2018

int16_t heading_adjust = lrintf(CENTIDEGREES_TO_DEGREES((float)getCruiseHeadingAdjustment()));

if (ARMING_FLAG(ARMED) && ((!FLIGHT_MODE(NAV_CRUISE_MODE)) || !(isAdjustingPosition() || isAdjustingHeading() || (heading_adjust != 0)))) {
displayWrite(osdDisplayPort, elemPosX, elemPosY, " ");

This comment has been minimized.

Copy link
@fiam

fiam Jun 22, 2018

Member

I don't like this extra call to displayWrite(). In functions as big as this one, I prefer to avoid early returns when possible. Can you make it write to buff the 5-space string? e.g.

            if (ARMING_FLAG(ARMED) && ((!FLIGHT_MODE(NAV_CRUISE_MODE)) || !(isAdjustingPosition() || isAdjustingHeading() || (heading_adjust != 0)))) {
                strcpy(buff, "     ");
            } else {
                buff[0] = SYM_HEADING;
                if (!ARMING_FLAG(ARMED))
                    buff[1] = buff[2] = buff[3] = buff[4] = '-';
                else if (FLIGHT_MODE(NAV_CRUISE_MODE)) {
                    tfp_sprintf(buff + 1, "%4d", heading_adjust);
                }
                buff[5] = SYM_DEGREES;
            }
            buff[6] = '\0';

This comment has been minimized.

Copy link
@fiam

fiam Jun 23, 2018

Member

Just did a quick test and the early returns save 40 bytes of flash. Given the current state of flash in F3, I guess we're better off taking the flash savings.

@fiam fiam added this to the 2.0 milestone Jun 22, 2018

@shellixyz shellixyz force-pushed the shellixyz:nav_cruise_mode_osd_items branch from bf53f0e to c9a69a6 Jun 22, 2018

@fiam fiam merged commit e05d2b3 into iNavFlight:development Jun 23, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.