Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ZONESTAR_12864OLED No Longer Works in 2.1.x BUGFIX But Works in 2.0.7 Branch #27213

Open
1 task done
jutochoppa opened this issue Jun 26, 2024 · 11 comments · May be fixed by #27220
Open
1 task done

[BUG] ZONESTAR_12864OLED No Longer Works in 2.1.x BUGFIX But Works in 2.0.7 Branch #27213

jutochoppa opened this issue Jun 26, 2024 · 11 comments · May be fixed by #27220

Comments

@jutochoppa
Copy link

Did you test the latest bugfix-2.1.x code?

Yes, and the problem still exists.

Bug Description

I'm migrating to marlin 2.1.x bugfix branch from 2.0.7 lts and for some reason the display is not working for my Z6 ZM3E2 Board.
The display is black as if it has no power.

I have configured it successfully so everything else works. I just finished a print with it too.
If anyone could assist with this, I'd greatly appreciate the help. I've spent hours trying to figure this out.

Bug Timeline

No response

Expected behavior

Display to work/ show life

Actual behavior

No response

Steps to Reproduce

No response

Version of Marlin Firmware

2.1.x BUGFIX

Printer model

ZONESTAR Z6, ZM3E2 motherboard

Electronics

No response

LCD/Controller

ZONESTAR_12864OLED

Other add-ons

No response

Bed Leveling

UBL Bilinear mesh

Your Slicer

None

Host Software

None

Don't forget to include

  • A ZIP file containing your Configuration.h and Configuration_adv.h.

Additional information & file uploads

Configuration.zip
Configuration_adv.zip

@ellensp
Copy link
Contributor

ellensp commented Jun 27, 2024

the lcd pin out matches what is in https://github.com/ZONESTAR3D/source-code-for-3d-printer/blob/main/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h
So its probably not a simple pins issue

Please confirm this is your motherboard
https://ae01.alicdn.com/kf/Sba938ab4ed7f451b9c5613b1295cc3d5F/New-Arrival-32-bits-All-In-One-3D-Printer-Laser-engraving-Control-Board-5-Stepping-Motor.jpg_.webp

The pins also seem to match the silk screen on this image.

@thisiskeithb thisiskeithb changed the title [BUG] (bug summary) ZONESTAR_12864OLED No Longer Works in 2.1.x BUGFIX But Works in 2.0.7 Branch [BUG] ZONESTAR_12864OLED No Longer Works in 2.1.x BUGFIX But Works in 2.0.7 Branch Jun 27, 2024
@jutochoppa
Copy link
Author

jutochoppa commented Jun 27, 2024

the lcd pin out matches what is in https://github.com/ZONESTAR3D/source-code-for-3d-printer/blob/main/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h So its probably not a simple pins issue

Please confirm this is your motherboard https://ae01.alicdn.com/kf/Sba938ab4ed7f451b9c5613b1295cc3d5F/New-Arrival-32-bits-All-In-One-3D-Printer-Laser-engraving-Control-Board-5-Stepping-Motor.jpg_.webp

The pins also seem to match the silk screen on this image.

That is indeed the motherboard.
Here is a copy of my latest build log, If it matters: https://pastebin.com/j27MkkKb

And some layman detective work:

from Zonestars 2.0.7 source, inside ultralcd_DOGM.h, starting at line 140:


#elif EITHER(MKS_12864OLED, ZONESTAR_12864OLED)
  // MKS 128x64 (SH1106) OLED I2C LCD
  // - or -
  // Zonestar SH1106 OLED SPI LCD
  #define FORCE_SOFT_SPI
  #if ENABLED(ALTERNATIVE_LCD)
    #define U8G_CLASS U8GLIB_SH1106_128X64_2X                   // 4 stripes
  #else
    #ifdef __STM32F1__
	#define U8G_CLASS U8GLIB_SH1106_128X64_SW_SPI_HAL
	#else
    #define U8G_CLASS U8GLIB_SH1106_128X64                      // 8 stripes
    #endif    
  #endif

from Zonestars 2.0.7 source, "U8GLIB_SH1106_128X64_SW_SPI_HAL" Defined in HAL_LCD_class_defines.h:

#ifdef U8GLIB_SH1106
extern u8g_dev_t u8g_dev_sh1106_128x64_HAL_sw_spi;
class U8GLIB_SH1106_128X64_SW_SPI_HAL : public U8GLIB {
public:
  U8GLIB_SH1106_128X64_SW_SPI_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE)
  : U8GLIB(&u8g_dev_sh1106_128x64_HAL_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset)
  {  }
};
#endif

@jutochoppa
Copy link
Author

Just to note, I've tried marlinfirmware/[email protected]. 5 to version 0.5.4

@ellensp
Copy link
Contributor

ellensp commented Jun 27, 2024

I think your on to something here.
That code was definitely added changing the default behavior of a ZONESTAR_12864OLED_SSD1306 when on a stm32 (which your board is)

@jutochoppa
Copy link
Author

jutochoppa commented Jun 27, 2024

I have updated the HAL_LCD_class_defines.h to include the updated functions

#ifdef U8GLIB_SH1106 //Fixed
extern u8g_dev_t u8g_dev_sh1106_128x64_HAL_sw_spi;
class U8GLIB_SH1106_128X64_SW_SPI_HAL : public U8GLIB {
public:
  U8GLIB_SH1106_128X64_SW_SPI_HAL() : U8GLIB() { }
  U8GLIB_SH1106_128X64_SW_SPI_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) {init(sck, mosi, cs, reset); }
  void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) {
    U8GLIB::init(&u8g_dev_sh1106_128x64_HAL_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset);
  }
};
#endif

#ifdef U8GLIB_SSD1306 //Fixed
extern u8g_dev_t u8g_dev_ssd1306_128x64_HAL_sw_spi;
class U8GLIB_SSD1306_128X64_SW_SPI_HAL : public U8GLIB {
public:
  U8GLIB_SSD1306_128X64_SW_SPI_HAL() : U8GLIB() { }
  U8GLIB_SSD1306_128X64_SW_SPI_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) {init(sck, mosi, cs, reset); }
  void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) {
    U8GLIB::init(&u8g_dev_ssd1306_128x64_HAL_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset);
  }
};
#endif

I've also included u8g_dev_ssd1306_sh1106_128x64_SWSPI.cpp from Zonestars repo to /Marlin/src/lcd/dogm/u8g/u8g_dev_ssd1306_sh1106_128x64_SWSPI.cpp

I've also modified marlinui_DOGM.h from this:

#elif ENABLED(ZONESTAR_12864OLED_SSD1306)

  // Zonestar SSD1306 OLED SPI LCD

  #define FORCE_SOFT_SPI                                        // SW-SPI
  #if ENABLED(ALTERNATIVE_LCD)
    #define U8G_CLASS U8GLIB_SH1306_128X64_2X                   // 4 stripes
  #else
    #define U8G_CLASS U8GLIB_SH1306_128X64                      // 8 stripes
  #endif

#elif ANY(MKS_12864OLED, ZONESTAR_12864OLED)

  // MKS 128x64 (SH1106) OLED I2C LCD
  // - or -
  // Zonestar SH1106 OLED SPI LCD

  #define FORCE_SOFT_SPI                                        // SW-SPI
  #if ENABLED(ALTERNATIVE_LCD)
    #define U8G_CLASS U8GLIB_SH1106_128X64_2X                   // 4 stripes
  #else
    #define U8G_CLASS U8GLIB_SH1106_128X64                      // 8 stripes
  #endif

To this:

#elif ENABLED(ZONESTAR_12864OLED_SSD1306)
  // Zonestar SSD1306 OLED SPI LCD
  #define FORCE_SOFT_SPI                                        // SW-SPI
  #if ENABLED(ALTERNATIVE_LCD)
    #define U8G_CLASS U8GLIB_SH1306_128X64_2X                   // 4 stripes
  #else    
  #ifdef __STM32F1__
    #define U8G_CLASS U8GLIB_SSD1306_128X64_SW_SPI_HAL
  #else
    #define U8G_CLASS U8GLIB_SH1306_128X64						// 8 stripes
  #endif    
  #endif

#elif ANY(MKS_12864OLED, ZONESTAR_12864OLED)
  // MKS 128x64 (SH1106) OLED I2C LCD
  // - or -
  // Zonestar SH1106 OLED SPI LCD
  #define FORCE_SOFT_SPI
  #if ENABLED(ALTERNATIVE_LCD)
    #define U8G_CLASS U8GLIB_SH1106_128X64_2X                   // 4 stripes
  #else
    #ifdef __STM32F1__
	#define U8G_CLASS U8GLIB_SH1106_128X64_SW_SPI_HAL
	#else
    #define U8G_CLASS U8GLIB_SH1106_128X64                      // 8 stripes
    #endif    
  #endif

The display now works. there's a little glitch on the right side but it might be because its slightly cracked.

Please add this fix to the repo.

@ellensp
Copy link
Contributor

ellensp commented Jun 28, 2024

This 'fix' as is would break all other i2c SH1106 displays on any stm32 controllers so it needs to be made to play nice for everyone

@thisiskeithb thisiskeithb added T: Feature Request Features requested by users. Bug: Confirmed ! and removed Bug: Confirmed ! T: Feature Request Features requested by users. labels Jun 28, 2024
@ellensp
Copy link
Contributor

ellensp commented Jun 28, 2024

@ellensp ellensp linked a pull request Jun 28, 2024 that will close this issue
@ellensp
Copy link
Contributor

ellensp commented Jun 28, 2024

Pr created so everyone gets the fix

@thisiskeithb thisiskeithb linked a pull request Jun 28, 2024 that will close this issue
@jutochoppa
Copy link
Author

jutochoppa commented Jun 29, 2024

This 'fix' as is would break all other i2c SH1106 displays on any stm32 controllers so it needs to be made to play nice for everyone

Sorry. I'm a bit of an under-qualified dummy at this. I barley know how to use GitHub.

To get your fix working (which itself does) /// Marlin 2.1.x itself, I also had to

  1. Add thermistor_56.h and thermistor_57.h
  2. Update thermistors.h
  3. Add ZONESTAR_ZM3E2.py to /buildroot/share/PlatformIO/scripts/ZONESTAR_ZM3E2.py
  4. Add ZONESTAR_ZM3E2.ld to buildroot/share/PlatformIO/ldscripts
  5. Add build_flags.py to Marlin/arc/HAL/STM32F1 realized buildroot/share/PlatformIO/scripts/STM32F1_build_flags.py exists
  6. Modify stepper.cpp

Again, I am a professional dummy, so there are probably better solutions to the modifications made.
The rest of Zonestar's scripts are in their repo.

Zonestar Z6 fix.zip

@thisiskeithb
Copy link
Member

thisiskeithb commented Jun 29, 2024

While the LCD issue was a bug, the rest of this sounds like a Feature Request to port ZONESTAR Z6 / ZM3E2 support upstream and should be requested separately.

Edit: We already support the ZM3E2:

#define BOARD_ZONESTAR_ZM3E2 5062 // Zonestar ZM3E2 (STM32F103RC)


  1. Modify stepper.cpp

I created a diff of this file so it's easier to tell what changed:

diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp
index f5a9f6d..d8090d9 100644
--- a/Marlin/src/module/stepper.cpp
+++ b/Marlin/src/module/stepper.cpp
@@ -2948,6 +2948,29 @@ void Stepper::init() {
   // Init Microstepping Pins
   TERN_(HAS_MICROSTEPS, microstep_init());
 
+
+    #ifdef OPTION_MICROSTEP
+    #if(PIN_EXISTS(MS1) && PIN_EXISTS(MS2))
+      SET_OUTPUT(MS1_PIN);
+      SET_OUTPUT(MS2_PIN);
+	  #if (OPTION_MICROSTEP == 128)
+	    WRITE(MS1_PIN, LOW);
+	    WRITE(MS2_PIN, LOW);
+	  #elif(OPTION_MICROSTEP == 64)
+	    WRITE(MS1_PIN, LOW);
+	    WRITE(MS2_PIN, HIGH);
+	  #elif(OPTION_MICROSTEP == 32)
+	    WRITE(MS1_PIN, HIGH);
+	    WRITE(MS2_PIN, LOW);
+	  #else
+	    WRITE(MS1_PIN, HIGH);
+	    WRITE(MS2_PIN, HIGH);
+	  #endif
+    #else
+      #error "Need Micro step pins MS1 & MS2 when you endabled OPTION_MICROSTEP"
+    #endif
+  #endif
+
   // Init Dir Pins
   TERN_(HAS_X_DIR, X_DIR_INIT());
   TERN_(HAS_X2_DIR, X2_DIR_INIT());

It looks like they should really be using the "Custom Microstepping" options instead of this new OPTION_MICROSTEP option:

/**
* Custom Microstepping
* Override as-needed for your setup. Up to 3 MS pins are supported.
*/
//#define MICROSTEP1 LOW,LOW,LOW
//#define MICROSTEP2 HIGH,LOW,LOW
//#define MICROSTEP4 LOW,HIGH,LOW
//#define MICROSTEP8 HIGH,HIGH,LOW
//#define MICROSTEP16 LOW,LOW,HIGH
//#define MICROSTEP32 HIGH,LOW,HIGH

@jutochoppa
Copy link
Author

Okay, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants