Cruisers Forum
 


Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 06-12-2013, 10:24   #1
Registered User

Join Date: Dec 2013
Boat: 36' Sail
Posts: 11
Dashboard programming

As my first post, I'd like to thank all of the developers and testers for a wonderful program. I was introduced last year and used it all summer on my boat with not a single problem!

I am trying to program a small "engine management" dashboard plugin. This is my first go with wxwidgets so the learning process has been a little slow.

I have recycled some of demo_pi_sample (which I see has been unsupported for a while) and some "DashboardInstrument_Speedometer" objects from the dashboard plugin.

I have a 4 wide by 2 high wxGridSizer where I am inserting the speedometer objects and using them for things like RPM, oil press, temp, etc.

I have the dials working and data changing, but I am having problems with the sizer. When I resize the plugin window, the dials resize, but not in proportion to the wxgridsizer. It takes a bunch of resizing the window to get back to an appropriately sized dial.

Some snippets from my code

itemGridSizer = new wxGridSizer( 2, 4, 0, 0 );

rpm = new DashboardInstrument_Speedometer( this, wxID_ANY, ............

itemGridSizer->Add( rpm, 0, wxEXPAND, 0 ); - and so on for the other 7 guages

this->SetSizer(itemGridSizer);

Centre();

Layout();


I have tried modelling my OnSize event similar to Dashboard's but that doesn't seem to work yet, although I think that is where the answer will be...

Any suggestions?

Thanks
tidefalling is offline   Reply With Quote
Old 07-12-2013, 15:34   #2
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,211
Re: Dashboard programming

tidefalling...
Could you put the whole plugin code somewhere? Preferably on github. It will be a whole lot easier to figure out where your problem is than from those few out-of-context lines.

Pavel
nohal is offline   Reply With Quote
Old 08-12-2013, 13:46   #3
Registered User

Join Date: Dec 2013
Boat: 36' Sail
Posts: 11
Re: Dashboard programming

Thank you Pavel.

I hope I have done it right - code is on github under tidefalling/engine_pi

the data functionality is just dummy right now to make sure I could make dials move.
If you run the included pac cup.txt you will see a couple of the dials moving (with fake data)

I also have to track down the seg fault on exiting - but I'll figure that one out...

My only not understood issue right now is the resizing of the dials with the window resizing.

Thanks for your time, I have been hesitant to post because I didn't want to waste anyone's time...


Owen
tidefalling is offline   Reply With Quote
Old 08-12-2013, 15:19   #4
Registered User
 
NahanniV's Avatar

Join Date: Mar 2011
Location: Nova Scotia Canada
Boat: Wharram Tiki 46
Posts: 1,321
Re: Dashboard programming

Quote:
Originally Posted by tidefalling View Post
the data functionality is just dummy right now to make sure I could make dials move.
If you run the included pac cup.txt you will see a couple of the dials moving (with fake data)
Just curious, how will you get real data ?

Cheers,
JM.
NahanniV is offline   Reply With Quote
Old 08-12-2013, 16:33   #5
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,211
Re: Dashboard programming

Owen...
I certainly could live with the old behaviour, but would you find this better?
Code:
diff --git a/dial.cpp b/dial.cpp
index 6a88781..509deb0 100644
--- a/dial.cpp
+++ b/dial.cpp
@@ -118,9 +118,8 @@ void DashboardInstrument_Dial::Draw(wxGCDC* bdc)
     int width, height;
     bdc->GetTextExtent( _T("000"), &width, &height, 0, 0, g_pFontLabel );
     m_cy = m_TitleHeight + 2;
-    m_cy += availableHeight / 2;
-    m_radius = availableHeight / 2;
-
+    m_radius = wxMin(availableHeight, size.x) / 2;
+    m_cy += m_radius;
 
     DrawLabels(bdc);
     DrawFrame(bdc);
@@ -375,7 +374,7 @@ void DashboardInstrument_Dial::DrawData(wxGCDC* dc, double value,
             case DIAL_POSITION_INSIDE:
             {
                   TextPoint.x = m_cx - (width / 2) - 1;
-                  TextPoint.y = (size.y * .75) - height;
+                  TextPoint.y = m_cy + (m_radius / 7.8) + height;
                   GetGlobalColor(_T("DASHL"), &cl);
                   int penwidth = size.x / 100;
                   wxPen* pen = wxThePenList->FindOrCreatePen( cl, penwidth, wxSOLID );
Pavel
nohal is offline   Reply With Quote
Old 09-12-2013, 20:57   #6
Registered User

Join Date: Dec 2013
Boat: 36' Sail
Posts: 11
Re: Dashboard programming

Pavel that is perfect! I was stuck thinking that the issue was with the sizer or the onsize event, not with the object itself. Thank you again.


JM, I am sending data via sensors and an arduino. I have been able to build a rudder angle sensor and have OpenCPN understand it. Right now I am using a thermister to read alternator temp. Just figuring out the OpenCPN side.

Owen
tidefalling is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Advertise Here


All times are GMT -7. The time now is 20:10.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.