-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
delete character / text? #492
Comments
Hi, Just set the test again with an empty string |
hm, but that doesn't delete the previous set text, see:
|
oh, I think, I need to create second text object... but with " " it doesn't delete the previous set characters |
I don't understand. What do you expect to happen exactly? Please, write it down step by step. |
I want increment a number beginning at "1".. and show it on the display.
it doesn't delete anything... why that? |
lv_label_set_text(txt, "1");
lv_label_set_text(txt, "2"); should result This simple example is working there? |
@kisvegabor @epikao You should set action function of that button, with |
you've called function button() many times. |
press button first time i want show 1, press button second time I want show 2 etc. so to show 2 properly I need to delete the 1 from before.... but how delete the 1? |
If you simply create a new label every time, you will see overlapping text like this. Are you using the same label object? |
I simply want count up a number... :-/ ... but before I count 1 to 2 and show to the display I need to delete the 1 otherwise 2 is written over 1 etc. I created a second text object for lv_label_set_text(txt2," ");. |
@epikao You do not need to create a new text object. Simply call |
I'm not sure if someone understand what I'm looking for?, see below my whole button code. I want simply count up a number by pressing a button....
|
lv_obj_t * txt = lv_label_create(lv_scr_act(), NULL); Should not be called multiple times in the loop. |
I already tried to move these parts outside, for example in the setup() function or global - but so far I know it makes problem with the arduino compiler... but I will try it asap again. |
@epikao If the issue still persists you should:
It will create the label only once. Anyway, if you create multiple labels on top of each other, you will get multiple get multiple labels on top of each other. So don't create a new label every time. |
if I put code below code in the setup function, I still have the same problem (cannot delete previous set text with " " or something else):
|
Ok, let's try this in your setup: lv_obj_t * test_txt = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(test_txt, "1");
lv_label_set_text(test_txt, "2"); And do nothing with labels in the loop. |
yes 2 |
so how I delete now this 2 and write a 3 at the same position? |
@epikao I don't think you understand how labels work. You can simply call |
unfortunately that does not work with arduino.. I get always an error if I don't call "lv_label_create" see error below. And If I call for example in the setup follow: the functions does not delete the previous text... so it's simply overwritten and looks like my pictures above :-( See the error without the create function in button function:
|
It should work: Above lv_obj_t * my_label;
int num = 0; In my_label = lv_label_create(lv_scr_act(), NULL); In char buf[32];
sprintf(buf, "num: %d\n", num);
num++;
lv_label_set_text(my_label, buf); |
"lv_obj_t * my_label;" above setup makes the display not work, it stay's black, not start anything. |
@epikao If adding a single global variable above |
I found that is not the global variable the problem, is more the function "lv_label_set..." (which I use in my button function):
as soon I activate "lv_label..." I can only call the button function once and than the whole program crashs, freeze... |
@epikao Would you mind showing the whole file? It would be easier than trying to debug from several code snippets. |
see more or less the whole code:
|
You can't create a label before you call |
it's the same after hal / lv_init:
I think there are still some problems with Arduino, especially the tick function together with other function... don't know?? I use branch 5.2 |
@epikao Is the tick function actually being called? |
yes (but only if lv_label is uncommented) |
@epikao Can you show |
I think you should carefully read and check what kisvegabor said above. |
you can see my code above, it's exactly according. Also I have put the code "loop" in my button function... but I think that should not be a problem?! |
You have this: my_label = lv_label_create(lv_scr_act(), NULL);
lv_init();
|
as mentioned, I already did that... but that still not works :-( .. (I have modify my code above, so maybe somebody can check again, if there is still something wrong??) Anyway does somebody already could do / test that with arduino / teensy? |
@epikao I would try creating a new project. In October it sounded like LittlevGL was running normally, but somehow something appears to have been broken between then and now. |
What means of label? you can't change label casually. I advise you use lv_ta_create() function instead of lv_label_create() function... and the number will update without delete ex-number. |
@xiaoloveyao Actually a label can be changed by calling |
I suppose the issue has been solved finally so I close this issue. |
Hello
I can set a text, for example a number:
lv_label_set_text(txt, "45");
but how can I delete this text, number now?
thanks
The text was updated successfully, but these errors were encountered: