olikraus / u8g2

U8glib library for monochrome displays, version 2
Other
5.15k stars 1.05k forks source link

Sharp Memory LS027B7DH01 Support #675

Closed vin7102 closed 6 years ago

vin7102 commented 6 years ago

Hi,

I have a Sharp Memory LS027B7DH01 and would really love to use u8g2 for this 2.7" display. Has anyone been able to use the u8g2 for this?

Thank you, Vince

olikraus commented 6 years ago

any datasheet available?

vin7102 commented 6 years ago

Hi Oliver,

Sure, here it is... LS027B7DH01_Rev_Jun_2010.pdf

vin7102 commented 6 years ago

Hey Oliver,

I see you have support for a similar Sharp LS013B7DH03 128X128 display and I was looking through the library to see if I can modify it to work with this new 400 x 240 size and have made many attempts but no luck with it. I am mainly in need of the HW version as like you pointed out a few months ago, using a bit banging spi along with my current hardware spi encoder doesnt work together.

Is it possible to modify your current 128x128 version to work with this display or is it far too complicated for a rookie like myself to work with?

Thanks again, Vince

olikraus commented 6 years ago

From what I see, the LS013B7DH03 and the LS027B7DH01 do not differ much, right? I assume it should not be a big problem to add support for your display.

What happens if your just use the existing LS013B7DH03 u8g2 device?

olikraus commented 6 years ago

Actually I can not even say, whether the LS013 works. At least I do not own this device.

vin7102 commented 6 years ago

I don’t own an LS013 either so I couldn’t say either. I did try your LS013 setup with the 027 and I just got a black screen with all pixels on. I just figured it needs some modifications to the U8g2 and I didn’t want to damage the display. However I was able to get the 027 to work with the adafruit library but I prefer to use U8g2 due to the hardware spi option as well as all of the custom fonts I created for U8g2. Since you think the 013 may possibly work, I’ll give it another try tonight and let you know the results. In the meantime, I’m going to try to order an 027 to test as well. Would you like me to send you one of each display with a breakout board for you to keep for testing and evaluating? I can at least do that.

Get Outlook for iOShttps://aka.ms/o0ukef


From: olikraus notifications@github.com Sent: Saturday, August 11, 2018 10:03 AM To: olikraus/u8g2 Cc: vin7102; Author Subject: Re: [olikraus/u8g2] Sharp Memory LS027B7DH01 Support (#675)

Actually I can not even say, whether the LS013 works. At least I do not own this device.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Folikraus%2Fu8g2%2Fissues%2F675%23issuecomment-412277155&data=02%7C01%7C%7C92d9d2b853f44f0b38ff08d5ff93263f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636695929818348416&sdata=kemWYlxkOLFH3Z0bBXaNcU%2BwiDYCJyeCNmFBxz2%2F%2FgE%3D&reserved=0, or mute the threadhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQJIyRXf3zcUAQyVaYEgKOBI5FFCui1eks5uPuQUgaJpZM4Vy0_Z&data=02%7C01%7C%7C92d9d2b853f44f0b38ff08d5ff93263f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636695929818348416&sdata=5QbOXVikfi4pibIu5DrHh2eqZIZLaf6CenueT7tsPbs%3D&reserved=0.

olikraus commented 6 years ago

I have added this constructor: U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display

olikraus commented 6 years ago

I have created a new beta release 2.23.16.

You can download the latest U8g2 beta release from here: https://github.com/olikraus/U8g2_Arduino/archive/master.zip

  1. Remove the existing U8g2_Arduino library (https://stackoverflow.com/questions/16752806/how-do-i-remove-a-library-from-the-arduino-environment)
  2. Install the U8g2_Arduino Zip file via Arduino IDE, add zip library menu (https://www.arduino.cc/en/Guide/Libraries).
vin7102 commented 6 years ago

Oliver,

Due to some other add-ons to this project, I switched to using SW spi and got successful output to this display using this constructor: U8G2_LS027B7DH01_400X240_F_4W_SW_SPI u8g2(U8G2_R0, 7, 11, 27, U8X8_PIN_NONE, 35);

Only 2 small issues: 1, The text orientation is correct but the screen height and width is swapped. It seems like the 400x240 needs to be swapped to 240x400.

  1. The screen background and text colors are inverted. Its like the background is BLACK and the text color is WHITE.

Here is the simple test .ino im using.

#include <Arduino.h>
#include <U8g2lib.h>
<SPI.h>
U8G2_LS027B7DH01_400X240_F_4W_SW_SPI u8g2(U8G2_R0, 7, 11, 27,  U8X8_PIN_NONE, 35);  

void setup(void) {
  u8g2.begin();

} 
void loop(void) {
  //u8g2.setDrawColor(0);
  u8g2.clearBuffer();                   // clear the internal memory
  u8g2.setFont(u8g2_font_logisoso58_tf);    // choose a suitable font
  u8g2.drawStr(0,100,"12567.64");   // write something to the internal memory
  u8g2.sendBuffer();                    // transfer internal memory to the display
  delay(1000);  
}

Can I make these two modifications in the Arduino code or do I need to modify the library?

Thanks Vin

olikraus commented 6 years ago

1.: You could use U8G2_R1 2.: Doesn't make sense. For a negative display it's just like this.

olikraus commented 6 years ago

Ok, back at my pc. Can you send and picture of the output of the HelloWorld.ino? .. based on the beta release from above?

vin7102 commented 6 years ago

Sure,
Attached are a couple screenshots of the black background using u8g2 HelloWorld posted above. Also posted is the same display using the Adafruit GFX library and SW spi. The background configures white by default.

You can also see on the HelloWorld u8g2 sketch that the orientation of characters is correct but the screen will only allow 240px horizontally (as you can see the #7 is cut off on the right. Its like the 240 x 400 is swapped). If I use R1 then I'll have to rotate all of my characters to use the display in this landscape orientation.

Thanks for your time bud! 20180821_220941939_ios 20180821_221037265_ios img_5491

olikraus commented 6 years ago

Did you enable 16 bit mode? https://github.com/olikraus/u8g2/blob/master/doc/faq.txt#L159 I think I forgot to mention this.

olikraus commented 6 years ago

any comments/feedback?

vin7102 commented 6 years ago

Sorry Oliver, I’ve been very ill the last few days. Going to try 16bit mode tomorrow and I’ll post the results.

Thank you!

On Aug 24, 2018, at 6:10 AM, olikraus notifications@github.com<mailto:notifications@github.com> wrote:

any comments/feedback?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Folikraus%2Fu8g2%2Fissues%2F675%23issuecomment-415715993&data=02%7C01%7C%7C208b9d27f42f46d61eae08d609a9e2e9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636707022587480087&sdata=uDdbkLC5p7ODCS8aSspwOlKIJ5juXc8oYIFrTGS%2FXss%3D&reserved=0, or mute the threadhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQJIyf3fISCUeUdcYk3u0Orjd67i6ZHXks5uT9EwgaJpZM4Vy0_Z&data=02%7C01%7C%7C208b9d27f42f46d61eae08d609a9e2e9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636707022587480087&sdata=KZe5NGp%2FH8d0Ori%2BZCGo7yaCE%2FneUl%2F5qQOpCkyxdFw%3D&reserved=0.

olikraus commented 6 years ago

No Problem. Moved the issue to the next milestone. Take your time...

vin7102 commented 6 years ago

Oliver, My apologies, Back to work here!

16bit works perfectly and the layout spans the entire display...

The only last issue is trying to get the background color of the entire screen to white.


void loop(void) {
  u8g2.setFontMode(0); 
  u8g2.setDrawColor(1);
  u8g2.setFont(u8g2_font_logisoso58_tf); 
  u8g2.drawStr(0,100,"1234567890"); 
  u8g2.sendBuffer();  
}

See the attachments: Setting DrawColor to 1 will give the Black background with White font color. (Pic #1) Setting DrawColor to 0 will give the White background boxes around each character with Black font color. (Pic#2)

20180825_131924396_ios 20180825_132144506_ios

olikraus commented 6 years ago

Setting DrawColor to 1 will give the Black background with White font color. (Pic #1) Setting DrawColor to 0 will give the White background boxes around each character with Black font color. (Pic#2)

It does not make sense for monochrome displays to associate 1 with white and 0 with black. The same display can be produced in a positive or negative variant and U8g2 will not know whether you have a positive or negative display.

For u8g2 the simple truth is: DrawColor 1 means a set pixel in the memory of the controller. Whether this appears white or black (or any other color) depends on the display variant.

Using the background color will draw the glyph background box. Indeed this does not make sense for an "t" font (last to last letter is a "t" in your example). Using the background color only makes sense for "m" and "h" fonts. This is discussed in the reference manual.

See here: https://github.com/olikraus/u8g2/wiki/u8g2reference#setfontmode

vin7102 commented 6 years ago

Thanks for the insight, I will have to make due with the black background with white text.

I appreciate your help, We can close this issue.

Regards, Vince

olikraus commented 6 years ago

:)

kw81634dr commented 2 years ago

For those who struggled, according to issue#941. there's a simple workaround by adding the following 3 lines to make this Sharp monochrome memory LCD display text with a white-looking background.

u8g2.setDrawColor(1); u8g2.drawBox(0,0,400,240); u8g2.setDrawColor(0); //in order to make content visable

for instance, modifying the sample code 'GraphicsTest.ino' from u8g2lib, a part of the code will be like:

void u8g2_prepare(void) { u8g2.setFont(u8g2_font_6x10_tf); u8g2.setFontRefHeightExtendedText(); u8g2.setDrawColor(1); //set drawing color to 1 for drawing canvas for Sharp Mono Memory LCD. u8g2.drawBox(0,0,400,240); //added for drawing white-looking canvas. u8g2.setFontPosTop(); u8g2.setFontDirection(0); u8g2.setDrawColor(0); //change from 1 to 0 to make content visable. }

so the actual LCD now looks like this (black pattern drawn on a white-looking background): IMG_1796

we could apply the same idea to display text, see the following modified part of 'Chinese.ino' sample code:

... do { u8g2.setDrawColor(1); //added for set pixel color to generate white canvas for Sharp LCD. u8g2.drawBox(0, 0, 400, 240); //added for drawing white canvas for Sharp LCD. u8g2.setDrawColor(0); //change from 1 to 0 to make content visable. u8g2.setCursor(10, 20); u8g2.print("Hello World!"); ... } while ( u8g2.nextPage() ); ...

IMG_1803

@olikraus has done an awesome job for contributing the u8g2 library, it's just this LCD somehow uses an inverse way to define the visible pixel, thank you Olikraus!