Replies: 2 comments
-
Your code is confusing: In most functions variable u8g2 is used as global variable, except for draw_m0_h_with_extra_blank, where u8g2 was passed as value (and as a consequence u8g2 is a local variable, shadowing the global variable u8g2).
to
and try again. If you really want to pass u8g2 to a function, then pass it as reference and use & instead:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks, I see the problem, I am not used to classes, (I used to program in fortran), that is why I make this kind of errors. Many thanks
Kind regards
John
The Netherlands
Verzonden vanuit Outlook<http://aka.ms/weboutlook>
…________________________________
Van: olikraus ***@***.***>
Verzonden: maandag 24 januari 2022 15:45
Aan: olikraus/u8g2 ***@***.***>
CC: John Nivard ***@***.***>; Author ***@***.***>
Onderwerp: Re: [olikraus/u8g2] Problem in example FontUsage (Discussion #1762)
Your code is confusing: In most function variable u8g2 is used as global variable, except for draw_m0_h_with_extra_blank, where u8g2 was passed as value (and as a consequence u8g2 is a local variable, shadowing the global variable u8g2).
My suggestion is to a avoid the argument u8g2, so just change
void draw_m0_h_with_extra_blank(U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2)
to
void draw_m0_h_with_extra_blank(void)
and try again.
If you really want to pass u8g2 to a function, then use & instead:
void draw_m0_h_with_extra_blank(U8G2_SSD1306_128X64_NONAME_F_SW_I2C &u8g2)
—
Reply to this email directly, view it on GitHub<#1762 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAZ57ZMPDF5WURNQUKG72BLUXVQZTANCNFSM5MVMPJ4A>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I try to put a part of the example FontUsage into a class. By trying to do that I discovered a problem
of interaction between the class and the main part of the code that is not correct. I left the origional code in the main module inplace and compare the result of the function void draw_m0_h_with_extra_blank(U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2) in the class with the function in the main code.
The execution of the code in the class is not working correctly (the background is not cleared, but when I execute the same function in the main code followed by a execution of thy function in the class withoud initialisation in between the result is correct is correct. When I execute the init inbetween the result is not correct (background not cleaned) It seems that the execution of the function in the main is leaving a state behind. But I am not able to find out what the problem is.
PSSD1306.initSSD1306();
delay(INFO_SCREEN_DELAY);
draw_m0_h_with_extra_blank(); // fontmode 1, h font with extra blank --> correct
PSSD1306.initSSD1306();
PSSD1306.draw_m0_h_with_extra_blank(u8g2); // fontmode 1, h font with extra blank --> not correct
PSSD1306.initSSD1306();
draw_m0_h_with_extra_blank(); // fontmode 1, h font with extra blank --> correct correct
//PSSD1306.initSSD1306();
PSSD1306.draw_m0_h_with_extra_blank(u8g2); // fontmode 1, h font with extra blank --> correct
#define INFO_SCREEN_DELAY 3000
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=/ 5, / data=/ 4, / reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
class PrintSSD1306U8G2 {
private:
uint8_t z = 127; // start value
uint32_t lcg_rnd(void) {
z = (uint8_t)((uint16_t)65 * (uint16_t)z + (uint16_t)17);
return (uint32_t)z;
}
public:
};
Beta Was this translation helpful? Give feedback.
All reactions