Ocell oled 0.5" with LD7032 driver

Go To Last Post
19 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Everyone

 

I am a new user.

I bought a Ocell oled 0.5" with LD7032 driver and a atmega328p.

 

Can someone help me to program this screen?

If I write this program:

/*
  u8g2.h

  Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
  Copyright (c) 2016, olikraus@gmail.com
  All rights reserved.
  Redistribution and use in source and binary forms, with or without modification,
  are permitted provided that the following conditions are met:
  * Redistributions of source code must retain the above copyright notice, this list
    of conditions and the following disclaimer.

  * Redistributions in binary form must reproduce the above copyright notice, this
    list of conditions and the following disclaimer in the documentation and/or other
    materials provided with the distribution.
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#define  F_CPU 8000000
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <u8g2.h>
#include <spi.h>

u8g2_t u8g2;

u8g2_Setup_ld7032_60x32_1( u8g2, U8G2_R0,  u8x8_byte_4wire_sw_spi,  gpio_and_delay_cb); //u8g2_Setup_ld7032_60x32_2(u8g2, rotation, u8x8_byte_4wire_sw_spi, uC specific)

int main (){
_delay_ms(2000);
return 1;
}

 

 

Why the error is -Error expected ')' before '(' token -  in this line u8g2_Setup_ld7032_60x32_1( u8g2, U8G2_R0,  u8x8_byte_4wire_sw_spi,  gpio_and_delay_cb); //u8g2_Setup_ld7032_60x32_2(u8g2, rotation, u8x8_byte_4wire_sw_spi, uC specific) ? How can I solve it?

I can use other library instead of u8g2 for this screen? What?

 

What library or command do you suggest me for pin mapping in atmega?

 

 

I hope your answer

Thank you

 

 

Last Edited: Thu. Dec 7, 2017 - 02:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When I see odd errors like that, the problem is seldom on the line shown, look for the error above that line.

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And is your cpu frequency really 1.5MHz?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Jim

If I remove this line, then there is not any error in the code (it compile good).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Is any of the stuff in that line preprocessor #defines?

 

If it is, then it's probably an error in one of those ...

 

If, instead of cramming it all onto one line, you split it over multiple lines:

u8g2_Setup_ld7032_60x32_1
(
    u8g2,
    U8G2_R0,
    u8x8_byte_4wire_sw_spi,
    gpio_and_delay_cb
);

the compiler might be able to give you a more specific line number reference ... ?

 

EDIT

 

And the code you presented is copied directly from your editor, and pasted into the forum - isn't it?

ie, you haven't done any manual typing or editing?

 

 

How to properly post source code: http://www.avrfreaks.net/comment...

 

Last Edited: Thu. Dec 7, 2017 - 08:50 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you awneil

 

 

I split the code as you post. And I figure it out that the error is in U8G2_R0 argument.

This argument in u8g2 library, only appear once, and is in this way:

 

#define U8G2_R0 (&u8g2_cb_r0)

 

So, Yes awneil it is in define. How can I solve it?

I attach the u8g2.h   

Attachment(s): 

Last Edited: Thu. Dec 7, 2017 - 03:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, if you plug that into the line in question, you get:

 

u8g2_Setup_ld7032_60x32_1
(
    u8g2,
    (&u8g2_cb_r0),
    u8x8_byte_4wire_sw_spi,
    gpio_and_delay_cb
);

so how is u8g2_cb_r0 defined?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If I change the U8G2_R0 argument for &u8g2_cd_r0. The error is the same and in the same place.

 

u8g2_cd_ro is define as:

typedef struct u8g2_cb_struct u8g2_cb_t;

extern const u8g2_cb_t u8g2_cb_r0;

 

Last Edited: Thu. Dec 7, 2017 - 11:36 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe will be easier use u8x8.h instead of u8g2.h. Actually I only want show text in the screen, and the u8x8 is for only text.

 

Then I have to use this:

void u8x8_Setup(u8x8_t *u8x8, u8x8_msg_cb display_cb, u8x8_msg_cb cad_cb, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);

uint8_t u8x8_d_ld7032_60x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);

I don't know what I have to write in  display_cd and cad_cb write. How I have to do it?

I attach the u8x8.h

 

Attachment(s): 

Last Edited: Thu. Dec 7, 2017 - 11:48 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

OK - so you have changed the original post!

 

angry

 

The error is now clear:

u8g2_t u8g2;

u8g2_Setup_ld7032_60x32_1( u8g2, U8G2_R0,  u8x8_byte_4wire_sw_spi,  gpio_and_delay_cb); //u8g2_Setup_ld7032_60x32_2(u8g2, rotation, u8x8_byte_4wire_sw_spi, uC specific)

int main (){
_delay_ms(2000);
return 1;
}

You are calling u8g2_Setup_ld7032_60x32_1() outside main() - in fact, outside any function!

 

Also, what are you doing returning from main() ?!

 

surprise

Last Edited: Thu. Dec 7, 2017 - 11:51 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I wrote outside of main because I undestood the Setup as Startup ( a think that only have to do once when you turn on the device).

 

Now I wrote it:

 

u8g2_t u8g2;


int main (){
u8g2_Setup_ld7032_60x32_1
( 
u8g2, U8G2_R0,  
u8x8_byte_4wire_sw_spi,  
gpio_and_delay_cb
); //u8g2_Setup_ld7032_60x32_2(u8g2, rotation, u8x8_byte_4wire_sw_spi, uC specific)

_delay_ms(2000);

}

I obtain this error : undefined reference to `u8g2_Setup_ld7032_60x32_1' in line u8g2_Setup_ld7032_60x32_1. How I have to solve it?

 

 

Thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Navidulce wrote:
Yes, I wrote outside of main because I undestood the Setup as Startup ( a think that only have to do once when you turn on the device).

That's not the way 'C' programs work!

 

You can't have any executable code outside a function.

 

main() is where all your code must go start - the top of main is where your program starts.

 

So, typically, it will look something like this:

int main( void )
{
  do_some_setup_stuff();
  do_other_setup_stuff();
  do_final_setup_stuff();

  while( 1 )
  {
    // main, running loop is here
  }
}

 

This is textbook stuff.

 

Perhaps you are being confused by Arduino, where main() is "hidden", and you provide setup() and loop() functions ... ?

 

I obtain this error : undefined reference to `u8g2_Setup_ld7032_60x32_1' in line u8g2_Setup_ld7032_60x32_1. How I have to solve it?

Well, if something is un-defined the solution should be obvious - you need to define it!

 

 

EDIT

 

"main() is where all your code must go" really doesn't describe it well!

 

changed to: "main() is where all your code must start"

Last Edited: Thu. Dec 7, 2017 - 01:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
Arduino, where main() is "hidden", and you provide setup() and loop() functions ... ?

See: https://forum.arduino.cc/index.p...

 

It even tells you where main() is "hidden"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps you are being confused by Arduino, where main() is "hidden", and you provide setup() and loop() functions ... ? Yes, I was confused, thank you very much awneil.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What library and/or command do you suggest me for SPI pin mapping in atmega?  

 

I suppose, what  pin mapping is decalre input or output (thinking in if the signal dirrection, from MCU to the buffer of OCELL) and then match every pin which every sides of wire is hook up?

 

For examle in  atmega 328p 28-pin MLF:

as MOSI ( PB3 )= 13,  and it is hook up in pin 5 of  buffer 74HC405D, so a have to do something like:

 

InstrucionForMapping(Output,13,5);

 

Is It right?

 

Thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It sounds like you should really be using an Arduino?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It sounds like you should really be using an Arduino?

 

Arduinos have a pre-loaded atmel MCU with the Arduino Bootloader . So,  I thought  that  Arduino is almost the same of AVR with some SW modification, isn't it?

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My main is :

int __attribute__ ((noinline)) main (void){
	u8g2_Setup_ld7032_60x32_1
	(
	&u8g2
	,
	(&u8g2_cb_r0)
	,
	u8x8_byte_4wire_sw_spi,
	gpio_and_delay_cb
	); //u8g2_Setup_ld7032_60x32_2(u8g2, rotation, u8x8_byte_4wire_sw_spi, uC specific)

}

I have this error:

Error expected expression before ')' token in this line:

(&u8g2_cb_r0)

How can I fix it?

 

Thank you

 

 

Last Edited: Thu. Dec 7, 2017 - 04:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi js

 

I edited the 1st page of this post changing the #define F_CPU 1500000 to  #define F_CPU 8000000 because I didn't know if in this blog was allow to speak of USBasp (now I searched  and I saw some post comented USBasp).  When I read your coment for the 1st time I thought that maybe would not be good to comment -That users can program the MCU without demand it to Atmel company-.

 

And is your cpu frequency really 1.5MHz? 

when I tried to upload the code to  the m328p  MCU, I saw a line which with -Set the SCK 1500 000 Hz in terminal of AVRDUDE.

I wrote #define F_CPU 1500000 because  the AVRDUDE with USBasp programmer the màx freq. in is 1.5MHz (See the picture  I attached).

 

 

Sorry for edit the post.

 

 

Attachment(s):