classicrocker883 / MRiscoCProUI

This is optimized firmware for Voxelab Aquila & Ender3 V2/S1 3D printers.
https://classicrocker883.github.io/
Other
79 stars 17 forks source link

Add to Edit Encoder Rate Multiplier in settings #37

Closed classicrocker883 closed 1 year ago

classicrocker883 commented 1 year ago

So I got this working! I hope someone can review this code and give me some pointers (pun intended)

Now, the code may not be A+ 100% whatever typically should be, but it works!


File lcd/e3v2/common/encoder.cpp line ~130

    #if ENABLED(ENCODER_RATE_MULTIPLIER)
      int* encRateA = &ui.enc_rateA;
      int32_t* encRateB = &ui.enc_rateB;
      int a = *encRateA;
      int32_t b = *encRateB;
      millis_t ms = millis();
      int32_t encoderMultiplier = 1;
------------------[after lines of code]---------------
               if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = a;
          else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC)  encoderMultiplier = b;


File lcd/marlinui.cpp line ~70

constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;

#if ENABLED(ENCODER_RATE_MULTIPLIER)
  int MarlinUI::enc_rateA;
  int32_t MarlinUI::enc_rateB;
#endif


File lcd/marlinui.cpp line ~200 after class MarlinUI {

public:

  #if ENABLED(ENCODER_RATE_MULTIPLIER)
    static int enc_rateA;
    static int32_t enc_rateB;
  #endif


File src/module/settings.cpp in the SettingsDataStruct {

  //
  // Encoder Rate
  //
  #if ENABLED(ENCODER_RATE_MULTIPLIER)
    int enc_rateA;
    int32_t enc_rateB;
  #endif
------------------[Many lines, goes with similar code]--------------
    #if ENABLED(ENCODER_RATE_MULTIPLIER)
      EEPROM_WRITE(ui.enc_rateA);
      EEPROM_WRITE(ui.enc_rateB);
    #endif
------------------[Many lines, goes with similar code]--------------
      #if ENABLED(ENCODER_RATE_MULTIPLIER)
        _FIELD_TEST(enc_rateA);
        EEPROM_READ(ui.enc_rateA);
        _FIELD_TEST(enc_rateB);
        EEPROM_READ(ui.enc_rateB);
      #endif
------------------[Many lines, goes with similar code]--------------
  #if ENABLED(ENCODER_RATE_MULTIPLIER)
    ui.enc_rateA = 550;
    ui.enc_rateB = 110;
  #endif


File dwin.cpp

void SetEncRate() { SetPIntOnClick( 0, 1000); }
-----------------[Many lines]--------------
    #if ENABLED(ENCODER_RATE_MULTIPLIER)
      EDIT_ITEM_F(ICON_ProbeMargin, "Enc Rate 1000x", onDrawPIntMenu, SetEncRate, &ui.enc_rateA);
      EDIT_ITEM_F(ICON_ProbeMargin, "Enc Rate 100x", onDrawPInt32Menu, SetEncRate, &ui.enc_rateB);
    #endif
-----------------[Include in a menu function]--------------
github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.