Skip to content

Commit

Permalink
Use extended OSD glyphs for dot in numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
error414 committed Jan 28, 2025
1 parent cd8f4f3 commit a4ded42
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 39 deletions.
27 changes: 17 additions & 10 deletions src/main/io/adsb.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
/*
* This file is part of Cleanflight.
* This file is part of INAV Project.
*
* Cleanflight is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Cleanflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Alternatively, the contents of this file may be used under the terms
* of the GNU General Public License Version 3, as described below:
*
* This file is free software: you may copy, redistribute and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see http://www.gnu.org/licenses/.
*/


Expand Down
73 changes: 44 additions & 29 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2134,16 +2134,8 @@ static bool osdDrawSingleElement(uint8_t item)
#ifdef USE_ADSB
case OSD_ADSB_WARNING:
{
static uint8_t adsblen = 1;
uint8_t arrowPositionX = 0;

for (int i = 0; i <= adsblen; i++) {
buff[i] = SYM_BLANK;
}

buff[adsblen]='\0';
displayWrite(osdDisplayPort, elemPosX, elemPosY, buff); // clear any previous chars because variable element size
adsblen=1;
uint8_t buffIndex = 0;
uint8_t arrowIndexIndex = 0;
adsbVehicle_t *vehicle = findVehicleClosest();

if(vehicle != NULL){
Expand All @@ -2156,31 +2148,54 @@ static bool osdDrawSingleElement(uint8_t item)
vehicle->calculatedVehicleValues.dist < METERS_TO_CENTIMETERS(osdConfig()->adsb_distance_warning) &&
(osdConfig()->adsb_ignore_plane_above_me_limit == 0 || METERS_TO_CENTIMETERS(osdConfig()->adsb_ignore_plane_above_me_limit) > vehicle->calculatedVehicleValues.verticalDistance)
){
buff[0] = SYM_ADSB;
osdFormatDistanceStr(&buff[1], (int32_t)vehicle->calculatedVehicleValues.dist);
adsblen = strlen(buff);

buff[adsblen-1] = SYM_BLANK;

arrowPositionX = adsblen-1;
osdFormatDistanceStr(&buff[adsblen], vehicle->calculatedVehicleValues.verticalDistance);
adsblen = strlen(buff)-1;
buff[buffIndex++] = SYM_ADSB;

//////////////////////////////////////////////////////
// distance to ADSB vehicle
osdFormatDistanceSymbol(&buff[buffIndex], (int32_t)vehicle->calculatedVehicleValues.dist, 0, 3);
buffIndex += 4;
//////////////////////////////////////////////////////

//////////////////////////////////////////////////////
// direction to ADSB vehicle
arrowIndexIndex = buffIndex;
buff[arrowIndexIndex] = SYM_BLANK; // space for direction arrow
buffIndex++;
//////////////////////////////////////////////////////

//////////////////////////////////////////////////////
// ALT diff to ADSB vehicle just space
osdFormatAltitudeSymbol(&buff[buffIndex], ((int32_t)vehicle->calculatedVehicleValues.verticalDistance));
buffIndex += osdConfig()->decimals_altitude + 2;
//////////////////////////////////////////////////////

if (vehicle->calculatedVehicleValues.dist < METERS_TO_CENTIMETERS(osdConfig()->adsb_distance_alert)) {
TEXT_ATTRIBUTES_ADD_BLINK(elemAttr);
}
}

buff[adsblen]='\0';
displayWriteWithAttr(osdDisplayPort, elemPosX, elemPosY, buff, elemAttr);
buff[buffIndex]='\0';
displayWriteWithAttr(osdDisplayPort, elemPosX, elemPosY, buff, elemAttr);

if (arrowPositionX > 0){
int16_t panHomeDirOffset = 0;
if (osdConfig()->pan_servo_pwm2centideg != 0){
panHomeDirOffset = osdGetPanServoOffset();
//////////////////////////////////////////////////////
// ALT diff to ADSB vehicle draw
if(arrowIndexIndex > 0)
{
int16_t panHomeDirOffset = 0;
if (osdConfig()->pan_servo_pwm2centideg != 0){
panHomeDirOffset = osdGetPanServoOffset();
}
int16_t flightDirection = STATE(AIRPLANE) ? CENTIDEGREES_TO_DEGREES(posControl.actualState.cog) : DECIDEGREES_TO_DEGREES(osdGetHeading());
osdDrawDirArrow(osdDisplayPort, osdGetDisplayPortCanvas(), OSD_DRAW_POINT_GRID(elemPosX + arrowIndexIndex, elemPosY), CENTIDEGREES_TO_DEGREES(vehicle->calculatedVehicleValues.dir) - flightDirection + panHomeDirOffset);
}
int16_t flightDirection = STATE(AIRPLANE) ? CENTIDEGREES_TO_DEGREES(posControl.actualState.cog) : DECIDEGREES_TO_DEGREES(osdGetHeading());
osdDrawDirArrow(osdDisplayPort, osdGetDisplayPortCanvas(), OSD_DRAW_POINT_GRID(elemPosX + arrowPositionX, elemPosY), CENTIDEGREES_TO_DEGREES(vehicle->calculatedVehicleValues.dir) - flightDirection + panHomeDirOffset);
//////////////////////////////////////////////////////
}
else
{
for (int i = 0; i < 11; i++) {
buff[i] = SYM_BLANK;
}

displayWrite(osdDisplayPort, elemPosX, elemPosY, buff);
}

return true;
Expand All @@ -2189,7 +2204,7 @@ static bool osdDrawSingleElement(uint8_t item)
{
buff[0] = SYM_ADSB;
if(getAdsbStatus()->vehiclesMessagesTotal > 0 || getAdsbStatus()->heartbeatMessagesTotal > 0){
tfp_sprintf(buff + 1, "%2d", getActiveVehiclesCount());
tfp_sprintf(buff + 1, "%1d", getActiveVehiclesCount());
}else{
buff[1] = '-';
}
Expand Down

0 comments on commit a4ded42

Please sign in to comment.