|
|
@@ -51,7 +51,8 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
Window *window;
|
|
|
|
Window *window;
|
|
|
|
grbl::jog_state jog;
|
|
|
|
grbl::jog_state jog;
|
|
|
|
TextArea *lblStatus, *lblSubstatus;
|
|
|
|
TextBox *txtStatus;
|
|
|
|
|
|
|
|
TextBox *txtMessage;
|
|
|
|
nanogui::Color colRed = nanogui::Color(255, 0, 0, 255);
|
|
|
|
nanogui::Color colRed = nanogui::Color(255, 0, 0, 255);
|
|
|
|
nanogui::Color colGreen = nanogui::Color(0, 255, 0, 255);
|
|
|
|
nanogui::Color colGreen = nanogui::Color(0, 255, 0, 255);
|
|
|
|
nanogui::Color colBg;
|
|
|
|
nanogui::Color colBg;
|
|
|
@@ -59,6 +60,9 @@ public:
|
|
|
|
grbl::program pgm;
|
|
|
|
grbl::program pgm;
|
|
|
|
Button *btnLoadProgram, *btnCheckProgram, *btnRunProgram;
|
|
|
|
Button *btnLoadProgram, *btnCheckProgram, *btnRunProgram;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> jog_distances = {"0.01", "0.1", "1", "10"};
|
|
|
|
|
|
|
|
std::vector<std::string> jog_feed_rates = {"5", "100", "500", "1000"};
|
|
|
|
|
|
|
|
|
|
|
|
grbl::program_renderer renderer;
|
|
|
|
grbl::program_renderer renderer;
|
|
|
|
|
|
|
|
|
|
|
|
glm::vec3 cam_target = glm::vec3(0);
|
|
|
|
glm::vec3 cam_target = glm::vec3(0);
|
|
|
@@ -72,7 +76,8 @@ public:
|
|
|
|
VScrollPanel *parameters_vscroll;
|
|
|
|
VScrollPanel *parameters_vscroll;
|
|
|
|
Widget *parameters_layer;
|
|
|
|
Widget *parameters_layer;
|
|
|
|
TextBox *mpos_x_text, *mpos_y_text, *mpos_z_text;
|
|
|
|
TextBox *mpos_x_text, *mpos_y_text, *mpos_z_text;
|
|
|
|
ComboBox *cboOffset, *cboTool;
|
|
|
|
ComboBox *cbo_work_offset, *cbo_tool, *cbo_jog_feed_rates, *cbo_jog_distance;
|
|
|
|
|
|
|
|
Button *btn_keyboard_jog;
|
|
|
|
|
|
|
|
|
|
|
|
SenderApp() : Screen(Vector2i(1024, 768), "GRBL Sender") {
|
|
|
|
SenderApp() : Screen(Vector2i(1024, 768), "GRBL Sender") {
|
|
|
|
inc_ref();
|
|
|
|
inc_ref();
|
|
|
@@ -82,36 +87,71 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
// create main window
|
|
|
|
// create main window
|
|
|
|
window = new Window(this, "Machine status");
|
|
|
|
window = new Window(this, "Machine status");
|
|
|
|
window->set_fixed_height((Screen::size().y() - 40) / 2);
|
|
|
|
// window->set_fixed_height((Screen::size().y() - 40) / 2);
|
|
|
|
window->set_position(Vector2i(0, 0));
|
|
|
|
window->set_position(Vector2i(0, 0));
|
|
|
|
window->set_layout(new BoxLayout(nanogui::Orientation::Vertical));
|
|
|
|
window->set_layout(new BoxLayout(nanogui::Orientation::Vertical));
|
|
|
|
|
|
|
|
|
|
|
|
tab_widget = window->add<TabWidget>();
|
|
|
|
tab_widget = window->add<TabWidget>();
|
|
|
|
tab_widget->set_callback([&](int index) {
|
|
|
|
tab_widget->set_callback([&](int index) {
|
|
|
|
if (index == 1 || index == 2) {
|
|
|
|
|
|
|
|
perform_layout();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tab_widget->set_selected_index(index);
|
|
|
|
tab_widget->set_selected_index(index);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
tab_widget->set_fixed_height((this->height() - 100) / 2);
|
|
|
|
tab_widget->set_fixed_height((this->height() - 80) / 2);
|
|
|
|
|
|
|
|
|
|
|
|
Widget *layer = new Widget(tab_widget);
|
|
|
|
Widget *layer = new Widget(tab_widget);
|
|
|
|
layer->set_layout(new GroupLayout());
|
|
|
|
layer->set_layout(new GroupLayout(10, 20, 30, 0));
|
|
|
|
tab_widget->append_tab("Info", layer);
|
|
|
|
tab_widget->append_tab("Info", layer);
|
|
|
|
|
|
|
|
|
|
|
|
new Label(layer, "Status", "sans-bold");
|
|
|
|
layer->add<Label>("");
|
|
|
|
Widget *status_holder = new Widget(layer);
|
|
|
|
auto status_holder = layer->add<Widget>();
|
|
|
|
status_holder->set_layout(new GridLayout());
|
|
|
|
status_holder->set_layout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 0, 0));
|
|
|
|
|
|
|
|
|
|
|
|
lblStatus = layer->add<TextArea>();
|
|
|
|
auto status_text_holder = status_holder->add<Widget>();
|
|
|
|
lblStatus->set_fixed_height(20);
|
|
|
|
status_text_holder->set_layout(new GridLayout(Orientation::Horizontal, 3, nanogui::Alignment::Fill, 0, 0));
|
|
|
|
lblStatus->set_font("sans");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lblSubstatus = layer->add<TextArea>();
|
|
|
|
status_text_holder->add<Label>("Status", "sans-bold", 20);
|
|
|
|
lblSubstatus->set_font("sans");
|
|
|
|
|
|
|
|
lblSubstatus->set_fixed_height(50);
|
|
|
|
txtStatus = status_text_holder->add<TextBox>();
|
|
|
|
|
|
|
|
txtStatus->set_editable(false);
|
|
|
|
|
|
|
|
txtStatus->set_fixed_width(300);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto *btnReset = status_text_holder->add<Button>("Reset");
|
|
|
|
|
|
|
|
btnReset->set_background_color(colRed);
|
|
|
|
|
|
|
|
btnReset->set_callback([&] {
|
|
|
|
|
|
|
|
cnc.request_reset();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
status_text_holder->add<Label>("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
txtMessage = status_text_holder->add<TextBox>("");
|
|
|
|
|
|
|
|
txtMessage->set_fixed_width(300);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_text_holder->add<Label>("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// buttons
|
|
|
|
|
|
|
|
auto status_btn_holder = status_holder->add<Widget>();
|
|
|
|
|
|
|
|
status_btn_holder->set_layout(new GridLayout(Orientation::Horizontal, 2, Alignment::Fill, 6, 6));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto *btnHome = new Button(status_btn_holder, "Home", FA_HOME);
|
|
|
|
|
|
|
|
btnHome->set_callback([&] {
|
|
|
|
|
|
|
|
cnc.request_home();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto *btnUnlock = new Button(status_btn_holder, "Unlock", FA_UNLOCK);
|
|
|
|
|
|
|
|
btnUnlock->set_callback([&] {
|
|
|
|
|
|
|
|
cnc.request_unlock();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// buttons to change state
|
|
|
|
|
|
|
|
auto *btnCycleStart = status_btn_holder->add<Button>("Cycle Start", FA_PLAY);
|
|
|
|
|
|
|
|
btnCycleStart->set_callback([&] {
|
|
|
|
|
|
|
|
cnc.request_cycle_start();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
auto *btnFeedHold = status_btn_holder->add<Button>("Feed Hold", FA_PAUSE);
|
|
|
|
|
|
|
|
btnFeedHold->set_callback([&] {
|
|
|
|
|
|
|
|
cnc.request_feed_hold();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// DRO
|
|
|
|
// DRO
|
|
|
|
layer->add<Label>("DRO", "sans-bold", 20);
|
|
|
|
layer->add<Label>("DRO", "sans-bold", 20);
|
|
|
@@ -128,7 +168,7 @@ public:
|
|
|
|
zero_btn->set_flags(Button::Flags::NormalButton);
|
|
|
|
zero_btn->set_flags(Button::Flags::NormalButton);
|
|
|
|
zero_btn->set_tooltip("Zero axis");
|
|
|
|
zero_btn->set_tooltip("Zero axis");
|
|
|
|
zero_btn->set_callback([&]() {
|
|
|
|
zero_btn->set_callback([&]() {
|
|
|
|
cnc.zero_offset_axis(cboOffset->selected_index(), 0);
|
|
|
|
cnc.zero_offset_axis(cbo_work_offset->selected_index(), 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
auto y_holder = mpos->add<Widget>();
|
|
|
|
auto y_holder = mpos->add<Widget>();
|
|
|
@@ -141,7 +181,7 @@ public:
|
|
|
|
zero_btn->set_flags(Button::Flags::NormalButton);
|
|
|
|
zero_btn->set_flags(Button::Flags::NormalButton);
|
|
|
|
zero_btn->set_tooltip("Zero axis");
|
|
|
|
zero_btn->set_tooltip("Zero axis");
|
|
|
|
zero_btn->set_callback([&]() {
|
|
|
|
zero_btn->set_callback([&]() {
|
|
|
|
cnc.zero_offset_axis(cboOffset->selected_index(), 1);
|
|
|
|
cnc.zero_offset_axis(cbo_work_offset->selected_index(), 1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
auto z_holder = mpos->add<Widget>();
|
|
|
|
auto z_holder = mpos->add<Widget>();
|
|
|
@@ -154,103 +194,175 @@ public:
|
|
|
|
zero_btn->set_flags(Button::Flags::NormalButton);
|
|
|
|
zero_btn->set_flags(Button::Flags::NormalButton);
|
|
|
|
zero_btn->set_tooltip("Zero axis");
|
|
|
|
zero_btn->set_tooltip("Zero axis");
|
|
|
|
zero_btn->set_callback([&]() {
|
|
|
|
zero_btn->set_callback([&]() {
|
|
|
|
cnc.zero_offset_axis(cboOffset->selected_index(), 2);
|
|
|
|
cnc.zero_offset_axis(cbo_work_offset->selected_index(), 2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
auto zero_all_btn = mpos->add<Button>("Zero all");
|
|
|
|
auto axis_btns_holder = mpos->add<Widget>();
|
|
|
|
|
|
|
|
axis_btns_holder->set_layout(new BoxLayout(Orientation::Horizontal, Alignment::Middle, 0, 6));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto zero_all_btn = axis_btns_holder->add<Button>("Zero all");
|
|
|
|
zero_all_btn->set_callback([&]() {
|
|
|
|
zero_all_btn->set_callback([&]() {
|
|
|
|
cnc.zero_offset(cboOffset->selected_index());
|
|
|
|
cnc.zero_offset(cbo_work_offset->selected_index());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
auto goto_zero_btn = mpos->add<Button>("Goto 0");
|
|
|
|
auto goto_zero_btn = axis_btns_holder->add<Button>("Goto 0");
|
|
|
|
goto_zero_btn->set_callback([&]() {
|
|
|
|
goto_zero_btn->set_callback([&]() {
|
|
|
|
cnc.go_to_zero(true, true, true);
|
|
|
|
cnc.go_to_zero(true, true, true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// jogging
|
|
|
|
|
|
|
|
layer->add<Label>("Jogging", "sans-bold", 20);
|
|
|
|
|
|
|
|
auto holder = new Widget(layer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
holder->set_layout(new GridLayout(Orientation::Horizontal, 3, Alignment::Fill, 0, 0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// feed and distance
|
|
|
|
|
|
|
|
auto jogParamsHolder = holder->add<Widget>();
|
|
|
|
|
|
|
|
jogParamsHolder->set_layout(new GridLayout(Orientation::Horizontal, 3, Alignment::Fill, 0, 4));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jogParamsHolder->add<Label>("Feed", "sans-bold");
|
|
|
|
|
|
|
|
cbo_jog_feed_rates = jogParamsHolder->add<ComboBox>(jog_feed_rates);
|
|
|
|
|
|
|
|
cbo_jog_feed_rates->set_selected_index(2);
|
|
|
|
|
|
|
|
jogParamsHolder->add<Label>("mm/min");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jogParamsHolder->add<Label>("Distance", "sans-bold");
|
|
|
|
|
|
|
|
cbo_jog_distance = jogParamsHolder->add<ComboBox>(jog_distances);
|
|
|
|
|
|
|
|
cbo_jog_distance->set_selected_index(2);
|
|
|
|
|
|
|
|
jogParamsHolder->add<Label>("mm");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jogParamsHolder->add<Label>("Keyboard Jog", "sans-bold");
|
|
|
|
|
|
|
|
btn_keyboard_jog = jogParamsHolder->add<Button>("", FA_KEYBOARD);
|
|
|
|
|
|
|
|
btn_keyboard_jog->set_flags(Button::Flags::ToggleButton);
|
|
|
|
|
|
|
|
jogParamsHolder->add<Label>("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// X and Y
|
|
|
|
|
|
|
|
auto jogBtnsHolder = holder->add<Widget>();
|
|
|
|
|
|
|
|
jogBtnsHolder->set_layout(new GridLayout(Orientation::Horizontal, 3, Alignment::Fill, 0, 6));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jogBtnsHolder->add<Label>("");
|
|
|
|
|
|
|
|
auto jog_btn = jogBtnsHolder->add<Button>("", FA_ARROW_ALT_CIRCLE_UP);
|
|
|
|
|
|
|
|
jog_btn->set_callback([&]() {
|
|
|
|
|
|
|
|
// FIXME: get rid of std::stof
|
|
|
|
|
|
|
|
cnc.request_jog_fixed(grbl::jog_direction::y_up,
|
|
|
|
|
|
|
|
std::stof(jog_distances[cbo_jog_distance->selected_index()]),
|
|
|
|
|
|
|
|
std::stof(jog_feed_rates[cbo_jog_feed_rates->selected_index()]));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
jogBtnsHolder->add<Label>("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jog_btn = jogBtnsHolder->add<Button>("", FA_ARROW_ALT_CIRCLE_LEFT);
|
|
|
|
|
|
|
|
jog_btn->set_callback([&]() {
|
|
|
|
|
|
|
|
// FIXME: get rid of std::stof
|
|
|
|
|
|
|
|
cnc.request_jog_fixed(grbl::jog_direction::x_down,
|
|
|
|
|
|
|
|
std::stof(jog_distances[cbo_jog_distance->selected_index()]),
|
|
|
|
|
|
|
|
std::stof(jog_feed_rates[cbo_jog_feed_rates->selected_index()]));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jog_btn = jogBtnsHolder->add<Button>("", FA_HOME);
|
|
|
|
|
|
|
|
jog_btn->set_callback([&]() {
|
|
|
|
|
|
|
|
cnc.go_to_zero(true, true, false);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jog_btn = jogBtnsHolder->add<Button>("", FA_ARROW_ALT_CIRCLE_RIGHT);
|
|
|
|
|
|
|
|
jog_btn->set_callback([&]() {
|
|
|
|
|
|
|
|
// FIXME: get rid of std::stof
|
|
|
|
|
|
|
|
cnc.request_jog_fixed(grbl::jog_direction::x_up,
|
|
|
|
|
|
|
|
std::stof(jog_distances[cbo_jog_distance->selected_index()]),
|
|
|
|
|
|
|
|
std::stof(jog_feed_rates[cbo_jog_feed_rates->selected_index()]));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jogBtnsHolder->add<Label>("");
|
|
|
|
|
|
|
|
jog_btn = jogBtnsHolder->add<Button>("", FA_ARROW_ALT_CIRCLE_DOWN);
|
|
|
|
|
|
|
|
jog_btn->set_callback([&]() {
|
|
|
|
|
|
|
|
// FIXME: get rid of std::stof
|
|
|
|
|
|
|
|
cnc.request_jog_fixed(grbl::jog_direction::y_down,
|
|
|
|
|
|
|
|
std::stof(jog_distances[cbo_jog_distance->selected_index()]),
|
|
|
|
|
|
|
|
std::stof(jog_feed_rates[cbo_jog_feed_rates->selected_index()]));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
jogBtnsHolder->add<Label>("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// z up/down
|
|
|
|
|
|
|
|
auto jogZBtnsHolder = holder->add<Widget>();
|
|
|
|
|
|
|
|
jogZBtnsHolder->set_layout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 0, 6));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jog_btn = jogZBtnsHolder->add<Button>("", FA_CHEVRON_UP);
|
|
|
|
|
|
|
|
jog_btn->set_callback([&]() {
|
|
|
|
|
|
|
|
// FIXME: get rid of std::stof
|
|
|
|
|
|
|
|
cnc.request_jog_fixed(grbl::jog_direction::z_up,
|
|
|
|
|
|
|
|
std::stof(jog_distances[cbo_jog_distance->selected_index()]),
|
|
|
|
|
|
|
|
std::stof(jog_feed_rates[cbo_jog_feed_rates->selected_index()]));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jog_btn = jogZBtnsHolder->add<Button>("", FA_HOME);
|
|
|
|
|
|
|
|
jog_btn->set_callback([&]() {
|
|
|
|
|
|
|
|
cnc.go_to_zero(0, 0, true);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jog_btn = jogZBtnsHolder->add<Button>("", FA_CHEVRON_DOWN);
|
|
|
|
|
|
|
|
jog_btn->set_callback([&]() {
|
|
|
|
|
|
|
|
// FIXME: get rid of std::stof
|
|
|
|
|
|
|
|
cnc.request_jog_fixed(grbl::jog_direction::z_down,
|
|
|
|
|
|
|
|
std::stof(jog_distances[cbo_jog_distance->selected_index()]),
|
|
|
|
|
|
|
|
std::stof(jog_feed_rates[cbo_jog_feed_rates->selected_index()]));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// work parameters
|
|
|
|
// work parameters
|
|
|
|
layer->add<Label>("Work parameters", "sans-bold", 20);
|
|
|
|
layer->add<Label>("Work parameters", "sans-bold", 20);
|
|
|
|
auto x = new Widget(layer);
|
|
|
|
auto work_holder = layer->add<Widget>();
|
|
|
|
x->set_layout(new GridLayout(Orientation::Horizontal, 4, Alignment::Middle, 0, 6));
|
|
|
|
work_holder->set_layout(new BoxLayout(nanogui::Orientation::Horizontal, Alignment::Fill, 6, 6));
|
|
|
|
|
|
|
|
|
|
|
|
x->add<Label>("Offset:");
|
|
|
|
auto work_data_holder = work_holder->add<Widget>();
|
|
|
|
|
|
|
|
work_data_holder->set_layout(new GridLayout(Orientation::Horizontal, 2, Alignment::Fill, 6, 6));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
work_data_holder->add<Label>("Offset", "sans-bold");
|
|
|
|
std::vector<std::string> offset_items = {"G54", "G55", "G56", "G57", "G58", "G59"};
|
|
|
|
std::vector<std::string> offset_items = {"G54", "G55", "G56", "G57", "G58", "G59"};
|
|
|
|
cboOffset = x->add<ComboBox>(offset_items);
|
|
|
|
cbo_work_offset = work_data_holder->add<ComboBox>(offset_items);
|
|
|
|
cboOffset->set_callback([&](int idx) {
|
|
|
|
cbo_work_offset->set_callback([&](int idx) {
|
|
|
|
refresh_offset();
|
|
|
|
refresh_offset();
|
|
|
|
update_dro();
|
|
|
|
update_dro();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
x->add<Label>("Tool:");
|
|
|
|
work_data_holder->add<Label>("Tool", "sans-bold");
|
|
|
|
std::vector<std::string> tool_items = {"None"};
|
|
|
|
std::vector<std::string> tool_items = {"None"};
|
|
|
|
cboTool = x->add<ComboBox>(tool_items);
|
|
|
|
cbo_tool = work_data_holder->add<ComboBox>(tool_items);
|
|
|
|
|
|
|
|
|
|
|
|
// buttons to change state
|
|
|
|
auto work_btns_holder = work_holder->add<Widget>();
|
|
|
|
new Label(layer, "Actions", "sans-bold");
|
|
|
|
work_btns_holder->set_layout(new GridLayout(Orientation::Horizontal, 3, Alignment::Fill, 0, 6));
|
|
|
|
auto *actions = new Widget(layer);
|
|
|
|
|
|
|
|
actions->set_layout(new BoxLayout(Orientation::Horizontal));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto *btnUnlock = new Button(actions, "Unlock");
|
|
|
|
|
|
|
|
btnUnlock->set_callback([&] {
|
|
|
|
|
|
|
|
cnc.request_unlock();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
auto *btnHome = new Button(actions, "Home");
|
|
|
|
|
|
|
|
btnHome->set_callback([&] {
|
|
|
|
|
|
|
|
cnc.request_home();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
auto *btnReset = new Button(actions, "Reset");
|
|
|
|
|
|
|
|
btnReset->set_background_color(colRed);
|
|
|
|
|
|
|
|
btnReset->set_callback([&] {
|
|
|
|
|
|
|
|
cnc.request_reset();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
auto *btnCycleStart = new Button(actions, "Cycle Start");
|
|
|
|
|
|
|
|
btnCycleStart->set_callback([&] {
|
|
|
|
|
|
|
|
cnc.request_cycle_start();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
auto *btnFeedHold = new Button(actions, "Feed Hold");
|
|
|
|
|
|
|
|
btnFeedHold->set_callback([&] {
|
|
|
|
|
|
|
|
cnc.request_feed_hold();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// No need to store a pointer, the data structure will be automatically
|
|
|
|
|
|
|
|
// freed when the parent window is deleted
|
|
|
|
|
|
|
|
new Label(layer, "Program", "sans-bold");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget *pgm_actions = new Widget(layer);
|
|
|
|
|
|
|
|
pgm_actions->set_layout(new BoxLayout(Orientation::Horizontal));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btnLoadProgram = new Button(pgm_actions, "Load");
|
|
|
|
btnLoadProgram = work_btns_holder->add<Button>("Load");
|
|
|
|
btnLoadProgram->set_callback([&] {
|
|
|
|
btnLoadProgram->set_callback([&] {
|
|
|
|
auto path = file_dialog(
|
|
|
|
auto path = file_dialog(
|
|
|
|
{{"gcode", "G-Code files"},
|
|
|
|
{{"gcode", "G-Code files"},
|
|
|
|
{"nc", "G-Code files"},
|
|
|
|
{"nc", "G-Code files"},
|
|
|
|
{"ngc", "G-Code files"}}, true);
|
|
|
|
{"ngc", "G-Code files"}}, true);
|
|
|
|
|
|
|
|
|
|
|
|
btnCheckProgram->set_background_color(colBg);
|
|
|
|
// btnCheckProgram->set_background_color(colBg);
|
|
|
|
btnRunProgram->set_background_color(colBg);
|
|
|
|
// btnRunProgram->set_background_color(colBg);
|
|
|
|
|
|
|
|
|
|
|
|
if (pgm.load_from_file(path)) {
|
|
|
|
if (pgm.load_from_file(path)) {
|
|
|
|
btnCheckProgram->set_enabled(true);
|
|
|
|
// btnCheckProgram->set_enabled(true);
|
|
|
|
// btnRunProgram->set_enabled(true);
|
|
|
|
// btnRunProgram->set_enabled(true);
|
|
|
|
this->init_program_geometry();
|
|
|
|
this->init_program_geometry();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
btnCheckProgram->set_enabled(false);
|
|
|
|
// btnCheckProgram->set_enabled(false);
|
|
|
|
btnRunProgram->set_enabled(false);
|
|
|
|
// btnRunProgram->set_enabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
btnLoadProgram->set_tooltip("Load program");
|
|
|
|
btnLoadProgram->set_tooltip("Load program");
|
|
|
|
|
|
|
|
|
|
|
|
btnCheckProgram = new Button(pgm_actions, "Check");
|
|
|
|
btnCheckProgram = work_btns_holder->add<Button>("Check");
|
|
|
|
btnCheckProgram->set_enabled(false);
|
|
|
|
// btnCheckProgram->set_enabled(false);
|
|
|
|
btnCheckProgram->set_callback([&] {
|
|
|
|
btnCheckProgram->set_callback([&] {
|
|
|
|
cnc.check_program(pgm);
|
|
|
|
cnc.check_program(pgm);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
btnCheckProgram->set_tooltip("Check program");
|
|
|
|
btnCheckProgram->set_tooltip("Check program");
|
|
|
|
|
|
|
|
|
|
|
|
btnRunProgram = new Button(pgm_actions, "Run");
|
|
|
|
btnRunProgram = work_btns_holder->add<Button>("Run");
|
|
|
|
btnRunProgram->set_enabled(false);
|
|
|
|
// btnRunProgram->set_enabled(false);
|
|
|
|
btnRunProgram->set_callback([&] {
|
|
|
|
btnRunProgram->set_callback([&] {
|
|
|
|
cnc.run_program(pgm, "G" + std::to_string(cboOffset->selected_index() + 54));
|
|
|
|
cnc.run_program(pgm, "G" + std::to_string(cbo_work_offset->selected_index() + 54));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
btnRunProgram->set_tooltip("Execute program");
|
|
|
|
btnRunProgram->set_tooltip("Execute program");
|
|
|
|
|
|
|
|
|
|
|
@@ -262,8 +374,8 @@ public:
|
|
|
|
m_render_pass->set_cull_mode(RenderPass::CullMode::Disabled);
|
|
|
|
m_render_pass->set_cull_mode(RenderPass::CullMode::Disabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void refresh_offset() {
|
|
|
|
void refresh_offset() const {
|
|
|
|
auto offset_name = "G" + std::to_string(cboOffset->selected_index() + 54);
|
|
|
|
auto offset_name = "G" + std::to_string(cbo_work_offset->selected_index() + 54);
|
|
|
|
cnc.set_work_offset(offset_name);
|
|
|
|
cnc.set_work_offset(offset_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -313,7 +425,7 @@ public:
|
|
|
|
auto y = w->add<TextBox>(s.second);
|
|
|
|
auto y = w->add<TextBox>(s.second);
|
|
|
|
y->set_editable(true);
|
|
|
|
y->set_editable(true);
|
|
|
|
y->set_tooltip(desc);
|
|
|
|
y->set_tooltip(desc);
|
|
|
|
y->set_fixed_width(200);
|
|
|
|
y->set_fixed_width(150);
|
|
|
|
|
|
|
|
|
|
|
|
auto z = w->add<ToolButton>(FA_SAVE);
|
|
|
|
auto z = w->add<ToolButton>(FA_SAVE);
|
|
|
|
z->set_flags(Button::Flags::NormalButton); // no toggle, please
|
|
|
|
z->set_flags(Button::Flags::NormalButton); // no toggle, please
|
|
|
@@ -359,27 +471,25 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
grbl::realtime_status_report last_report;
|
|
|
|
grbl::realtime_status_report last_report;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
volatile bool machine_initialized = false;
|
|
|
|
|
|
|
|
|
|
|
|
void on_init_completed() override {
|
|
|
|
void on_init_completed() override {
|
|
|
|
fill_in_settings();
|
|
|
|
machine_initialized = true;
|
|
|
|
fill_in_parameters();
|
|
|
|
// need to do UI related things in UI thread
|
|
|
|
refresh_offset();
|
|
|
|
|
|
|
|
update_dro();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_realtime_status_report(grbl::realtime_status_report report) override {
|
|
|
|
void on_realtime_status_report(grbl::realtime_status_report report) override {
|
|
|
|
// if (report == last_report) return;
|
|
|
|
// if (report == last_report) return;
|
|
|
|
|
|
|
|
|
|
|
|
if (last_report.status != report.status) {
|
|
|
|
// if (last_report.status != report.status) {
|
|
|
|
lblStatus->clear();
|
|
|
|
txtStatus->set_value(grbl::status_to_string(cnc.get_status().status));
|
|
|
|
lblStatus->append(grbl::status_to_string(cnc.get_status().status));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lblSubstatus->clear();
|
|
|
|
|
|
|
|
if (cnc.get_status().status == grbl::machine_status::alarm) {
|
|
|
|
if (cnc.get_status().status == grbl::machine_status::alarm) {
|
|
|
|
lblSubstatus->append(grbl::alarm_to_string(last_alarm));
|
|
|
|
txtStatus->set_tooltip(grbl::alarm_to_string(last_alarm));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
lblSubstatus->append(cnc.get_status().sub_status);
|
|
|
|
txtStatus->set_tooltip(cnc.get_status().sub_status);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
update_dro();
|
|
|
|
update_dro();
|
|
|
|
last_report = report;
|
|
|
|
last_report = report;
|
|
|
@@ -396,6 +506,7 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_message(std::string message) override {
|
|
|
|
void on_message(std::string message) override {
|
|
|
|
|
|
|
|
txtMessage->set_value(message);
|
|
|
|
set_caption(message);
|
|
|
|
set_caption(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -512,7 +623,7 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (jog != new_jog) {
|
|
|
|
if (btn_keyboard_jog->pushed() && jog != new_jog) {
|
|
|
|
cnc.request_jog(new_jog);
|
|
|
|
cnc.request_jog(new_jog);
|
|
|
|
jog = new_jog;
|
|
|
|
jog = new_jog;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -555,6 +666,22 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void draw(NVGcontext *ctx) override {
|
|
|
|
|
|
|
|
// not pretty but need to do this in UI thread
|
|
|
|
|
|
|
|
if (machine_initialized) {
|
|
|
|
|
|
|
|
fill_in_settings();
|
|
|
|
|
|
|
|
fill_in_parameters();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
perform_layout();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refresh_offset();
|
|
|
|
|
|
|
|
update_dro();
|
|
|
|
|
|
|
|
machine_initialized = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget::draw(ctx);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void draw_contents() {
|
|
|
|
virtual void draw_contents() {
|
|
|
|
auto fb_size = framebuffer_size();
|
|
|
|
auto fb_size = framebuffer_size();
|
|
|
|
|
|
|
|
|
|
|
|