Skip to content

Commit

Permalink
added g-force to the status screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus10110 committed Apr 8, 2024
1 parent 08e6e5e commit 34966c8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions firmware/include/screens.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ namespace Screens
double mSpeedMph{ 0 };
double mHeadingDegrees{ 0 };
double mBatteryVolts{ 0 };
double mForwardG{ 0 };
double mLateralG{ 0 };
double mVerticalG{ 0 };

void Draw( Display::Display* display ) override;
};
Expand Down
7 changes: 7 additions & 0 deletions firmware/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ void loop()
status.mSpeedMph = Gps::GetGps()->speed.mph();
status.mHeadingDegrees = Gps::GetGps()->course.deg();
}
auto motion = Motion::GetState();
if( motion.mValid )
{
status.mForwardG = motion.mForward;
status.mLateralG = motion.mLeft;
status.mVerticalG = motion.mUp;
}
status.Draw( &gDisplay );
gTft->DrawCanvas( &gDisplay );
}
Expand Down
1 change: 1 addition & 0 deletions firmware/src/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace Motion
state.mForward = z;
state.mLeft = x;
state.mUp = y;
state.mValid = true;


// the clock is slightly tilted, so we'll need to adjust the forward vector.
Expand Down
10 changes: 8 additions & 2 deletions firmware/src/screens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,17 @@ namespace Screens

namespace
{
void DrawPair( Display::Display* display, const char* title, const char* value, int x, int y )
void DrawPair( Display::Display* display, const char* title, const char* value, int x, int y, bool tiny_value = false )
{
const int line_height = 20;

display->setFont( &JetBrainsMono_Thin7pt7b );
display->setCursor( x, y );
display->write( title );
display->setFont( &JetBrainsMono_Thin10pt7b );
if( !tiny_value )
{
display->setFont( &JetBrainsMono_Thin10pt7b );
}
display->setCursor( x, y + line_height );
display->write( value );
}
Expand Down Expand Up @@ -197,6 +200,9 @@ namespace Screens

sprintf( buffer, "%2.1f V", mBatteryVolts );
DrawPair( display, "Battery", buffer, x1, y1 + y_pitch * 2 );

sprintf( buffer, "% 1.1f/% 1.1f/% 1.1f", mForwardG, mLateralG, mVerticalG );
DrawPair( display, "G-Force", buffer, x2, y1 + y_pitch * 2, true );
}

void OtaInProgress::Draw( Display::Display* display )
Expand Down

0 comments on commit 34966c8

Please sign in to comment.