Closed hhuter closed 1 year ago
he did not implement the "print()" functionality directly,
Yes, the code is reused. Otherwise the same code would exist twice in the memory of your controller, wasting flash memory.
but he redirected the arduinos print() function in some way, which my C++ knowledge does not understand.
Not much C++ magic: I just derive from the Arduino print class (if the code is compiled under Arduino environment):
class U8G2LOG
#ifdef ARDUINO
: public Print
Some explanation would help me to enhance the my C++ language knowledge better, and better, and ...
Not sure what other explanation I can give (class inheritance should be explained better in some text books), but I could commend your code a little bit:
The member class initalization expects arguments in inside () not inside {}, so it should be
u8g2(rotation)
instead of
u8g2{rotation}
Below
MYDISP MyDisp {U8G2_R0}; // ... or ctor with argument
Is the same problem: You need to use () instead of {}. In fact using {} will call a not defined default constructor of your class.
There might be another problem: Arduino is not C++. Arduino modifies your C++ so that some things which are required in C++ are not required any more. On the other side some C++ coding styles my not work any more. This not documented, only my personal experience, but it makes working with classes very hard under Arduino.
I personally do not see an issue inside u8g2 here, instead your code looks incorrect to me.
thx oli kraus i will try your suggestions: .. "change { } enclosurements by ( ) "
... and i will give you the my feedback then.
You, Oli Kraus, you did NOT just simple try and experience the my simplest example codes. You did not really just simply selftrying und experiencing the my code. No compilation error. What is your answer worth - without selfexperiencing the my simple "10 liner" code: -> There is a "logical error" somewhere around - and it is maybe in your library coding?
You suggested: ( ) <--vs--> { } ... My helping C++ learning resource about inheritance and initialisation was this: https://www.learncpp.com/cpp-tutorial/constructors-and-initialization-of-derived-classes/
and no: your speedguessing tip: { } do change it by ( ) did not my simple my code to work.
BUT:
Big THX
PS: what I really want to message to you oli: = = = = = = = = = = = = = = = = = = = = = = is this: ... is Serial monitor defuncting just by C++ using your library?
Hi There
I am a little bit confused by your last msg, anyhow:
There is a "logical error" somewhere around - and it is maybe in your library coding?
The mentioned curly brackets in your code are wrong. No need to look further here. They need to be replaced. Only once this is fixed, any further debugging would make sense.
And yes, there is a high probability that my lib code still contains bugs.
Oliver
Hello Oliver,
No, not really: I changed the curly braces against your suggested round braces: --> But the Arduino binary (the "hex-file") are exactly and bitident the same, both: curly (initialisation-list) and rounded (parameter list) compiles to exactly the same nonworking code (as given in the hex-file ) (And clearly as directly uploaded to the Arduino device, it shows the same "nonbehaviour")
You wrote "There might be another problem: Arduino is not C++. Arduino modifies your C++ so that some things which are required in C++ are not required any more. On the other side some C++ coding styles my not work any more. This not documented, only my personal experience, but it makes working with classes very hard under Arduino."
"Arduino is not C++": yes, somehow yes, for example, I see this
But still I think it is a more or less a transparent GCC toolchain with a more or less "pure" C++ ?
Thx a lot for your guidance and the hints. Have a good week. Johannes
But still I think it is a more or less a transparent GCC toolchain with a more or less "pure" C++ ?
Arduino applies a preprocessing step. The generted cpp file should be there in the build folder.
thx oliver,
i will stay on this your debugging hint. sometimes the next days or weeks. or so. it is not an urgent problem. and - it is just a beautifing elegance problem.
liebe grüsse nach deutschland von johannes aus österreich
! is there any other c++ gcc arduino nerd here? hello world ! where are you ?
My problems arises, when I derive a class from U8G2LOG
Explanation:
First, this works great and exactly as expected:
Next: with the above given 'template' I want to have
Both the above codes should behave exactly identical!
But my 2nd approach:
I already checked the Oli Kraus's source code:
Some explanation would help me to enhance the my C++ language knowledge better, and better, and ...
Thank you very much Johannes