diff --git a/main/display/cnc/grbl/screens/main_screen.cpp b/main/display/cnc/grbl/screens/main_screen.cpp index 442b1a71..036c27cd 100644 --- a/main/display/cnc/grbl/screens/main_screen.cpp +++ b/main/display/cnc/grbl/screens/main_screen.cpp @@ -84,23 +84,27 @@ lv_obj_t *main_btn_stop = nullptr; lv_obj_t *main_btn_resume = nullptr; lv_obj_t *main_label_progression_area = nullptr; lv_obj_t *main_btn_menu = nullptr; -std::string progression_area_str = "Progress 10/122222\nmygcode.nc"; +std::string progression_area_str = ""; +bool display_machine_position = true; /********************** * GLOBAL FUNCTIONS **********************/ -// bool position_value_cb(ESP3DValuesIndex index, const char *value, -// ESP3DValuesCbAction action) { -// if (action == ESP3DValuesCbAction::Update) { -// if (esp3dTftui.get_current_screen() == ESP3DScreenType::main) { -// main_display_positions(); -// } else { -// positionsScreen::callback(index, value, action); -// } -// } -// return true; -// } +bool position_values(ESP3DValuesIndex index, const char *value, + ESP3DValuesCbAction action) { + return true; + +} +bool state_value_cb(ESP3DValuesIndex index, const char *value, + ESP3DValuesCbAction action) { + return true; +} + +bool state_comment_value_cb(ESP3DValuesIndex index, const char *value, + ESP3DValuesCbAction action) { + return true; +} bool job_status_value_cb(ESP3DValuesIndex index, const char *value, ESP3DValuesCbAction action) { if (action == ESP3DValuesCbAction::Update) { @@ -449,7 +453,7 @@ void create() { "Z: 0.0000", LV_HOR_RES / 3, 60); main_btn_position_a = symbolButton::create(ui_positions_buttons_container, "A: 0.0000", LV_HOR_RES / 3, 60); - //lv_obj_add_flag(main_btn_position_y, LV_OBJ_FLAG_HIDDEN); + // lv_obj_add_flag(main_btn_position_y, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(main_btn_position_z, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(main_btn_position_a, LV_OBJ_FLAG_HIDDEN); // Create button for switch positions @@ -487,7 +491,7 @@ void create() { // Create button and label for abort main_btn_abort = symbolButton::create(ui_middle_container, LV_SYMBOL_POWER); - // lv_obj_add_flag(main_btn_abort, LV_OBJ_FLAG_HIDDEN); + // lv_obj_add_flag(main_btn_abort, LV_OBJ_FLAG_HIDDEN); // Create progression area for middle container main_label_progression_area = lv_label_create(ui_middle_container); diff --git a/main/display/cnc/grbl/screens/main_screen.h b/main/display/cnc/grbl/screens/main_screen.h index 2d68064b..b1245b9b 100644 --- a/main/display/cnc/grbl/screens/main_screen.h +++ b/main/display/cnc/grbl/screens/main_screen.h @@ -23,8 +23,14 @@ #include "esp3d_values.h" namespace mainScreen { -extern void create(); -extern bool job_status_value_cb(ESP3DValuesIndex index, const char *value, - ESP3DValuesCbAction action); +void create(); +bool job_status_value_cb(ESP3DValuesIndex index, const char *value, + ESP3DValuesCbAction action); +bool position_values(ESP3DValuesIndex index, const char *value, + ESP3DValuesCbAction action); +bool state_value_cb(ESP3DValuesIndex index, const char *value, + ESP3DValuesCbAction action); +bool state_comment_value_cb(ESP3DValuesIndex index, const char *value, + ESP3DValuesCbAction action); } // namespace mainScreen diff --git a/main/target/cnc/grbl/esp3d_values.cpp b/main/target/cnc/grbl/esp3d_values.cpp index 7493bc9b..05e1b6ee 100644 --- a/main/target/cnc/grbl/esp3d_values.cpp +++ b/main/target/cnc/grbl/esp3d_values.cpp @@ -46,44 +46,128 @@ bool ESP3DValues::intialize() { nullptr, }); - - // // x position - - // _values.push_back({ - // ESP3DValuesIndex::position_x, - // ESP3DValuesType::float_t, - // 4, // precision - // std::string("?"), - // mainScreen::position_value_cb, - // }); - - // // y position - // _values.push_back({ - // ESP3DValuesIndex::position_y, - // ESP3DValuesType::float_t, - // 4, // precision - // std::string("?"), - // mainScreen::position_value_cb, - // }); - - // // z position - // _values.push_back({ - // ESP3DValuesIndex::position_z, - // ESP3DValuesType::float_t, - // 4, // precision - // std::string("?"), - // mainScreen::position_value_cb, - // }); - - // // a position - // _values.push_back({ - // ESP3DValuesIndex::position_a, - // ESP3DValuesType::float_t, - // 4, // precision - // std::string("?"), - // mainScreen::position_value_cb, - // }); + // x machine position + _values.push_back({ + ESP3DValuesIndex::m_position_x, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + mainScreen::position_values, + }); + + // y machine position + _values.push_back({ + ESP3DValuesIndex::m_position_y, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + // z machine position + _values.push_back({ + ESP3DValuesIndex::m_position_z, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + + // a machine position + _values.push_back({ + ESP3DValuesIndex::m_position_a, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + + // b machine position + _values.push_back({ + ESP3DValuesIndex::m_position_b, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + + // c machine position + + _values.push_back({ + ESP3DValuesIndex::m_position_c, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + + // x work position + _values.push_back({ + ESP3DValuesIndex::w_position_x, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + + // y work position + _values.push_back({ + ESP3DValuesIndex::w_position_y, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + + // z work position + _values.push_back({ + ESP3DValuesIndex::w_position_z, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + + // a work position + _values.push_back({ + ESP3DValuesIndex::w_position_a, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + + // b work position + _values.push_back({ + ESP3DValuesIndex::w_position_b, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + + // c work position + _values.push_back({ + ESP3DValuesIndex::w_position_c, + ESP3DValuesType::float_t, + 4, // precision + std::string("?"), + nullptr, + }); + + // state + _values.push_back({ESP3DValuesIndex::state, ESP3DValuesType::string_t, + 10, // precision + std::string("idle"), mainScreen::state_value_cb}); + + // state comment + _values.push_back({ + ESP3DValuesIndex::state_comment, + ESP3DValuesType::string_t, + 100, // precision + std::string(""), + mainScreen::state_comment_value_cb, + }); // print status _values.push_back({ @@ -93,6 +177,7 @@ bool ESP3DValues::intialize() { std::string("idle"), mainScreen::job_status_value_cb, }); + // file path _values.push_back({ ESP3DValuesIndex::file_path, diff --git a/main/target/cnc/grbl/esp3d_values_list.h b/main/target/cnc/grbl/esp3d_values_list.h index a4ccdeeb..85b8e288 100644 --- a/main/target/cnc/grbl/esp3d_values_list.h +++ b/main/target/cnc/grbl/esp3d_values_list.h @@ -41,10 +41,18 @@ extern "C" { enum class ESP3DValuesIndex : uint16_t { status_bar_label, current_ip, - position_x, - position_y, - position_z, - position_a, + m_position_x, + m_position_y, + m_position_z, + m_position_a, + m_position_b, + m_position_c, + w_position_x, + w_position_y, + w_position_z, + w_position_a, + w_position_b, + w_position_c, job_status, file_path, file_name, @@ -53,6 +61,8 @@ enum class ESP3DValuesIndex : uint16_t { job_progress, job_duration, job_id, + state, + state_comment, unknown_index };