Announcement

Collapse
No announcement yet.

gfx_Button2 text not centered

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • gfx_Button2 text not centered

    Hi guys,

    we are thinking about building one of our products around the Gen4-uLCD-70DT display module. I have been playing around with the module and I am trying to implement the serial commands example myself since we cannot always wait for the display's response.
    For this we are building an circular input buffer (integer-array) and need to convert the received text to a "normal" string which can then be passed to the gfx_Button2-function. Right now this is done manually: We reserve a chunk of memory (mem_Alloc) and compress the received string into the memory (joining two characters into one 16 bit memory block).

    The problem that arises is the following: When the string resides in Flash (address > 0x8000), everything works out okay and the string is centered correctly. The same holds for a local variable (address close to 0x0...). But when we use the memory block allocated on the heap (address 0x4xxx), the string is not centered on the button anymore but the text either extends from the middle to the left or from the middle to the right.

    I've been tesing this manually also and I will just copy and paste the code so you can reproduce the phenomenon:

    var test2[] := [0x6766, 0x6968, 0]; // Resembles the text "fghi", null-terminated
    var ptr;
    var ptr2;
    var test[10];
    var pos;

    ptr := mem_Alloc(20);

    // Make sure all locations hold the same data:
    ptr[0] := test2[0];
    ptr[1] := test2[1];
    ptr[2] := test2[2];
    ptr2 := 0x3000;
    ptr2[0] := ptr[0];
    ptr2[1] := ptr[1];
    ptr2[2] := ptr[2];

    gfx_Button2(1, 300, 300, 150, 60, GRAY, BLACK, &test2[0]); // Text from stack (local variable) - Result okay
    gfx_Button2(1, 400, 400, 150, 60, GRAY, BLACK, &ptr[0]); // Text from heap, result offset (incorrect)
    gfx_Button2(1, 400, 200, 150, 60, GRAY, BLACK, &ptr2[0]); // Text from arbitrary location below 0x4000 - Result okay

    We are not sure what's going on, maybe we are missing something here. Otherwise this seems to be a bug in the library implementation. Can anyone suggest how to fix this?

    Best,
    Tobi
    Last edited by HSE; 20th January 2017, 03:20 AM.
Working...
X