Skip to content

Commit

Permalink
basic values for main screen
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed May 25, 2024
1 parent fd75eb2 commit 7904bb4
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 58 deletions.
32 changes: 18 additions & 14 deletions main/display/cnc/grbl/screens/main_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 9 additions & 3 deletions main/display/cnc/grbl/screens/main_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
159 changes: 122 additions & 37 deletions main/target/cnc/grbl/esp3d_values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -93,6 +177,7 @@ bool ESP3DValues::intialize() {
std::string("idle"),
mainScreen::job_status_value_cb,
});

// file path
_values.push_back({
ESP3DValuesIndex::file_path,
Expand Down
18 changes: 14 additions & 4 deletions main/target/cnc/grbl/esp3d_values_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -53,6 +61,8 @@ enum class ESP3DValuesIndex : uint16_t {
job_progress,
job_duration,
job_id,
state,
state_comment,
unknown_index
};

Expand Down

0 comments on commit 7904bb4

Please sign in to comment.