Go Down

Topic: U8glib: Graphics Lib for LCDs and OLEDs (Read 59277 times) previous topic - next topic

momtot

Thank you Oliver for your care

and i am so sorry for my poring asking =(



this is the code i use and there is some pictures in attachments

Code: [Select]


#include "U8glib.h"



U8GLIB_KS0108_128 u8g(36, 40, 42, 44, 46, 48, 50, 52, 34, 22, 24, 28, 30 );


void draw(void) {
 
  u8g.setFont(u8g_font_unifont);
  u8g.setPrintPos(0, 20);

  u8g.print("Hello World!");
}

void setup(void) {
 
   u8g.setRot180();

}

void loop(void) {
 
 
  u8g.firstPage(); 
  do {
    draw();
  } while( u8g.nextPage() );
 

  delay(2000);
}


momtot

and that is the second picture

and thank you Oliver  :*

olikraus

Thanks for the pictures. Still it is difficult to follow the wires. In general, i think the wires are too long.
Another question: What happens if you change the variable pot. Can you see the pixels at the most left or most right position?

Oliver

momtot

Hi Oliver

yes i see some pixels but it about to disappear

i almost seeing these pixels

and i cant see it from a distance i can see it hardly when i am close enough to the lcd

and when i change the variable pot there is nothing happened ,the pixels not going lighter and not even being darker .

shall i change the variable pot?   :smiley-roll-sweat:

and thank you Oliver  you really a good person  :* 

olikraus

Hi

With the variable pot it should be possible to turn off and on all pixels. So probably something is miswired with your variable pot.

Oliver

Atvaark

Hallo Oliver,

Thanks a lot for U8glib, it's great when RAM is limited. Thanks to that, I've been able to use an ATtiny85 w/ Arduino core to control an OLED display.

FYI, I had to remove all *_hw_spi.c files from the library because some symbols were undefined at compile time (for instance SPDR). It seems logical because ATtiny85s don't have any direct hardware API support. Do you believe there is a way to exclude those files automatically? Maybe with the right #ifdef...

If that can help anyone else, here's what I had to do to get everything working (in addition to configuring an Arduino as ATtiny programmer):

  • set the ATtiny internal clock to 8 MHz

  • (OS X) install the latest CrossPack-AVR and replace /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr/bin/ld with /usr/local/CrossPack-AVR/avr/bin/ld (solves code relocation issues at the link stage)

  • remove all U8glib/utility/*_hw_spi.c files

  • use a small font because the 8 kB flash is easily exhausted

  • of course, use the lib constructor for software SPI



The next thing I would like to do is to use the USI provided by the ATtiny in order to implement hardware SPI, with the hope that it will both improve performance and reduce program size (currently, just creating the library instance takes 4 kB). I saw that there is some ATtiny support in the library, though not in Arduino context. Does it use USI or just software SPI? If hardware SPI is implemented, can you give me a few hints that would help me make the port from AVR to Arduino? I can then submit a patch.

Thanks again for your lib.

olikraus

Hi Atvaark

As far as i remember there is no HW support for the ATTiny. I would be glad to add support for ATTiny to U8glib, but i need to be able to compile for the ATTiny to check and test the modifications for ATTiny. Is there some extension for the Arduino IDE so that ATTiny appears as a board?

Oliver

Atvaark

I followed the instructions there and it works like a charm:
http://hlt.media.mit.edu/?p=1695

The Arduino IDE + core can be used to program the ATtiny using an Arduino as programmer.

olikraus

Somehow the link does not work :-(

Oliver

Atvaark

Strange… It did yesterday!

I hope I remember all the steps:
1. Download the ATtiny Arduino core at https://github.com/damellis/attiny
2. Create a 'hardware' directory in the Arduino directory (the one in the preferences of the Arduino IDE)
3. Copy the downloaded attiny directory (the one that contains boards.txt) to the new hardware directory
4. Relaunch the Arduino IDE, you should now see ATtiny items in the Tools > Boards menu
5. Open the ArduinoISP sketch from File > Examples
6. Upload the sketch to the Arduino (must be ATMega328-based!)
7. Connect the ATtiny to the Arduino : Arduino pin 10 --> ATtiny pin 1, 11 --> 5, 12 --> 6 and 13 --> 7
8. Add a 10 µF capacitor between the Arduino reset pin and ground (prevents the Arduino from resetting when uploading a sketch to the ATtiny)
9. In the Arduino IDE, choose your ATtiny chip from Tools > Board
10. In the Arduino IDE, choose 'Arduino as ISP' from Tools > Programmer
11. You can now upload a sketch directly from the IDE to the ATtiny

To set the ATTiny internal clock to 8 MHz (necessary for software SPI) :
1. Choose the 8 MHz variant from Tools > Board
2. Tools > Burn Bootloader (this won't actually burn any bootloader, just set internal ATtiny flags)

I hope I didn't forget anything.  :smiley-roll-sweat:

olikraus

Hi

I have fixed  the errors for ATTiny in the repository (snapshot attached). Thanks for pointing out this problem.
Currently there is no HW SPI support for ATTiny.  :(

Oliver

Atvaark

Hi Oliver,

Thanks for fixing the compilation issue!

Once I have understood the design of the U8glib abstraction layer, I'll try to implement hw SPI using the code posted by Nick on this thread:
http://forum.arduino.cc/index.php?topic=152432.0

olikraus


Atvaark

Hi Oliver,

I managed to add support for Arduino ATtiny85 hardware SPI. I tested it with an SSD1306 OLED controller (Adafruit 128x32) and it seems to be working OK. As predicted, it spares some CPU time and program memory.

The mod is attached. Feel free to include it into future releases, as is or modified.

Part of the credit goes to Nick Gammon, thanks to the code he posted there: http://forum.arduino.cc/index.php?topic=152432.0

Danke schön for your library.  :)

olikraus

Thanks. I have updated issue 190 to add your patch as part of the support for attiny.

Oliver

Go Up