Show calibration confirmation in GUI
This commit is contained in:
parent
a68ad5a3c3
commit
3e24361d18
7 changed files with 132 additions and 9 deletions
10
Makefile
10
Makefile
|
|
@ -61,13 +61,14 @@ MAKEFLAGS = --jobs=12
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJS = visualize.o serialdata.o rawdata.o magcal.o matrix.o fusion.o quality.o mahony.o
|
OBJS = visualize.o serialdata.o rawdata.o magcal.o matrix.o fusion.o quality.o mahony.o
|
||||||
|
IMGS = checkgreen.png checkempty.png checkemptygray.png
|
||||||
|
|
||||||
all: $(ALL)
|
all: $(ALL)
|
||||||
|
|
||||||
MotionCal: gui.o portlist.o $(OBJS)
|
MotionCal: gui.o portlist.o images.o $(OBJS)
|
||||||
$(CXX) $(SFLAG) $(CFLAGS) $(LDFLAGS) -o $@ $^ `$(WXCONFIG) --libs all,opengl`
|
$(CXX) $(SFLAG) $(CFLAGS) $(LDFLAGS) -o $@ $^ `$(WXCONFIG) --libs all,opengl`
|
||||||
|
|
||||||
MotionCal.exe: resource.o gui.o portlist.o $(OBJS)
|
MotionCal.exe: resource.o gui.o portlist.o images.o $(OBJS)
|
||||||
$(CXX) $(SFLAG) $(CFLAGS) $(LDFLAGS) -o $@ $^ `$(WXCONFIG) --libs all,opengl`
|
$(CXX) $(SFLAG) $(CFLAGS) $(LDFLAGS) -o $@ $^ `$(WXCONFIG) --libs all,opengl`
|
||||||
-pjrcwinsigntool $@
|
-pjrcwinsigntool $@
|
||||||
-./cp_windows.sh $@
|
-./cp_windows.sh $@
|
||||||
|
|
@ -75,6 +76,9 @@ MotionCal.exe: resource.o gui.o portlist.o $(OBJS)
|
||||||
resource.o: resource.rc icon.ico
|
resource.o: resource.rc icon.ico
|
||||||
$(WINDRES) $(WXFLAGS) -o resource.o resource.rc
|
$(WINDRES) $(WXFLAGS) -o resource.o resource.rc
|
||||||
|
|
||||||
|
images.cpp: $(IMGS) png2c.pl
|
||||||
|
perl png2c.pl $(IMGS) > images.cpp
|
||||||
|
|
||||||
MotionCal.app: MotionCal Info.plist icon.icns
|
MotionCal.app: MotionCal Info.plist icon.icns
|
||||||
mkdir -p $@/Contents/MacOS
|
mkdir -p $@/Contents/MacOS
|
||||||
mkdir -p $@/Contents/Resources/English.lproj
|
mkdir -p $@/Contents/Resources/English.lproj
|
||||||
|
|
@ -94,7 +98,7 @@ imuread: imuread.o $(OBJS)
|
||||||
$(CC) -s $(CFLAGS) $(LDFLAGS) -o $@ $^ $(CLILIBS)
|
$(CC) -s $(CFLAGS) $(LDFLAGS) -o $@ $^ $(CLILIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f gui MotionCal imuread *.o *.exe *.sign?
|
rm -f gui MotionCal imuread *.o *.exe *.sign? images.cpp
|
||||||
rm -rf MotionCal.app MotionCal.dmg .DS_Store dmg_tmpdir
|
rm -rf MotionCal.app MotionCal.dmg .DS_Store dmg_tmpdir
|
||||||
|
|
||||||
gui.o: gui.cpp gui.h imuread.h Makefile
|
gui.o: gui.cpp gui.h imuread.h Makefile
|
||||||
|
|
|
||||||
BIN
checkempty.png
Normal file
BIN
checkempty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 953 B |
BIN
checkemptygray.png
Normal file
BIN
checkemptygray.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 943 B |
BIN
checkgreen.png
Normal file
BIN
checkgreen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
32
gui.cpp
32
gui.cpp
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
|
|
||||||
wxString port_name;
|
wxString port_name;
|
||||||
|
static bool show_calibration_confirmed = false;
|
||||||
|
|
||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(MyCanvas, wxGLCanvas)
|
wxBEGIN_EVENT_TABLE(MyCanvas, wxGLCanvas)
|
||||||
|
|
@ -132,6 +133,13 @@ MyFrame::MyFrame(wxWindow *parent, wxWindowID id, const wxString &title,
|
||||||
m_button_sendcal = new wxButton(panel, ID_SENDCAL_BUTTON, "Send Cal");
|
m_button_sendcal = new wxButton(panel, ID_SENDCAL_BUTTON, "Send Cal");
|
||||||
vsizer->Add(m_button_sendcal, 1, wxEXPAND, 0);
|
vsizer->Add(m_button_sendcal, 1, wxEXPAND, 0);
|
||||||
m_button_sendcal->Enable(false);
|
m_button_sendcal->Enable(false);
|
||||||
|
vsizer->AddSpacer(16);
|
||||||
|
text = new wxStaticText(panel, wxID_ANY, "Status");
|
||||||
|
vsizer->Add(text, 0, wxTOP|wxBOTTOM, 4);
|
||||||
|
wxImage::AddHandler(new wxPNGHandler);
|
||||||
|
//m_confirm_icon = new wxStaticBitmap(panel, ID_CONFIRM_ICON, MyBitmap("checkgreen.png"));
|
||||||
|
m_confirm_icon = new wxStaticBitmap(panel, wxID_ANY, MyBitmap("checkemptygray.png"));
|
||||||
|
vsizer->Add(m_confirm_icon, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 0);
|
||||||
|
|
||||||
vsizer = new wxBoxSizer(wxVERTICAL);
|
vsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
middlesizer->Add(vsizer, 1, wxEXPAND | wxALL, 8);
|
middlesizer->Add(vsizer, 1, wxEXPAND | wxALL, 8);
|
||||||
|
|
@ -257,11 +265,17 @@ void MyFrame::OnTimer(wxTimerEvent &event)
|
||||||
wobble = quality_wobble_error();
|
wobble = quality_wobble_error();
|
||||||
fiterror = quality_spherical_fit_error();
|
fiterror = quality_spherical_fit_error();
|
||||||
if (gaps < 15.0f && variance < 4.5f && wobble < 4.0f && fiterror < 5.0f) {
|
if (gaps < 15.0f && variance < 4.5f && wobble < 4.0f && fiterror < 5.0f) {
|
||||||
m_sendcal_menu->Enable(ID_SENDCAL_MENU, true);
|
if (!m_sendcal_menu->IsEnabled(ID_SENDCAL_MENU) || !m_button_sendcal->IsEnabled()) {
|
||||||
m_button_sendcal->Enable(true);
|
m_sendcal_menu->Enable(ID_SENDCAL_MENU, true);
|
||||||
|
m_button_sendcal->Enable(true);
|
||||||
|
m_confirm_icon->SetBitmap(MyBitmap("checkempty.png"));
|
||||||
|
}
|
||||||
} else if (gaps > 20.0f && variance > 5.0f && wobble > 5.0f && fiterror > 6.0f) {
|
} else if (gaps > 20.0f && variance > 5.0f && wobble > 5.0f && fiterror > 6.0f) {
|
||||||
m_sendcal_menu->Enable(ID_SENDCAL_MENU, false);
|
if (m_sendcal_menu->IsEnabled(ID_SENDCAL_MENU) || m_button_sendcal->IsEnabled()) {
|
||||||
m_button_sendcal->Enable(false);
|
m_sendcal_menu->Enable(ID_SENDCAL_MENU, false);
|
||||||
|
m_button_sendcal->Enable(false);
|
||||||
|
m_confirm_icon->SetBitmap(MyBitmap("checkemptygray.png"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
snprintf(buf, sizeof(buf), "%.1f%%", quality_surface_gap_error());
|
snprintf(buf, sizeof(buf), "%.1f%%", quality_surface_gap_error());
|
||||||
m_err_coverage->SetLabelText(buf);
|
m_err_coverage->SetLabelText(buf);
|
||||||
|
|
@ -297,12 +311,17 @@ void MyFrame::OnTimer(wxTimerEvent &event)
|
||||||
m_sendcal_menu->Enable(ID_SENDCAL_MENU, false);
|
m_sendcal_menu->Enable(ID_SENDCAL_MENU, false);
|
||||||
m_button_clear->Enable(false);
|
m_button_clear->Enable(false);
|
||||||
m_button_sendcal->Enable(false);
|
m_button_sendcal->Enable(false);
|
||||||
|
m_confirm_icon->SetBitmap(MyBitmap("checkemptygray.png"));
|
||||||
m_port_list->Clear();
|
m_port_list->Clear();
|
||||||
m_port_list->Append("(none)");
|
m_port_list->Append("(none)");
|
||||||
m_port_list->SetSelection(0);
|
m_port_list->SetSelection(0);
|
||||||
port_name = "";
|
port_name = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (show_calibration_confirmed) {
|
||||||
|
m_confirm_icon->SetBitmap(MyBitmap("checkgreen.png"));
|
||||||
|
show_calibration_confirmed = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnClear(wxCommandEvent &event)
|
void MyFrame::OnClear(wxCommandEvent &event)
|
||||||
|
|
@ -322,12 +341,13 @@ void MyFrame::OnSendCal(wxCommandEvent &event)
|
||||||
printf(" %7.2f %6.3f %6.3f %6.3f\n",
|
printf(" %7.2f %6.3f %6.3f %6.3f\n",
|
||||||
magcal.V[2], magcal.invW[2][0], magcal.invW[2][1], magcal.invW[2][2]);
|
magcal.V[2], magcal.invW[2][0], magcal.invW[2][1], magcal.invW[2][2]);
|
||||||
*/
|
*/
|
||||||
|
m_confirm_icon->SetBitmap(MyBitmap("checkempty.png"));
|
||||||
send_calibration();
|
send_calibration();
|
||||||
}
|
}
|
||||||
|
|
||||||
void calibration_confirmed(void)
|
void calibration_confirmed(void)
|
||||||
{
|
{
|
||||||
// TODO: show GUI indication of calibration written to EEPROM
|
show_calibration_confirmed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -407,7 +427,7 @@ void MyFrame::OnAbout(wxCommandEvent &event)
|
||||||
"Paul Stoffregen <paul@pjrc.com>\n"
|
"Paul Stoffregen <paul@pjrc.com>\n"
|
||||||
"http://www.pjrc.com/store/prop_shield.html\n"
|
"http://www.pjrc.com/store/prop_shield.html\n"
|
||||||
"https://github.com/PaulStoffregen/MotionCal\n\n"
|
"https://github.com/PaulStoffregen/MotionCal\n\n"
|
||||||
"Copyright 2016, PJRC.COM, LLC.",
|
"Copyright 2018, PJRC.COM, LLC.",
|
||||||
"About MotionCal", wxOK|wxICON_INFORMATION|wxCENTER);
|
"About MotionCal", wxOK|wxICON_INFORMATION|wxCENTER);
|
||||||
dialog.ShowModal();
|
dialog.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
gui.h
4
gui.h
|
|
@ -79,6 +79,7 @@ private:
|
||||||
wxTimer *m_timer;
|
wxTimer *m_timer;
|
||||||
wxButton *m_button_clear;
|
wxButton *m_button_clear;
|
||||||
wxButton *m_button_sendcal;
|
wxButton *m_button_sendcal;
|
||||||
|
wxStaticBitmap *m_confirm_icon;
|
||||||
wxMenu *m_port_menu;
|
wxMenu *m_port_menu;
|
||||||
wxComboBox *m_port_list;
|
wxComboBox *m_port_list;
|
||||||
wxMenu *m_sendcal_menu;
|
wxMenu *m_sendcal_menu;
|
||||||
|
|
@ -108,6 +109,9 @@ private:
|
||||||
// portlist.cpp
|
// portlist.cpp
|
||||||
wxArrayString serial_port_list();
|
wxArrayString serial_port_list();
|
||||||
|
|
||||||
|
// images.cpp
|
||||||
|
wxBitmap MyBitmap(const char *name);
|
||||||
|
|
||||||
// sample port name, for initial sizing of left panel
|
// sample port name, for initial sizing of left panel
|
||||||
#if defined(LINUX)
|
#if defined(LINUX)
|
||||||
#define SAMPLE_PORT_NAME "/dev/ttyACM5."
|
#define SAMPLE_PORT_NAME "/dev/ttyACM5."
|
||||||
|
|
|
||||||
95
png2c.pl
Executable file
95
png2c.pl
Executable file
|
|
@ -0,0 +1,95 @@
|
||||||
|
#! /usr/bin/perl
|
||||||
|
|
||||||
|
binmode IN, ":bytes";
|
||||||
|
$file = $ARGV[0];
|
||||||
|
|
||||||
|
print "#include <wx/bitmap.h>\n";
|
||||||
|
print "#include <wx/image.h>\n";
|
||||||
|
print "#include <wx/mstream.h>\n";
|
||||||
|
print "\n";
|
||||||
|
|
||||||
|
foreach $file (@ARGV) {
|
||||||
|
open(IN, $file) or die "Can't open $file: $!\n";
|
||||||
|
$count = 0;
|
||||||
|
$len = -s $file;
|
||||||
|
$filelist[$numfiles] = $file;
|
||||||
|
$file =~ /^([-_A-Za-z0-9\/]+)/;
|
||||||
|
$name = "png_$1";
|
||||||
|
$name =~ s/\//_/g;
|
||||||
|
$name =~ s/-/_/g;
|
||||||
|
$size[$numfiles] = $len;
|
||||||
|
$list[$numfiles++] = $name;
|
||||||
|
print "static unsigned char ${name}[$len] = \{\n";
|
||||||
|
while (read(IN, $byte, 1) == 1) {
|
||||||
|
$n = ord($byte);
|
||||||
|
printf '0x%02X', $n;
|
||||||
|
print ',' if $count < $len - 1;
|
||||||
|
print "\n" if $count++ % 12 == 11;
|
||||||
|
}
|
||||||
|
print "\};\n";
|
||||||
|
close(IN);
|
||||||
|
}
|
||||||
|
print "\nstatic const unsigned char *png_image_list[] = {\n";
|
||||||
|
for ($i=0; $i<$numfiles; $i++) {
|
||||||
|
print "$list[$i]";
|
||||||
|
print ',' if $i < $numfiles - 1;
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
print "\};\n";
|
||||||
|
|
||||||
|
print "\nstatic const char *png_image_name[] = {\n";
|
||||||
|
for ($i=0; $i<$numfiles; $i++) {
|
||||||
|
print "\"$filelist[$i]\"";
|
||||||
|
print ',' if $i < $numfiles - 1;
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
print "\};\n";
|
||||||
|
|
||||||
|
print "\nstatic const unsigned int png_image_size[] = {\n";
|
||||||
|
for ($i=0; $i<$numfiles; $i++) {
|
||||||
|
print "$size[$i]";
|
||||||
|
print ',' if $i < $numfiles - 1;
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
print "\};\n";
|
||||||
|
|
||||||
|
print "\nstatic wxBitmap * image_list[] = {\n";
|
||||||
|
for ($i=0; $i<$numfiles; $i++) {
|
||||||
|
print "NULL";
|
||||||
|
print ',' if $i < $numfiles - 1;
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print "\};\n\n";
|
||||||
|
|
||||||
|
print <<EOT;
|
||||||
|
wxBitmap MyBitmap(size_t index)
|
||||||
|
{
|
||||||
|
if (index >= $numfiles || index < 0) return wxNullBitmap;
|
||||||
|
wxBitmap *p = image_list[index];
|
||||||
|
if (p) return *p;
|
||||||
|
wxMemoryInputStream istream(png_image_list[index], png_image_size[index]);
|
||||||
|
wxImage img(istream, wxBITMAP_TYPE_PNG);
|
||||||
|
p = new wxBitmap(img);
|
||||||
|
return *p;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmap MyBitmap(const char *name)
|
||||||
|
{
|
||||||
|
for (size_t i=0; i < $numfiles; i++) {
|
||||||
|
if (strcmp(name, png_image_name[i]) == 0) return MyBitmap(i);
|
||||||
|
}
|
||||||
|
return wxNullBitmap;
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue