Index: trunk/desktop/ICSSerialPort.rbbas
===================================================================
--- trunk/desktop/ICSSerialPort.rbbas	(revision 11)
+++ trunk/desktop/ICSSerialPort.rbbas	(revision 15)
@@ -370,4 +370,78 @@
 	#tag EndMethod
 
+	#tag Method, Flags = &h0
+		Sub loadProfile(theName as string)
+		  //Find the profile in the database, update the bytes and fire the event
+		  dim rs as RecordSet
+		  
+		  rs = fsicsdb.SQLSelect("SELECT * FROM carprofiles WHERE name= '"+theName+"'")
+		  
+		  //Make sure we got a record to work with
+		  if rs <> Nil then
+		    
+		    if rs.Field("cartype").StringValue <> "" then
+		      carType = rs.Field("cartype").StringValue
+		    end if
+		    
+		    if rs.Field("byte01").StringValue <> "" then
+		      byte01 = chrb(rs.Field("byte01").IntegerValue)
+		    end if
+		    if rs.Field("byte02").StringValue <> "" then
+		      byte02 = chrb(rs.Field("byte02").IntegerValue)
+		    end if
+		    if rs.Field("byte03").StringValue <> "" then
+		      byte03 = chrb(rs.Field("byte03").IntegerValue)
+		    end if
+		    if rs.Field("byte04").StringValue <> "" then
+		      byte04 = chrb(rs.Field("byte04").IntegerValue)
+		    end if
+		    if rs.Field("byte05").StringValue <> "" then
+		      byte05 = chrb(rs.Field("byte05").IntegerValue)
+		    end if
+		    if rs.Field("byte06").StringValue <> "" then
+		      byte06 = chrb(rs.Field("byte06").IntegerValue)
+		    end if
+		    if rs.Field("byte07").StringValue <> "" then
+		      byte07 = chrb(rs.Field("byte07").IntegerValue)
+		    end if
+		    if rs.Field("byte08").StringValue <> "" then
+		      byte08 = chrb(rs.Field("byte08").IntegerValue)
+		    end if
+		    if rs.Field("byte09").StringValue <> "" then
+		      byte09 = chrb(rs.Field("byte09").IntegerValue)
+		    end if
+		    if rs.Field("byte10").StringValue <> "" then
+		      byte10 = chrb(rs.Field("byte10").IntegerValue)
+		    end if
+		    if rs.Field("byte11").StringValue <> "" then
+		      byte11 = chrb(rs.Field("byte11").IntegerValue)
+		    end if
+		    if rs.Field("byte12").StringValue <> "" then
+		      byte12 = chrb(rs.Field("byte12").IntegerValue)
+		    end if
+		    if rs.Field("byte13").StringValue <> "" then
+		      byte13 = chrb(rs.Field("byte13").IntegerValue)
+		    end if
+		    if rs.Field("byte14").StringValue <> "" then
+		      byte14 = chrb(rs.Field("byte14").IntegerValue)
+		    end if
+		    if rs.Field("byte15").StringValue <> "" then
+		      byte15 = chrb(rs.Field("byte15").IntegerValue)
+		    end if
+		    if rs.Field("byte16").StringValue <> "" then
+		      byte16 = chrb(rs.Field("byte16").IntegerValue)
+		    end if
+		    if rs.Field("byte17").StringValue <> "" then
+		      byte17 = chrb(rs.Field("byte17").IntegerValue)
+		    end if
+		    if rs.Field("byte18").StringValue <> "" then
+		      byte18 = chrb(rs.Field("byte18").IntegerValue)
+		    end if
+		    
+		    valuesChanged()
+		  end if
+		End Sub
+	#tag EndMethod
+
 
 	#tag Hook, Flags = &h0
@@ -598,4 +672,5 @@
 			InitialValue="&hFF"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -603,4 +678,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -608,4 +684,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -613,4 +690,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -618,4 +696,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -623,4 +702,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -628,4 +708,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -633,4 +714,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -638,4 +720,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -643,4 +726,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -648,4 +732,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -653,4 +738,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -658,4 +744,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -663,4 +750,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -668,4 +756,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -673,4 +762,5 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
@@ -678,8 +768,22 @@
 			Group="Behavior"
 			Type="String"
+			EditorType="MultiLineEditor"
 		#tag EndViewProperty
 		#tag ViewProperty
 			Name="byte10"
 			Group="Behavior"
+			Type="String"
+			EditorType="MultiLineEditor"
+		#tag EndViewProperty
+		#tag ViewProperty
+			Name="carType"
+			Group="Behavior"
+			InitialValue="MR-03"
+			Type="String"
+		#tag EndViewProperty
+		#tag ViewProperty
+			Name="mode"
+			Group="Behavior"
+			InitialValue="read"
 			Type="String"
 		#tag EndViewProperty
Index: trunk/desktop/mainWindow.rbfrm
===================================================================
--- trunk/desktop/mainWindow.rbfrm	(revision 14)
+++ trunk/desktop/mainWindow.rbfrm	(revision 15)
@@ -59,5 +59,5 @@
       Cancel          =   ""
       Caption         =   "Write"
-      Default         =   True
+      Default         =   False
       Enabled         =   True
       Height          =   20
@@ -129,5 +129,5 @@
       Panels          =   ""
       Scope           =   0
-      SmallTabs       =   ""
+      SmallTabs       =   False
       TabDefinition   =   "Settings\rProfiles\rCar\rCustom"
       TabIndex        =   43
@@ -138,5 +138,5 @@
       Top             =   32
       Underline       =   ""
-      Value           =   1
+      Value           =   2
       Visible         =   True
       Width           =   637
@@ -957,5 +957,5 @@
             LockRight       =   ""
             LockTop         =   ""
-            Maximum         =   255
+            Maximum         =   10
             Minimum         =   1
             PageStep        =   20
@@ -2695,4 +2695,7 @@
 		Sub Open()
 		  StaticText_Version.Text = "Version " + str(app.NonReleaseVersion/100)
+		  
+		  //Set the default car type
+		  ICSSerialPort1.setCarType("MR-03")
 		End Sub
 	#tag EndEvent
@@ -2793,4 +2796,5 @@
 		  //Update punch
 		  Slider_Punch.Value = asc(ICSSerialPort1.Byte05)
+		  EditField_Punch.Text = str(asc(ICSSerialPort1.Byte05))
 		  
 		  //Update DBAND
@@ -2920,7 +2924,9 @@
 		  //Update Steering Gain
 		  Slider_STGain.Value = asc(ICSSerialPort1.Byte16)
+		  EditField_STGain.Text = str(asc(ICSSerialPort1.Byte16))
 		  
 		  //Update Throttle Gain
 		  Slider_THGain.Value = asc(ICSSerialPort1.Byte17)
+		  EditField_THGain.Text = str(asc(ICSSerialPort1.Byte17))
 		End Sub
 	#tag EndMethod
@@ -3046,4 +3052,12 @@
 	#tag EndEvent
 #tag EndEvents
+#tag Events TabPanel1
+	#tag Event
+		Sub Change()
+		  updateAdvancedScreen
+		  updateCarScreen
+		End Sub
+	#tag EndEvent
+#tag EndEvents
 #tag Events PopupMenu_Profile
 	#tag Event
@@ -3052,4 +3066,5 @@
 		    PushButton_SaveProfile.Visible = true
 		    PushButton_Delete.Visible = true
+		    ICSSerialPort1.loadProfile(me.Text)
 		  end if
 		End Sub
@@ -3089,5 +3104,32 @@
 		Sub ValueChanged()
 		  ICSSerialPort1.Byte17 = chrb(me.Value)
-		  EditField_THGain.Text = str(me.Value)
+		  //Check to see if we need to update the edit field
+		  //This prevents the edit field from triggering this event that then updates the edit field again
+		  //Causing the cursor to move to the begginning of the editfield
+		  if EditField_THGain.Text <> str(me.Value) then
+		    EditField_THGain.Text = str(me.Value)
+		  end if
+		  
+		  
+		End Sub
+	#tag EndEvent
+#tag EndEvents
+#tag Events EditField_THGain
+	#tag Event
+		Sub TextChange()
+		  //Make sure we have a valid value if not then set it to something
+		  if me.Text <> "" then
+		    if val(me.Text) > 255 or val(me.Text) < 1 then
+		      me.Text = "255"
+		    end if
+		  end if
+		  
+		  dim d as double
+		  dim i as integer
+		  d = val(me.Text)
+		  i = d
+		  ICSSerialPort1.Byte17 = chrb(i)
+		  
+		  Slider_THGain.Value = val(me.Text)
 		End Sub
 	#tag EndEvent
@@ -3097,5 +3139,31 @@
 		Sub ValueChanged()
 		  ICSSerialPort1.Byte16 = chrb(me.Value)
-		  EditField_STGain.Text = str(me.Value)
+		  //Check to see if we need to update the edit field
+		  //This prevents the edit field from triggering this event that then updates the edit field again 
+		  //Causing the cursor to move to the begginning of the editfield
+		  if EditField_STGain.Text <> str(me.Value) then
+		    EditField_STGain.Text = str(me.Value)
+		  end if
+		End Sub
+	#tag EndEvent
+#tag EndEvents
+#tag Events EditField_STGain
+	#tag Event
+		Sub TextChange()
+		  //Make sure we have a valid value if not then set it to something
+		  if me.Text <> "" then
+		    if val(me.Text) > 255 or val(me.Text) < 1 then
+		      me.Text = "255"
+		    end if
+		  end if
+		  
+		  dim d as double
+		  dim i as integer
+		  d = val(me.Text)
+		  i = d
+		  ICSSerialPort1.Byte16 = chrb(i)
+		  
+		  Slider_STGain.Value = val(me.Text)
+		  
 		  
 		End Sub
@@ -3220,6 +3288,32 @@
 		Sub ValueChanged()
 		  ICSSerialPort1.Byte05 = chrb(me.Value)
-		  EditField_Punch.Text = str(me.Value)
-		  
+		  //Check to see if we need to update the edit field
+		  //This prevents the edit field from triggering this event that then updates the edit field again
+		  //Causing the cursor to move to the begginning of the editfield
+		  if EditField_Punch.Text <> str(me.Value) then
+		    EditField_Punch.Text = str(me.Value)
+		  end if
+		  
+		  
+		End Sub
+	#tag EndEvent
+#tag EndEvents
+#tag Events EditField_Punch
+	#tag Event
+		Sub TextChange()
+		  //Make sure we have a valid value if not then set it to something
+		  if me.Text <> "" then
+		    if val(me.Text) > 255 or val(me.Text) < 1 then
+		      me.Text = "255"
+		    end if
+		  end if
+		  
+		  dim d as double
+		  dim i as integer
+		  d = val(me.Text)
+		  i = d
+		  ICSSerialPort1.Byte05 = chrb(i)
+		  
+		  Slider_Punch.Value = val(me.Text)
 		End Sub
 	#tag EndEvent
