picking up eos change that did not get committed, for PORT designation feature

This commit is contained in:
jlpoole 2026-04-29 17:07:08 -07:00
commit 515cc9bcff
2 changed files with 52 additions and 3 deletions

30
gui.cpp
View file

@ -3,9 +3,22 @@
wxString port_name;
static wxArrayString requested_ports;
static bool show_calibration_confirmed = false;
static bool calibration_saved = false;
static wxArrayString available_port_list(void)
{
wxArrayString list = serial_port_list();
for (size_t i=0; i < requested_ports.GetCount(); i++) {
if (list.Index(requested_ports[i]) == wxNOT_FOUND) {
list.Add(requested_ports[i]);
}
}
list.Sort();
return list;
}
static int valid_mag_point_count(void)
{
int i, count=0;
@ -383,7 +396,7 @@ void MyFrame::OnShowMenu(wxMenuEvent &event)
menu->AppendRadioItem(9000, " (none)");
bool isopen = port_is_open();
if (!isopen) menu->Check(9000, true);
wxArrayString list = serial_port_list();
wxArrayString list = available_port_list();
int num = list.GetCount();
for (int i=0; i < num; i++) {
menu->AppendRadioItem(9001 + i, list[i]);
@ -399,7 +412,7 @@ void MyFrame::OnShowPortList(wxCommandEvent& event)
//printf("OnShowPortList\n");
m_port_list->Clear();
m_port_list->Append("(none)");
wxArrayString list = serial_port_list();
wxArrayString list = available_port_list();
int num = list.GetCount();
for (int i=0; i < num; i++) {
m_port_list->Append(list[i]);
@ -480,6 +493,19 @@ bool MyApp::OnInit()
// make sure we exit properly on macosx
SetExitOnFrameDelete(true);
for (int i=1; i < argc; i++) {
wxString arg(argv[i]);
if ((arg == "--port" || arg == "-p") && i + 1 < argc) {
wxString requested(argv[++i]);
if (!requested.IsEmpty() && requested_ports.Index(requested) == wxNOT_FOUND) {
requested_ports.Add(requested);
}
} else if (arg == "--help" || arg == "-h") {
fprintf(stderr, "Usage: MotionCal [--port /path/to/tty]\n");
return false;
}
}
wxPoint pos(100, 100);
MyFrame *frame = new MyFrame(NULL, -1, "Motion Sensor Calibration Tool",