Skip to content

Commit

Permalink
Added a "speedometer" widget to the GUI program.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory W Heckler committed Jun 3, 2009
1 parent f4dcf08 commit 6153c01
Show file tree
Hide file tree
Showing 11 changed files with 980 additions and 23 deletions.
Binary file modified gps-gse
Binary file not shown.
Binary file added gse/gps-gse
Binary file not shown.
642 changes: 642 additions & 0 deletions gse/gui.fbp

Large diffs are not rendered by default.

99 changes: 98 additions & 1 deletion gse/gui_classes.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 21 2008)
// C++ code generated with wxFormBuilder (version Dec 29 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
Expand Down Expand Up @@ -96,6 +96,9 @@ iGUI_Toplevel::iGUI_Toplevel( wxWindow* parent, wxWindowID id, const wxString& t
bMessages = new wxToggleButton( this, ID_MESSAGES_B, wxT("Messages"), wxDefaultPosition, wxDefaultSize, 0 );
SubWindows->Add( bMessages, 0, wxALL|wxEXPAND, 5 );

bSpeedo = new wxToggleButton( this, ID_SPEEDO_B, wxT("Speedometer"), wxDefaultPosition, wxDefaultSize, 0 );
SubWindows->Add( bSpeedo, 0, wxALL|wxEXPAND, 5 );

sMain->Add( SubWindows, 1, wxALL|wxEXPAND, 5 );

wxBoxSizer* sStatus;
Expand Down Expand Up @@ -2138,3 +2141,97 @@ iGUI_Select::~iGUI_Select()
// Disconnect Events
pVisible->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( iGUI_Select::onMouse ), NULL, this );
}

iGUI_Speedo::iGUI_Speedo( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );

wxBoxSizer* bSizer107;
bSizer107 = new wxBoxSizer( wxVERTICAL );

wxBoxSizer* bSizer116;
bSizer116 = new wxBoxSizer( wxHORIZONTAL );

wxStaticBoxSizer* sbSizer18;
sbSizer18 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Speed") ), wxHORIZONTAL );

pspeed = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sbSizer18->Add( pspeed, 1, wxEXPAND, 5 );

bSizer116->Add( sbSizer18, 1, wxALL|wxEXPAND, 5 );

wxStaticBoxSizer* sbSizer43;
sbSizer43 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("???") ), wxVERTICAL );

pdist = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sbSizer43->Add( pdist, 1, wxEXPAND, 5 );

bSizer116->Add( sbSizer43, 1, wxALL|wxEXPAND, 5 );

bSizer107->Add( bSizer116, 1, wxEXPAND, 5 );

wxBoxSizer* bSizer109;
bSizer109 = new wxBoxSizer( wxHORIZONTAL );

wxGridSizer* gSizer5;
gSizer5 = new wxGridSizer( 2, 3, 0, 0 );

wxStaticBoxSizer* sbSizer235;
sbSizer235 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Overall Avg") ), wxVERTICAL );

pstop1 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sbSizer235->Add( pstop1, 1, wxEXPAND, 5 );

gSizer5->Add( sbSizer235, 1, wxALL|wxEXPAND, 5 );

wxStaticBoxSizer* sbSizer23;
sbSizer23 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Moving Avg") ), wxVERTICAL );

pmavg = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sbSizer23->Add( pmavg, 1, wxEXPAND, 5 );

gSizer5->Add( sbSizer23, 1, wxALL|wxEXPAND, 5 );

wxStaticBoxSizer* sbSizer231;
sbSizer231 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Max Speed") ), wxVERTICAL );

pmax = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sbSizer231->Add( pmax, 1, wxEXPAND, 5 );

gSizer5->Add( sbSizer231, 1, wxALL|wxEXPAND, 5 );

wxStaticBoxSizer* sbSizer232;
sbSizer232 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Total Time") ), wxVERTICAL );

pttime = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sbSizer232->Add( pttime, 1, wxEXPAND, 5 );

gSizer5->Add( sbSizer232, 1, wxALL|wxEXPAND, 5 );

wxStaticBoxSizer* sbSizer233;
sbSizer233 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Moving Time") ), wxVERTICAL );

pmtime = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sbSizer233->Add( pmtime, 1, wxEXPAND, 5 );

gSizer5->Add( sbSizer233, 1, wxALL|wxEXPAND, 5 );

wxStaticBoxSizer* sbSizer234;
sbSizer234 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Stopped Time") ), wxVERTICAL );

pstop = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sbSizer234->Add( pstop, 1, wxEXPAND, 5 );

gSizer5->Add( sbSizer234, 1, wxALL|wxEXPAND, 5 );

bSizer109->Add( gSizer5, 1, wxEXPAND, 5 );

bSizer107->Add( bSizer109, 1, wxEXPAND, 5 );

this->SetSizer( bSizer107 );
this->Layout();
}

iGUI_Speedo::~iGUI_Speedo()
{
}
63 changes: 44 additions & 19 deletions gse/gui_classes.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 21 2008)
// C++ code generated with wxFormBuilder (version Dec 29 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
Expand Down Expand Up @@ -51,24 +51,25 @@
#define ID_HEALTH_B 1015
#define ID_COMMANDS_B 1016
#define ID_MESSAGES_B 1017
#define ID_EPHEMERIS_REFRESH 1018
#define ID_EPHEMERIS_SAVE 1019
#define ID_EPHEMERIS_LOAD 1020
#define ID_ALMANAC_REFRESH 1021
#define ID_ALMANAC_SAVE 1022
#define ID_ALMANAC_LOAD 1023
#define ID_NULL 1024
#define ID_RESET_WATCHDOG 1025
#define ID_RESET_ALL 1026
#define ID_RESET_PPS 1027
#define ID_RESET_PVT 1028
#define ID_RESET_EKF 1029
#define ID_RESET_CHANNEL 1030
#define ID_RESET_EPHEMERIS 1031
#define ID_RESET_ALMANAC 1032
#define ID_EEPROM_STOP 1033
#define ID_EEPROM_START 1034
#define ID_SELECT_REFRESH 1035
#define ID_SPEEDO_B 1018
#define ID_EPHEMERIS_REFRESH 1019
#define ID_EPHEMERIS_SAVE 1020
#define ID_EPHEMERIS_LOAD 1021
#define ID_ALMANAC_REFRESH 1022
#define ID_ALMANAC_SAVE 1023
#define ID_ALMANAC_LOAD 1024
#define ID_NULL 1025
#define ID_RESET_WATCHDOG 1026
#define ID_RESET_ALL 1027
#define ID_RESET_PPS 1028
#define ID_RESET_PVT 1029
#define ID_RESET_EKF 1030
#define ID_RESET_CHANNEL 1031
#define ID_RESET_EPHEMERIS 1032
#define ID_RESET_ALMANAC 1033
#define ID_EEPROM_STOP 1034
#define ID_EEPROM_START 1035
#define ID_SELECT_REFRESH 1036

///////////////////////////////////////////////////////////////////////////////
/// Class iGUI_Toplevel
Expand All @@ -92,6 +93,7 @@ class iGUI_Toplevel : public wxFrame
wxToggleButton* bHealth;
wxToggleButton* bCommands;
wxToggleButton* bMessages;
wxToggleButton* bSpeedo;
wxTextCtrl* tRS422;
wxTextCtrl* tTask;
wxStatusBar* mStatus;
Expand Down Expand Up @@ -551,4 +553,27 @@ class iGUI_Select : public wxFrame

};

///////////////////////////////////////////////////////////////////////////////
/// Class iGUI_Speedo
///////////////////////////////////////////////////////////////////////////////
class iGUI_Speedo : public wxFrame
{
private:

protected:
wxPanel* pspeed;
wxPanel* pdist;
wxPanel* pstop1;
wxPanel* pmavg;
wxPanel* pmax;
wxPanel* pttime;
wxPanel* pmtime;
wxPanel* pstop;

public:
iGUI_Speedo( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Speedometer"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 600,500 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
~iGUI_Speedo();

};

#endif //__gui_classes__
1 change: 1 addition & 0 deletions gse/include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1
#include "gui_health.h"
#include "gui_messages.h"
#include "gui_select.h"
#include "gui_speedo.h"
#include "gui_toplevel.h"
/*----------------------------------------------------------------------------------------------*/
double icn0_2_fcn0(uint32 _cn0);
Expand Down
30 changes: 30 additions & 0 deletions gse/include/gui_speedo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef GUI_SPEEDO_H_
#define GUI_SPEEDO_H_

#include "gui.h"

/*----------------------------------------------------------------------------------------------*/
class GUI_Speedo : public iGUI_Speedo, public GUI_Object
{

private:

int32 tick;
double speed;

public:

GUI_Speedo();
~GUI_Speedo();

void onClose(wxCloseEvent& event);
void render(wxDC& dc);
void paintNow();
void renderSpeedo();

DECLARE_EVENT_TABLE()

};
/*----------------------------------------------------------------------------------------------*/

#endif
2 changes: 2 additions & 0 deletions gse/include/gui_toplevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class GUI_Toplevel: public iGUI_Toplevel
GUI_Commands *wCommands;
//GUI_EEPROM *wEEPROM;
GUI_Messages *wMessages;
GUI_Speedo *wSpeedo;
class GUI_Serial*pSerial;

wxTimer *timer;
Expand Down Expand Up @@ -67,6 +68,7 @@ class GUI_Toplevel: public iGUI_Toplevel
void onCommands(wxCommandEvent& event);
void onEEPROM(wxCommandEvent& event);
void onMessages(wxCommandEvent& event);
void onSpeedo(wxCommandEvent& event);

void paintEvent(wxPaintEvent& evt);
void paintNow();
Expand Down
1 change: 0 additions & 1 deletion gse/src/gui_almanac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ GUI_Almanac::GUI_Almanac():iGUI_Almanac(NULL, wxID_ANY, wxT("Almanac"), wxDefaul
fp = NULL;
}


GUI_Almanac::~GUI_Almanac()
{

Expand Down
127 changes: 127 additions & 0 deletions gse/src/gui_speedo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* gui_speedo.cpp
*
* Created on: Nov 4, 2008
* Author: gheckler
*/

#include "gui.h"

extern wxColor red;
extern wxColor green;
extern wxColor blue;
extern wxColor yellow;
extern wxColor white;
extern wxColor black;
extern wxColor grey;
extern wxColor htext;

DECLARE_APP(GUI_App)

/*----------------------------------------------------------------------------------------------*/
BEGIN_EVENT_TABLE(GUI_Speedo, wxFrame)
EVT_CLOSE(GUI_Speedo::onClose)
END_EVENT_TABLE()
/*----------------------------------------------------------------------------------------------*/

GUI_Speedo::GUI_Speedo():iGUI_Speedo(NULL, wxID_ANY, wxT("Speedo"), wxDefaultPosition, wxSize(600,400), wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
{

speed = 0;

}


GUI_Speedo::~GUI_Speedo()
{


}

void GUI_Speedo::onClose(wxCloseEvent& evt)
{
wxCommandEvent cevt;
evt.Veto();
pToplevel->onSpeedo(cevt);
}

void GUI_Speedo::paintNow()
{
wxClientDC dc(this);
render(dc);
}

void GUI_Speedo::render(wxDC& dc)
{

renderSpeedo();
//renderStat();

}


void GUI_Speedo::renderSpeedo()
{

int32 lcv;
wxPoint box[4];
wxCoord w, h, rmin, rmax, dx, dy;
wxCoord dx1, dx2, dy1, dy2;
wxString str;
SPS_M *pNav = &p->sps;
double speed;

speed += (2.23693629*sqrt(pNav->vz*pNav->vz + pNav->vy*pNav->vy + pNav->vx*pNav->vx) - speed)*.25;

tick++;

wxBufferedPaintDC dc(pspeed, wxBUFFER_VIRTUAL_AREA);
dc.Clear();

pspeed->GetClientSize(&w, &h);
dc.SetTextForeground(red);

rmax = w > h ? w : h;
rmin = w < h ? w : h;

box[0].x = 0; box[0].y = 0;
box[1].x = w; box[1].y = 0;
box[2].x = w; box[2].y = h;
box[3].x = 0; box[3].y = h;

dc.SetBrush(wxBrush(black));
dc.SetPen(wxPen(black, 1));
dc.DrawPolygon(4, box, 0, 0);

dc.SetBrush(wxBrush(black));
dc.SetPen(wxPen(red, 2));

dc.DrawCircle(w/2, h*3/4, rmin * 11/16);

dc.SetPen(wxPen(red, 2));

for(lcv = 0; lcv <= 20; lcv++)
{
dx1 = (rmin*10/16)*cos((lcv*10 + 170)*DEG_2_RAD);
dy1 = (rmin*10/16)*sin((lcv*10 + 170)*DEG_2_RAD);
dx2 = (rmin*11/16)*cos((lcv*10 + 170)*DEG_2_RAD);
dy2 = (rmin*11/16)*sin((lcv*10 + 170)*DEG_2_RAD);
dc.DrawLine(w/2 + dx1, h*3/4 + dy1, w/2 + dx2, h*3/4 + dy2);
}

dc.SetPen(wxPen(blue, 2));

dc.DrawCircle(w/2, h*3/4, 4);

dx = (rmin*9/16)*cos((speed + 170)*DEG_2_RAD);
dy = (rmin*9/16)*sin((speed + 170)*DEG_2_RAD);
dc.DrawLine(w/2, h*3/4, w/2 + dx, h*3/4 + dy);

dc.SetBrush(wxBrush(red));
dc.SetFont(wxFont(24, wxFONTFAMILY_TELETYPE, wxNORMAL, wxNORMAL));
str.Printf(wxT("%6.1f"),speed);
dc.DrawText(str, (w - 7*dc.GetCharWidth())/2, h*4/5);

// circle at (100, 150) with radius 60 dc.DrawCircle(100, 150, 60) ...

}
Loading

0 comments on commit 6153c01

Please sign in to comment.