Skip to content

Commit

Permalink
Merge pull request #740 from patryk3211/system-menu-jog-params
Browse files Browse the repository at this point in the history
Make jog parameter variables global
  • Loading branch information
Paciente8159 authored Aug 23, 2024
2 parents 3910576 + 4f14ff3 commit 0569d31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 8 additions & 8 deletions uCNC/src/modules/system_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

system_menu_t g_system_menu;

static float jog_distance, jog_feed;
float g_system_menu_jog_distance, g_system_menu_jog_feed;

static uint8_t system_menu_get_item_count(uint8_t menu_id);
static bool system_menu_action_settings_cmd(uint8_t action, system_menu_item_t *item);
Expand Down Expand Up @@ -77,8 +77,8 @@ DECL_MODULE(system_menu)
}
loaded = true;

jog_distance = 1.0f;
jog_feed = 100.0f;
g_system_menu_jog_distance = 1.0f;
g_system_menu_jog_feed = 100.0f;

// entry menu to startup screen
DECL_DYNAMIC_MENU(SYSTEM_MENU_ID_STARTUP, 0, system_menu_startup, NULL);
Expand Down Expand Up @@ -125,8 +125,8 @@ DECL_MODULE(system_menu)
#if (AXIS_COUNT > 5)
DECL_MENU_ENTRY(SYSTEM_MENU_ID_JOG, jogc, STR_JOG_AXIS("C"), NULL, system_menu_render_axis_position, NULL, system_menu_action_jog, "C");
#endif
DECL_MENU_VAR(SYSTEM_MENU_ID_JOG, jogdist, STR_JOG_DIST, &jog_distance, VAR_TYPE_FLOAT);
DECL_MENU_VAR(SYSTEM_MENU_ID_JOG, jogfeed, STR_JOG_FEED, &jog_feed, VAR_TYPE_FLOAT);
DECL_MENU_VAR(SYSTEM_MENU_ID_JOG, jogdist, STR_JOG_DIST, &g_system_menu_jog_distance, VAR_TYPE_FLOAT);
DECL_MENU_VAR(SYSTEM_MENU_ID_JOG, jogfeed, STR_JOG_FEED, &g_system_menu_jog_feed, VAR_TYPE_FLOAT);

// append settings menu
DECL_MENU(SYSTEM_MENU_ID_SETTINGS, SYSTEM_MENU_ID_MAIN_MENU, STR_SETTINGS);
Expand Down Expand Up @@ -768,10 +768,10 @@ static bool system_menu_action_jog(uint8_t action, system_menu_item_t *item)
switch (action)
{
case SYSTEM_MENU_ACTION_NEXT:
system_menu_flt_to_str(ptr, jog_distance);
system_menu_flt_to_str(ptr, g_system_menu_jog_distance);
break;
case SYSTEM_MENU_ACTION_PREV:
system_menu_flt_to_str(ptr, -jog_distance);
system_menu_flt_to_str(ptr, -g_system_menu_jog_distance);
break;
default:
// allow to propagate
Expand All @@ -781,7 +781,7 @@ static bool system_menu_action_jog(uint8_t action, system_menu_item_t *item)
while (*++ptr)
;
*ptr++ = 'F';
system_menu_flt_to_str(ptr, jog_feed);
system_menu_flt_to_str(ptr, g_system_menu_jog_feed);
while (*++ptr)
;
*ptr++ = '\r';
Expand Down
3 changes: 3 additions & 0 deletions uCNC/src/modules/system_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ extern "C"

extern system_menu_t g_system_menu;

extern float g_system_menu_jog_distance;
extern float g_system_menu_jog_feed;

DECL_MODULE(system_menu);
void system_menu_reset(void);
void system_menu_go_idle(void);
Expand Down

0 comments on commit 0569d31

Please sign in to comment.