Skip to content

Commit

Permalink
odometer: Fix storing of axis and filament values
Browse files Browse the repository at this point in the history
  • Loading branch information
espr14 authored and MistrKernnunos committed Sep 1, 2021
1 parent 17031ba commit 42fa2b0
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 24 deletions.
4 changes: 4 additions & 0 deletions lib/Marlin/Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ GcodeSuite gcode;

#include "../Marlin.h" // for idle() and suspend_auto_report

#include "odometer.hpp"

millis_t GcodeSuite::previous_move_ms;

// Relative motion mode for each logical axis
Expand Down Expand Up @@ -121,6 +123,8 @@ void GcodeSuite::get_destination_from_command() {
}
else
destination[i] = current_position[i];

Odometer_s::instance().add_value(i, destination[i] - current_position[i]);
}

#if ENABLED(POWER_LOSS_RECOVERY) && !PIN_EXISTS(POWER_LOSS)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/screen_menu_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#ifdef _DEBUG
using Screen = ScreenMenu<EHeader::Off, EFooter::On, HelpLines_None, MI_RETURN, MI_STATISTIC_disabled, MI_SYS_INFO, MI_FAIL_STAT_disabled,
MI_SUPPORT_disabled, MI_SENSOR_INFO, MI_VERSION_INFO, MI_ODOMETR>;
MI_SUPPORT_disabled, MI_SENSOR_INFO, MI_VERSION_INFO, MI_ODOMETER>;
#else
using Screen = ScreenMenu<EHeader::Off, EFooter::On, HelpLines_None, MI_RETURN, MI_SYS_INFO, MI_SENSOR_INFO, MI_VERSION_INFO, MI_ODOMETR>;
using Screen = ScreenMenu<EHeader::Off, EFooter::On, HelpLines_None, MI_RETURN, MI_SYS_INFO, MI_SENSOR_INFO, MI_VERSION_INFO, MI_ODOMETER>;
#endif //_DEBUG

//cannot move it to header - 'ScreenMenuInfo' has a field 'ScreenMenuInfo::<anonymous>' whose type uses the anonymous namespace [-Wsubobject-linkage]
Expand Down
2 changes: 1 addition & 1 deletion src/gui/screen_menu_version_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ScreenMenuVersionInfo::ScreenMenuVersionInfo()
serial_numbers);
}

// this MakeRAM is safe - version_info_str is allocated in RAM for the lifetime of ths
// this MakeRAM is safe - version_info_str is allocated in RAM for the lifetime of this
help.SetText(string_view_utf8::MakeRAM((const uint8_t *)version_info_str.data()));
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/screen_printing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "wui_api.h"
#include "../lang/format_print_will_end.hpp"
#include "window_dlg_popup.hpp"
#include "odometer.hpp"

#ifdef DEBUG_FSENSOR_IN_HEADER
#include "filament_sensor.hpp"
Expand Down Expand Up @@ -553,4 +554,6 @@ void screen_printing_data_t::change_print_state() {
set_tune_icon_and_label();
set_stop_icon_and_label();
}
if (st == printing_state_t::PRINTED || st == printing_state_t::PAUSED)
Odometer_s::instance().force_to_eeprom();
}
2 changes: 2 additions & 0 deletions src/gui/screen_printing_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "i18n.h"
#include "ScreenHandler.hpp"
#include "screen_menus.hpp"
#include "odometer.hpp"

//octo icon
static point_ui16_t pt_ico() { return icon_meas(resource_ptr(IDR_PNG_serial_printing)); }
Expand Down Expand Up @@ -62,6 +63,7 @@ void screen_printing_serial_data_t::windowEvent(EventLock /*has private ctor*/,
marlin_gcode("M104 S0 D0"); /// set temperatures to zero
marlin_gcode("M140 S0"); /// set temperatures to zero
marlin_gcode("M107"); /// print fan off.
Odometer_s::instance().force_to_eeprom();
return;
}
if (connection == connection_state_t::disconnected) {
Expand Down
20 changes: 10 additions & 10 deletions src/guiapi/include/MItem_menus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ class MI_SENSOR_INFO : public WI_LABEL_t {
virtual void click(IWindowMenu &window_menu) override;
};

class MI_ODOMETER : public WI_LABEL_t {
static constexpr const char *const label = N_("Odometer");

public:
MI_ODOMETER();

protected:
virtual void click(IWindowMenu &window_menu) override;
};

class MI_FILAMENT : public WI_LABEL_t {
static constexpr const char *const label = N_("Filament");

Expand Down Expand Up @@ -205,13 +215,3 @@ class MI_EXPERIMENTAL_SETTINGS : public WI_LABEL_t {
protected:
virtual void click(IWindowMenu &window_menu) override;
};

class MI_ODOMETR : public WI_LABEL_t {
static constexpr const char *const label = N_("Odometr");

public:
MI_ODOMETR();

protected:
virtual void click(IWindowMenu &window_menu) override;
};
17 changes: 9 additions & 8 deletions src/guiapi/src/MItem_menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ void MI_SENSOR_INFO::click(IWindowMenu & /*window_menu*/) {
Screens::Access()->Open(GetScreenMenuSensorInfo);
}

/*****************************************************************************/
MI_ODOMETER::MI_ODOMETER()
: WI_LABEL_t(_(label), 0, is_enabled_t::yes, is_hidden_t::no) {
}

void MI_ODOMETER::click(IWindowMenu & /*window_menu*/) {
Screens::Access()->Open(GetScreenMenuOdometer);
}

/*****************************************************************************/
//MI_FILAMENT
MI_FILAMENT::MI_FILAMENT()
Expand Down Expand Up @@ -209,11 +218,3 @@ MI_EXPERIMENTAL_SETTINGS::MI_EXPERIMENTAL_SETTINGS()
void MI_EXPERIMENTAL_SETTINGS::click(IWindowMenu & /*window_menu*/) {
Screens::Access()->Open(GetScreenMenuExperimentalSettings);
}
/*****************************************************************************/
// MI_ODOMETER
MI_ODOMETR::MI_ODOMETR()
: WI_LABEL_t(_(label), 0, is_enabled_t::yes, is_hidden_t::no) {
}
void MI_ODOMETR::click(IWindowMenu &window_menu) {
Screens::Access()->Open(GetScreenMenuOdometer);
}
4 changes: 2 additions & 2 deletions src/guiapi/src/MItem_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ void I_MI_Filament::click_at(FILAMENT_t filament_index) {
}

MI_FILAMENT_SENSOR_STATE::MI_FILAMENT_SENSOR_STATE()
: WI_SWITCH_0_1_NA_t(get_state(), _(label), 0, is_enabled_t::no, is_hidden_t::no) {
: WI_SWITCH_0_1_NA_t(get_state(), _(label), IDR_NULL, is_enabled_t::no, is_hidden_t::no) {
}

MI_FILAMENT_SENSOR_STATE::state_t MI_FILAMENT_SENSOR_STATE::get_state() {
Expand All @@ -460,7 +460,7 @@ bool MI_FILAMENT_SENSOR_STATE::StateChanged() {
}

MI_MINDA::MI_MINDA()
: WI_SWITCH_0_1_NA_t(get_state(), _(label), 0, is_enabled_t::no, is_hidden_t::no) {
: WI_SWITCH_0_1_NA_t(get_state(), _(label), IDR_NULL, is_enabled_t::no, is_hidden_t::no) {
}

MI_MINDA::state_t MI_MINDA::get_state() {
Expand Down
2 changes: 1 addition & 1 deletion src/guiapi/src/window_numb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ window_numb_t::window_numb_t(window_t *parent, Rect16 rect, float value, const c
, color_text(GuiDefaults::ColorText)
, font(GuiDefaults::Font)
, value(value)
, format("%.0f")
, format(frmt == nullptr ? "%.0f" : frmt)
, padding(GuiDefaults::Padding) {
PrintAsFloat();
}
Expand Down
1 change: 1 addition & 0 deletions src/lang/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "translator.hpp"

/// Translate the surrounded text. Does not alter the content. Provides proper translation at the output.
/// If translation not available, returns the same text.
#define _(String) gettext(String)

/// This just marks the text to be translated (extracted by gettext tools). Does not alter its content.
Expand Down

0 comments on commit 42fa2b0

Please sign in to comment.