>

CarPC Front-End

Document
DriveLine (Click here to download)
Document
DriveLine - SourceCode (Click here to download)
This program is a "front-end" for a Car-PC. The idea is that this program loads when the OS starts, and provides the user with an interface to access music, video, GPS, and vehicle diagnostics. Of course, all of that could be done through an OS, using a keyboard and a mouse. But, when driving a vehicle, using a keyboard and mouse is just not an option.  So this program is designed with the assumption that user input will come from a touch-screen.  The goal is a clean interface with few distractions, but access to all the information and functionality the driver needs. 

Building the hardware and software for this project has been something I've wanted to do for a very long time. And, since I've realized that I am not the only person to attempt such a project, I've designed the program to be pretty customizable, in terms of images, colors, and fonts. And since a lot of the people who do this kind of thing are the do-it-yourself type, I've decided to provide the source code to the program, for anyone that really wants to tinker with it, or use it as a starting point. 



History:

01-17-2010:
Some new icons.
The personalization image now defaults to Main_Personalization.GIF first, and then Main_Personalization.BMP if no .GIF is present.  This is for animated GIF support.
Added Fuel System Status to page 2 of OBD info.

01-16-2010:
Added a third page of OBD info.  This page lists O2 sensor information (voltage and trim) for each cylinder (if available).

01-15-2010:
Scanning for updates is now handled by a separate thread.
The 'reset' button for clearing engine codes is now only visible if there are actually trouble-codes stored.
Double-clicking the 'reset' button for clearing engine codes will now prompt the user to confirm before clearing codes.
The form now stays OnTop.  I left this off for a long time for debugging.
Re-wrote much of the code for finding the main HWND of a process, again. 
Removed a timer.

01-07-2010:
Added 'media inserted' detection, which for now only triggers the program to scan for updates.
Cleaned up some interface code.  Still ugly code though.  Trying to standardize font auto-sizing.
There's got to be another way.  Need a better plan.
Experimenting with threading.  The internet-refresh code is now handled by a separate thread.  So far, so good.
Fixed a minor issue with treeview nodes colapsing and not updating.

01-06-2010
Changed the Folder Import code to copy the file bytes manually, in order to free more processing and bandwidth during the copying.
Otherwise, copying from a thumbdrive to a thumbdrive which contains the currently playing media was causing the media to skip/lag.
Still need to test this to see if it actually helps.  Also, considering moving this code into a different thread. 

01-05-2010:
Modified the GPS and OBD interfaces to both be 2-page interfaces with prev/next buttons and a 'reset' button.
By having fewer values on the OBD screen, the refresh-rate is increased.

01-02-2010:
Changed cursor-hiding code to move the cursor to the bottom-left instead of bottom-right.
Changed code for calculating font dimensions from old VB6 code to managed .Net code.
Changed some file-access code to managed .Net code
Added .Net code for ejecting an optical drive.
Added .Net code for downloading a file from the internet.
Changed some functions to .Net code, but many will remain low-level for the sake of speed and control.

06-18-2009:
Cleaned up SongArt code, MP3 file access in modMP3.
Cleaned up function names and variable names in modDriveLine.

06-17-2009:
Added support for displaying Song-Art/Album-Art from ID3v2 tags.  The image is displayed in the Visualization window. 
If the MP3 contains multiple images, only the first is displayed (for now).
Due to some inconsistencies in the way software stores the APIC frame in the .MP3 file, I had to tweak the way this frame is handled.
In other words, there could be more to this later on, as I get to test more .MP3 files.

06-13-2009:
Split DriveLine into 2 programs.  They are 'DriveLine.Net' and 'DriveLine 3.0'.  The difference is DriveLine.Net is 1 program.  DriveLine 3.0 is plug-in based.
All of the independent modules are shared between the two programs.
The source code for both will be included for a while.

06-09-2009:
Completely changed the GetTickCount code.  This should prevent issues with some counters failing after 25 days without a reboot.
Cleaned up modules, removed dependencies.
The form is getting a little messy, with my attempts to implement a plugin interface..
Possibly reduced the CPU usage when viewing the OBD interface.

05-18-2009:
Fixed an issue with embedded apps, where the app icon would not be scaled if an external image was specified but did not exist.
Fixed an issue with persistant embedded apps, where the front-end would think the embedded app had been unembedded.
Modified the function for finding the main window handle of a process.
Plug-Ins are coming...

04-19-2009:
Moved code to VB.Net 2008.
Fixed GPS Speed display (oops).
Possibly fixed an issue displaying time (thanks to TheCustomizer).

04-18-2009:
Added module modMP3 to the project.
Removed OBD info fields Throttle Position and Check Engine.  Check Engine will be replaced with a more thorough diagnostic interface.  Throttle Pos was kind of useless.
Added MAF Flow to OBD fields.  It was already being monitored for MPG, so it might as well be displayed.  For now anyway.
Fixed speed display for GPS.

04-15-2009:
Split modCarPC_Generic into separate modules for Arrays, COMM, Cursor, Display, Files, Fonts, GPS, Icons, INet, INI, Keyboard, Math, MCI, Mixer, OBD, Playlists, Processes, Registry, Strings, VideoCap, and WinAPI.
This is in preparation for a more plugin-based interface.

04-13-2009:
Changed Display_RestoreGammaRamp function to use 50% brightness to build gamma ramp, instead of using stored array.  This is kind of a test.
Considering a plug-in based interface, and splitting this program into roughly 8 separate components.
Cleaned up OBD initialization.  Function fails much sooner now if no OBD device available.

04-06-2009:
Fixed an issue with the Config window, where the Dimmer status was not being updated (would display ON when OFF, or OFF when on).

03-24-2009:
Fixed a small bug, where GPS window would show OBD speed if available.
Updated the 'GettingStarted' documents and images.

03-22-2009:
Cleaned up dimmer code.

03-20-2009:
If OBD speed is being used, the Speed/Bearing will be underlined.

03-19-2009:
The program will now prefer OBD-Speed (if available) over GPS-Speed if OBD data is less than 1 second old.
Modified display text from "No GPS" to "No Speed" when neither GPS or OBD is present.

03-17-2009:
Added support for embedding Apps which require the OBD port.  Similar to the GPS.
Added OBD support.  Still testing.

03-16-2009:
Fixed an issue with the dimmer not resetting when coming out of hibernate.
Working on OBD.

03-07-2009:
Fixed an issue with the conversion from GMT to local time, where the wrong time would be displayed if the input time seconds was between 59.5 and 59.9999.  Obviously, a rounding error.

03-06-2009:
Added seconds to the time display on the GPSinfo frame.  It's normal for seconds to be skipped, which is probably why I chose to not display the seconds in the first place.
Added support for version 3.0 of the NMEA sentence spec, and sentence $GPGLL.
Removed all MSCOMM code.  Replaced with Win32 FileAPI code to access COMM Port.  So the MSCOMM COM Object is no longer required.
Basically, there are 3 ways to access the COMM ports:
 1.  Use the old MSCOMM object (a COM object).  This is event-driven.  I think I had issues getting this to work under Vista64.
 2.  Use the Win32API and File functions.  Setting this up to be event-driven is difficult, so it will be polling-based instead.
 3.  Use the new System.IO.Ports.SerialPort class in Visual Studio 2005 and later.  This is event-driven.
Method # 3 is what I want to use, but the program will crash if a USB-Serial (most GPS and OBD) device is disconnected while running.
So, method # 2 is what is now in place.  The code for method # 3 is in place, but not used.
 
03-01-2009:
Upgraded all code to VB.Net 2005.  Option Explicit, Option Strict.
Modified auto-updater to copy all files from source folder (EXE and DLLs).

02-26-2009:
Removed the option for Horizontal Browser Split.  Vertical is the way to go. 
Moved the RefreshInternet call into a separate timer.
Corrected and clarified some code around the main timer and the interval.
Added scrolling acceleration to the ListView (the bottom box of the Browser window).
Reordered steps for setting current frame.  Frames are now initialized before they are visible.

02-25-2009:
Alerts now expire after 60 minutes.

02-24-2009:
Fixed an error in the conversion from GMT date/time to local date/time.
Fixed an error in the conversion of Longitude from DegsMinsSecs to Degs
Added TimeStamps to Traffic Alerts. 
Alerts spanning multiple days now list the date-range.
Alerts that expire today will list no date, only time-range.
Added scrolling acceleration.  The scroll-speed of the treeview doubles after 5 lines of scrolling.

02-23-2009:
Decreased precision of Bearing.  No more NNW, WNW, etc.  Now just N, NW, W, SW, S, SE, E, NE. 
Modified the internet detection code.  Now it queries a URL to confirm online status.
Internet detection is refreshed every 30 seconds now (instead of every second).
Tweaked the weather/traffic updates. 

02-20-2009:
Added Weather and Traffic alerts under the Media Browser.

02-16-2009:
Fixed an issue with the SlideShow Browser, where clicking a folder in the Listview would cause an error if the folder contained no images.
Added functionality to the visualization window.  Clicking on album art will now iterate through all images in the current media directory.
Added BMP and JPG code into generic CarPC module.  Probably didn't need to at this point.

01-25-2009:
Changed the album-art code to check for images containing the word "front" and if found, use that image first.

01-12-2009:
Added 'Copy Folder' functionality under the Media Browser.  Copy the folder and contents, or just the contents, to another folder.

01-05-2009:
Modified the filename cleansing to also be able to remove repeated info from the end of filenames (album year, group names like h8me, whatever).

12-31-2008:
Fixed an issue with the ShutDown procedure, which would crash the program instead of shutting down the PC.
Tweaked the GPS Statistics code to compensate for hibernate/suspend.

12-30-2008:
Changed the method of calculating average speeds.
Changed the default unit within the program to KM.  Using Knots was a pain for calculating averages.
Fixed an issue with a date calculation function.
Considering abandoning the GetTickCount function to avoid a potential overflow error after 49 days of not rebooting.  Could be 25 days.

12-29-2008:
Changed the GPS Info window to a 2-page interface.  One with basic GPS data, and one with derived GPS statistics.
GPS Stats Include:  Avg Moving Speed, Avg Overall Speed, Time Moving, Time Stopped, Peak Speed, Trip Meter, and Launch.

12-18-2008:
Modified the function that cleans up the filenames.  Now, the underscore character is replaced with the space character.
Also, the period character (except for the last one in the filename) is replaced with the space character.

12-09-2008:
Fixed a minor issue with the ListView for the FileList, where a click in empty space (below the last item) was treated like a click on the selected item in the list.
Adjusted the TreeView Text Truncation by a few pixels.
Still considering removing the TreeView, and potentially trying to use a ListView in it's place.

12-01-2008:
Fixed a type-o which would prevent the user from browsing for images for a slideshow.

11-25-2008:
Code Clean-Up.  Made a few functions faster.

11-21-2008:
Fixed an issue where the visualization would remain full-screen after playing a video file, even if the next file was an audio file.
Fixed the filename cleansing code to never remove all the characters from a file name.

11-18-2008:
If two media paths overlap (ie C:\ and C:\Media) and the current media is located in both (ie C:\Media\MySong.MP3), the browser will now choose the longest media path that contains the media file as the root of the current media.
This now works for playlists and images as well.
Treeview Text Truncation now applies to playlists and root entries as well as subfolders.
Fixed an error that would prevent media from being displayed in a root folder.

11-17-2008:
Fixed minor issues with TreeView text truncation.  This now seems to work perfectly.
Fixed major issue where 2 media paths with the same root could not be specified.  Paths now stored in TreeView Node.Tag instead of Node.Key.
ListView still uses ListItem.Key for storing full path + filename.

11-14-2008:
Modified the TreeView to check text width and ensure no item causes a Horizontal ScrollBar to appear.
At present, this check is only performed for media files.  Not for special entries, such as playlists.

11-13-2008:
Fixed the code for the TreeView BackColor.  Had to remove the tree-lines and the +button next to expandable nodes.
Added functionality to remove repeated text from media file names (if text is in all visible filenames in directory). 
First it removes repeated text from the left.  Then it breaks the filename into subfields, assuming a delimiter of "-" (hyphen), and checks for repeated values to remove. 
Then it does it all again, assuming a delimiter of " " (space char).

11-10-2008:
Modified the Browser code so that the TreeView and ListView controls can now have their colors specified.
The bright white treeview and listview were an eye-sore at night in the dark.

11-07-2008:
Font sizes are now measured to one-tenth of a point, resulting in more accurate auto-sizing.
All playlist files are now denoted with <LST: instead of separate identifiers for <M3U: and <PLS:.
Cleaned up the code that links the treeview and listview in the Browser window.
DVD Label is now displayed in the NavBar.

11-06-2008:
Changed Browser window to use a ListView control instead of a ListBox.
Modified Browser window so PlayList files will appear in the Treeview, and can be browsed just like a folder.
Had to tweak the format of the .PlayList file, changed the delimiter to a pipe | character.

11-04-2008:
Changed GPSinfo window to use a ListView control with 2 columns instead of a ListBox.  The CommonControls library was already required for the TreeView in the Browser window.
Changed GPSinfo window to display date and time on separate lines.
Perfected BAT code for updater.

11-03-2008:
TimeZone offset is now updated upon resuming from hibernate/suspend.  Also, GPS last-sync-date is cleared upon resuming, to force a refresh.
Modified the BAT code for the updater to specifically wait for the DriveLine ProcessID to terminate before trying to install the new version.

10-27-2008:
Fixed an issue where the PC would resume from hibernation, but forget that the screen should be dimmed.  The dimmer is now refreshed at time of resume.  This appears to be a Windows issue.
Finally made GPS reconnect after closing an embedded app that required the GPS and had to be force-terminated.
Basically, after closing an embedded app, the program will attempt to reconnect to the GPS every 5 seconds for 30 seconds.
Added UpdateScanner.  This will search all drive letters (1 subfolder deep) for a new version when the program is executed, (or upon resuming from hibernation) and offer to install the new EXE.
The purpose of the UpdateScanner is to be able to upgrade the program without a keyboard or mouse attached.

10-24-2008:
Added clock-sync.  Once per day or per reboot, the clock will sync with the GPS date/time.
Clicking the GPSinfo list will now reset the last-synced date, forcing the program to re-sync date/time.
Fixed minor issue with embedding programs, which would cause the current track to restart.

10-23-2008:
Added support for playlist formats .M3U and .PLS.  These are managed internally, and should NOT be specified in the INI file.

10-22-2008:
Cleaned up the GettingStarted document.  Coded HTML manually.  Now using PNG images instead of JPG images.  Smaller files, better quality.
Changes to GPSinfo window. 
-Combined Latitude and Longitude onto one line. 
-If the GPS device is present but there is no Satelite-Fix, the GPS info will show blank values instead of default values, and OS time instead of GPS time.

10-21-2008:
Modified the ONRESUME function to better handle resuming from hibernation.  Media resumes as it should.  GPS reconnects.
Configuring the program ONRESUME settings to run DEVCON.EXE with the RESCAN parameter seems to work well for re-enabling USB devices on resume.

10-20-2008:
Set the program to always remain ONTOP of other programs.  Considering making this an option in the DriveLine.ini file.
Adjusted GPS sensitivity for tripmeter.
The program will now display GPS Date/Time as Local Date/Time, using the TimeZone setting in Windows.

10-16-2008:
The "Getting Started" document is now provided as HTML, instead of a Word Doc.  Smaller ZIP file, more compatibility.
Adjusted the function that draws icons for the apps window.  Now using the Image and ImageMask (DI_NORMAL instead of DI_IMAGE), the icons look better.
Clicking the GPSinfo list will now reset the PeakSpeed and DistanceTraveled.
Made it so more areas will hide the mouse if they are clicked (such as dead space, lists, etc).

10-15-2008:
Fixed an issue where the peak speed would occasionally not get updated.
Fixed an issue that would prevent the NavBar from hiding when playing DVD video.
Fixed an issue that would prevent the program from resuming a playlist when the item in the playlist was a DVD video.
Fixed an issue that would prevent the program from ejecting an optical disc.
The program is now set up to gracefully handle ejecting the media that is currently playing.

10-13-2008:
Added GPS-based tripmeter.  Tried 2 different methods.  By Lat/Lon, and by speed/time.  Decided to go with speed/time method since it doesn't require trig.
So far, I am very pleased with the accuracy of this.

10-01-2008:
Finally made application embedding work reliably, with a new method for finding the main hWnd of a process.

09-29-2008:
Clicking on the left half of the slideshow window will load the previous image.
Clicking on the right half of the slideshow window will load the next image.
Made it so more areas will hide the mouse if they are clicked (such as dead space, lists, etc).

09-26-2008:
The slideshow image-list is now saved (and loaded on startup), just like the media playlist.
DriveLine.PlayList
DriveLine.SlideList

09-25-2008:
Fixed an error in the image scaling routine, which would incorrectly re-calculate the aspect ratio of the image.
Fixed an error that would crash the program if the Visualization window was loaded while no media was playing.

09-24-2008:
Fixed an error that would display the wrong track number if the file chosen in the browser was not the first file in the folder.
Fixed the way folders are handled in the treeview when they have no subfolders.
Added new functionality - SlideShow.  Modified interface to accomodate.
New icons!

09-08-2008:
When the browser window is loaded, the current track will be hilighted.

09-05-2008:
Made the Up/Down arrows hide the mouse when clicked, just like the Prev/Next arrows.
Added detection of suspend and resume.  Upon resume, the program will execute a specified program.  I don't know if this has a purpose or not -- I'm thinking devcon.

09-04-2008:
Changed the way the program detects if an embedded program is idle. 
When a program is launched, it won't be embedded until CPU usage for that process drops below 4%.

09-03-2008:
Changed the way the scrolling works on the Browser window.  Now using SCROLL commands instead of ARROW commands, like I should have from the beginning.
Changed the way the treeview handles clicks on the Browser window.  More consistent now.
Changed the layout of the NavBar to be 3 lines of text instead of 2, and locked the positions of text on the top line.

08-11-2008:
Changed the format of the colors in the Skin.INI file to RGB format.
Tweaked the embedding functions.  Still not perfect.
Changed the way album art is located.  Now, the largest image in the folder (by filesize) is the one used.

08-08-2008:
Embedded Programs nearly complete. 
Now supports:
-Disable Playback while program is embedded (for running tuner programs, media players).
-Disable GPS while program is embedded (for running mapping software).
-Maximize program.  This should almost always be set to TRUE.
-CommandLine to include when running the program.
-Commands to run after loading the program.  An example for Streets & Trips:  <SLEEP02><ALTDOWN>TGS<ALTUP><CTRLDOWN>A<CTRLUP><ALTDOWN>VNL<ALTUP><ALTDOWN>TGM<ALTUP>
One problem at the moment.  A program cannot be embedded if an instance of the program is already running.

08-06-2008:
When a program is unembedded, a CLOSEWINDOW command is sent.  If the window still exists after 5 seconds, the process is terminated.
This works out well for programs that may prompt the user to save, or confirm something, such as Streets & Trips.

08-05-2008:
Removed the Streets & Trips code.  Replaced with a generic "Embedded Programs" interface.  Up to 18 programs can be embedded.
By default, the program icon is used, but a different image may be specified in the program INI file.
Still working on all of this.

08-02-2008:
Added album-art display in the Visualization window.  Currently it checks for JPG and BMP images in the music folder.
Tweaked the StatusText format.  Removed Lat/Lon.  Speed and bearing are now always displayed (if GPS is available).

07-30-2008:
Fixed a bug that would cause an incorrect track number to be displayed when navigating past the end of a playlist.
Enabled Hold-and-Scroll on the PREV and NEXT buttons, similar to the UP and DOWN arrows.
Added an option to view the Browser window with a Vertical split, or with a Horizontal split.
Changed the way the Browser window loads the current media path -- Now all folders get populated.

07-18-2008:
Fixed a type-o, cleaned up the GettingStarted file.  Made all of the source code available.

07-17-2008:
Clicking the PREV button when you are more than 5 seconds into a song will now restart the same song (like how most disc players work).

07-16-2008:
Unit of Speed is now an option.  Choose MPH, KM/H, or Knots.
Configuration window implemented.
The program now keeps track of your peak speed.

07-10-2008:
Added "Launch" stats to GPS info.  In other words, it displays your acceleration info (0 to 60 in 5.9 seconds, for example)

06-30-2008:
Separated code into two modules - one generic for CarPC programming, and one specific to this particular program.

06-23-2008:
Added network detection.  The status text now indicates if the CarPC is online or not.

06-21-2008:
Made skin folder configurable.  Separated program settings and skin settings.
Fixed a bug which prevented the playlist from repeating.


06-20-2008:
Scrapped the original program.  Wrote a new interface.  Much cleaner, better code (might even make source code available).
New images, new layout.
Visualization no longer loads automatically.
No more support for NumPad input.  Sorry.  Could add it again later.  Or programmable key commands.
Numerous things fixed or added.