Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-12-2013, 11:24   #1
Registered User

Join Date: Dec 2013
Boat: 36' Sail
Posts: 7
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, 16:34   #2
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,018
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 online now   Reply With Quote
Old 08-12-2013, 14:46   #3
Registered User

Join Date: Dec 2013
Boat: 36' Sail
Posts: 7
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, 16:19   #4
Registered User
 
NahanniV's Avatar

Join Date: Mar 2011
Location: On the Boat
Boat: Finnsailer 38
Posts: 1,143
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, 17:33   #5
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,018
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 online now   Reply With Quote
Old 09-12-2013, 21:57   #6
Registered User

Join Date: Dec 2013
Boat: 36' Sail
Posts: 7
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

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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




Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -7. The time now is 09:41.


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

ShowCase vBulletin Plugins by Drive Thru Online, Inc.