You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you helped me solving the issue with me master/slave display by suggesting following:
u8g2_tu8g2l;
u8g2_tu8g2r;
u8g2_Setup_s1d15300_100x32i_f(&u8g2l, U8G2_R0, u8x8_byte_4wire_sw_spi,u8x8_arm_linux_gpio_and_delay);
init_spi_sw(&u8g2l, GPIO_CHIP_NUM, PIN_DISPA0, U8X8_PIN_NONE,PIN_DISPMOSI, PIN_DISPCLK, PIN_DISPCS, 0);
u8g2_Setup_s1d15300_97x32_1(&u8g2r, U8G2_R0, u8x8_byte_4wire_sw_spi,u8x8_arm_linux_gpio_and_delay);
init_spi_sw(&u8g2r, GPIO_CHIP_NUM, PIN_DISPA02, U8X8_PIN_NONE,PIN_DISPMOSI2, PIN_DISPCLK2, PIN_DISPCS2, 0);
u8g2_InitDisplay(&u8g2l);
u8g2_ClearDisplay(&u8g2l);
u8g2_SetPowerSave(&u8g2l, 0);
// Get GPIO file descriptorsuser_data_t*user_data_r=u8g2_GetUserPtr(&u8g2r);
user_data_t*user_data_l=u8g2_GetUserPtr(&u8g2l);
// Copy file descriptors from u8g2 to u8g2lif ( (user_data_r!=NULL) && (user_data_l!=NULL) ){
for (inti=0; i<U8X8_PIN_CNT; ++i) {
if (user_data_l->pins[i] !=NULL) {
user_data_r->pins[i] =user_data_l->pins[i]; // Copy the file descriptor
}
}
}
// Now, u8g2 and u8g2l share the same file descriptors, so that we don't need to repeatedly close and reopen gpio ports// At the end of the program, please be careful with `done_user_data(u8g2)` to avoid double free.u8g2_InitDisplay(&u8g2r);
u8g2_ClearDisplay(&u8g2r);
u8g2_SetPowerSave(&u8g2r, 0);
This works for the "C" version, but does not for "CPP". As I need to switch to C++ for my project - could you help me how I could achieve the same with C++?
The text was updated successfully, but these errors were encountered:
karlo922
changed the title
Copy file descriptors using cpp version of lib not workin
Copy file descriptors using cpp version of lib not working
Apr 18, 2024
I now got it working with just compiling everything u8g2 related as pure C and only doing the rest of my program in C++. So you can still answer if you may help others searching it, or we can close it :)
It looks like the C++ code does not work because the variable u8g2_t u8g2 is defined as a protected member. Thus, the reference to the pins cannot be modified from the outside of the class.
class U8G2: public Print {
protected:
u8g2_t u8g2;
u8x8_char_cb cpp_next_cb; /* the cpp interface has its own decoding function for the Arduino print command */
Hi,
you helped me solving the issue with me master/slave display by suggesting following:
This works for the "C" version, but does not for "CPP". As I need to switch to C++ for my project - could you help me how I could achieve the same with C++?
The text was updated successfully, but these errors were encountered: