Thanks Justin. That got it.
Cheers!
Printable View
Thanks Justin. That got it.
Cheers!
Okay, I may have spoke too soon. I get the settings screen, with the settings option and OK button. I do not see the sample buttons/labels. And (as I figured anyway) if I set a main menu button to my plugin, nothing happens when I click it (because no skin file?).
Where should I see the sample buttons? Why might I not see the samples?
John
Okay scratch my issues up to this point. My plugins stuff is kinda working right now. Except The whole thing works fine, as long as i stay in OM but exit and come back and the setting is gone. History. All the extra logging stuff i put in says everything works right. Kinda irritating and making me feel inadequate. I don't know if there is something i don't know about or if Im just stupid so i gotta step away. Im giving up for tonight.
Tomorrow is a new day.
I think I understand what your describing but if not feel free to correct me.
This may be a stupid question but are you saving the setting? Each Setting class stores a setting for display purposes only. If that setting is changed, the Settings class fires an OnSettingChanged event with the changed setting. Your plugin will then need to save this setting similar to how the plugin example does it:
Code:Using settings As PluginSettings = New PluginSettings
settings.setSetting(s.Name, s.Value)
End Using
Never a stupid question. The quick answer is yes. Here are my loadsettings() and setting_changed():
Code:Public Function loadSettings() As Settings Implements IHighLevel.loadSettings
'Class Level: Private settings As Settings (Settings screen items)
Dim z As String
Dim x As Integer
Dim COMOptions As New Generic.List(Of String)
Dim COMValues As New Generic.List(Of String)
Dim m_Settings As New OpenMobile.Data.PluginSettings ' for the settings data for our plugin
Me.settings = New Settings("OMArduino")
If String.IsNullOrEmpty(m_Settings.getSetting("OMArduino.ComPort")) Then
' The comport value does not exist
log_msg(".... com port setting not yet created")
m_Settings.setSetting("OMArduino.ComPort", m_ComPort.ToString)
log_msg("........ created with value: " & m_ComPort.ToString)
Else
log_msg("Found existing setting: " & m_ComPort.ToString)
m_ComPort = Val(m_Settings.getSetting("OMArduino.comport"))
End If
' temporary to write to 'arduino.log' in the OM folder
log_msg("Gathering available com ports")
COMOptions.Add("Auto")
COMOptions.AddRange(System.IO.Ports.SerialPort.GetPortNames)
For Each Port As String In COMOptions
If Port = "Auto" Then
COMValues.Add("0")
log_msg(".... adding " & Port & " as 0")
Else
z = Port.Replace("COM", "")
COMValues.Add(z)
log_msg(".... adding " & Port & " as " & z)
End If
Next
x = COMOptions.Count
log_msg(".... list built with " & x & " items")
' The create the comport multichoice control
If String.IsNullOrEmpty(m_Settings.getSetting("OMArduino.ComPort")) Then
' The comport value does not exist
log_msg(".... com port setting not yet created")
m_Settings.setSetting("OMArduino.ComPort", m_ComPort.ToString)
log_msg("........ created with value: " & m_ComPort.ToString)
End If
log_msg(".... creating COM port list control for settings screen")
settings.Add(New Setting(SettingTypes.MultiChoice, "OMArduino.ComPort", "COM", "Com Port", COMOptions, COMValues, m_ComPort.ToString))
log_msg("........ created with default " & m_ComPort.ToString)
AddHandler Me.settings.OnSettingChanged, New SettingChanged(AddressOf Setting_Changed)
log_msg("....handler assigned")
log_msg("DONE!")
'Settings collections are automatically laid out by the framework
Return Me.settings
End Function
I am sure I am still missing something, but pretty sure I reach the m_settings.setSettings() and it returns TRUE in the test. My simple logging always finds the setting, but it is always = 0 (should be 5 for my one and only com port).Code:Private Sub Setting_Changed(ByVal s As Setting)
'When a setting changes you should update your plugin with
'the new setting information
'Then the setting should be saved to the database
Dim z As Integer = 0
Using m_settings As PluginSettings = New PluginSettings
Select Case s.Name
Case "OMArduino.ComPort"
m_ComPort = Val(s.Value)
If (m_settings.setSetting(s.Name, s.Value)) Then
log_msg("Changed setting " & s.Name & " to " & s.Value)
Else
log_msg("Could not set " & s.Name & " to " & s.Value)
End If
Case "OMArduino.Pin1"
Case "OMArduino.Pin2"
Case "OMArduino.Pin3"
Case "OMArduino.Pin4"
End Select
End Using
End Sub
Here is my log output for 1st and 2nd opening of OM then going into settings:
Gotta run. I'm out for most of the morning. Thanks for looking.Code:Found existing setting: 0
Gathering available com ports
.... adding Auto as 0
.... adding COM5 as 5
.... list built with 2 items
.... creating COM port list control for settings screen
........ created with default 0
....handler assigned
DONE!
Changed setting OMArduino.ComPort to 5
Found existing setting: 0
Gathering available com ports
.... adding Auto as 0
.... adding COM5 as 5
.... list built with 2 items
.... creating COM port list control for settings screen
........ created with default 0
....handler assigned
DONE!
Changed setting OMArduino.ComPort to 5
John
John
Well, time for new glasses? Time to go back to school? Or how about a new day, some sleep, and fresh eyes.
Everywhere in my plugin I use "OMArduino.ComPort". Okay, makes sense. Only that the 2 lines that reload the existing value, because it is Not Null or Empty, loads in "OMArduino.comport".
How quick did you notice the problem above? DOH! Case sensitivity. I can't believe it took me a few hours to pin that down.
I'm happy again, until the next blunder.
Cheers,
John
DOh...if it makes you feel any better I looked over that a dozen times and missed it too lol
Oh yes, I'm sure we've ALL been there before. I'm not afraid to admit overlooking the same thing 100 times and every time it just "looks" right.
Now I can't wait for the Arduino to arrive (tomorrow hopefully) to begin the real work.
Im lovin the challenge.
Cheers,
John
Okay. I would like to request a favor.
I need some snippets to show me how to get/send data to a selected com port. I can easily do it with an MSCOMCTL object on form based project (basically drag-n-drop the control), but not sure what I should do with just a class library.
Is there related routines in the framework?
John
There's no serial port interface in the framework as of now (at least not any that I'm aware of...)
Found this link after a quick google for "c# com port interface", it should help you along for serial communication: http://www.dreamincode.net/forums/to...ation-in-c%23/