evshar / u8glib

Automatically exported from code.google.com/p/u8glib
Other
0 stars 0 forks source link

Porting to ARM on MBED #304

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Setup u8g_arm.h and .cpp for mbed
2. setup main code to created object

What is the expected output? What do you see instead?
Should compile but receive error. 
Error: This declaration has no storage class or type specifier in "main.cpp", 
Line: 22, Col: 2
which is 
u8g_InitComFn((int)&u8g, &u8g_dev_ssd1306_128x64_hw_spi, u8g_com_hw_spi_fn);

Also getting 
Error: Declaration is incompatible with "std::uint8_t u8g_InitComFn(u8g_t *, 
u8g_dev_t *, u8g_com_fnptr)" (declared at <a href="#" 
onmousedown="mbed_doc_goto('/USBTester3/u8glib/u8g.h', '1113'); return 
false;">u8glib/u8g.h:1113</a>) in "main.cpp", Line: 22, Col: 2

Is there a CPP version of the ARM version of u8glib? I had to change u8g_arm.c 
to cpp since cpp is needed for mbed.h

What version of the product are you using? On what operating system?
mbed online compiler with u8glib 1.17

Please provide any additional information below.

Link to test code
https://github.com/FriedCircuits/mbed_arm_u8glib_test

I know mbed isn't supported but anything to point me in the right direction 
would be great. Once working I can most the final code for others on the mbed 
platform. 

Thanks

Original issue reported on code.google.com by blackspa...@gmail.com on 27 Dec 2014 at 7:49

GoogleCodeExporter commented 8 years ago
Oops ug8_InitComFn needs to be in main. I guess late night and looking at too 
many examples it didn't make it there. 

Now I am getting these

Error: Undefined symbol u8g_com_arduino_port_d_wr_fn (referred from 
u8g_dev_ili9325d_320x240.c.LPC11U24.o).
Error: Undefined symbol u8g_com_arduino_no_en_parallel_fn (referred from 
u8g_dev_sbn1661_122x32.c.LPC11U24.o).
Error: Undefined symbol u8g_com_arduino_sw_spi_fn (referred from 
u8g_dev_st7687_c144mvgd.c.LPC11U24.o).
Error: Undefined symbol u8g_com_arduino_st7920_custom_fn (referred from 
u8g_dev_st7920_128x64.c.LPC11U24.o).

Original comment by blackspa...@gmail.com on 27 Dec 2014 at 8:02

GoogleCodeExporter commented 8 years ago
I was able to comment out the lines referring to Arduino. 

Original comment by blackspa...@gmail.com on 27 Dec 2014 at 8:09

GoogleCodeExporter commented 8 years ago
There is a cpp wrapper for u8glib.
Usually the code tries to detect the target system by the some compiler 
switches. This will probably fail for an unsupported environment. So i think it 
is ok to remove the arduino specific code.

A nice tutorial is here: http://blog.bastelhalde.de/?p=759

Original comment by olikr...@gmail.com on 28 Dec 2014 at 8:10

GoogleCodeExporter commented 8 years ago
Thanks, that site came in handy as well as 
https://forum.pjrc.com/threads/24357-u8glib-now-has-an-ARM-variant

I finally got it to compile but display isn't working yet. Have to play with it 
some more 

I have a SeeedStudio Arch connected to a 128x64 OLED with SSD1306. I will be 
trying on the Pro and STM32 once I get it working. 

From what I have read Mbed will detect c or cpp and compile each properly. I 
guess you can mix c with cpp. 

Original comment by blackspa...@gmail.com on 28 Dec 2014 at 8:15

GoogleCodeExporter commented 8 years ago
Does the CPP wrapper allow use of the U8Glib as a object like the way its is 
called in Arduino?

Where is the wrapper, I haven't found it?

Original comment by blackspa...@gmail.com on 29 Dec 2014 at 7:18

GoogleCodeExporter commented 8 years ago
The wrapper is only used for the Arduino environment. It is not part of the ARM 
and AVR distribution, however it is here in the repo: 
https://code.google.com/p/u8glib/source/browse/#hg%2Fcppsrc

Additionally the wrapper class is derived from the Arduino "print" class. The 
"print" class is the standard way to print information on the serial (or any 
other) interface. The print class is not part of u8glib, but it is a standarde 
class of the Arduino environment.

All u8glib specific variables are located in a c structure (u8g_t). The C++ 
object is a class around the c structure:
{{{
class U8GLIB : public Print
{
  private:
    u8g_t u8g;
  ...
}}}

Original comment by olikr...@gmail.com on 29 Dec 2014 at 7:30

GoogleCodeExporter commented 8 years ago
Thanks, would it be possible to use printf in the ARM environment? 

Without the c++ wrapper, how can you print at the current position? 

I am porting Arduino code to ARM. 

Original comment by blackspa...@gmail.com on 29 Dec 2014 at 7:34

GoogleCodeExporter commented 8 years ago
Except for the c++ wrapper the code is identical for ARM and Arduino.
The C interface has u8g_DrawStr to draw a string at a given position. To 
convert a value, use sprintf or itoa or something similar. These functions 
should be part of your standardlibraries (string.h, stdlib.h)

Original comment by olikr...@gmail.com on 29 Dec 2014 at 8:38

GoogleCodeExporter commented 8 years ago
Sprintf does work.

How can I drawstr without specifying position. Just draw at the end pixel? Like 
print does.

Original comment by blackspa...@gmail.com on 29 Dec 2014 at 8:40

GoogleCodeExporter commented 8 years ago
DrawStr returns the x offset: You need a variable like
int x = 20;
Where 20 is your initial x position. For the first draw, use:
x += ...DrawStr(x,y,...)
For the next draw, again use
x += ...DrawStr(x,y,...)
Have a look at the wrapper code...

Original comment by olikr...@gmail.com on 29 Dec 2014 at 11:52

GoogleCodeExporter commented 8 years ago
the refered code is in line 90 of U8glib.h

Original comment by olikr...@gmail.com on 29 Dec 2014 at 11:55