PROS Controller Screen Problem

The function: int32_t controller_set_text(controller_id_e_t id, uint8_t line, uint8_t col, const char* str) (found in the controller.c file on the PROS Kernel github) seems to have a major flaw that causes the clear screen and line functions to not work in certain circumstances. This is because when characters are printed on the controller screen they can differ in size & placement. The max amount of characters this function will accept is defined by: #define CONTROLLER_MAX_COLS 19, which is NOT the max amount of space: ' ' that can fit on the screen. Please increase this number so the entire screen is cleared properly every time.

Line of code that caused the problem:

controller_set_text(CONTROLLER_MASTER,2,0,"DON'T POWER OFF");

Temp fix:

controller_set_text(CONTROLLER_MASTER,2,9,"                   ");
delay(55);
controller_set_text(CONTROLLER_MASTER,2,0,"                   ");

Picture:

issue.PNG

Additional question:

After reading through the code I noticed char* buf = (char*)malloc(CONTROLLER_MAX_COLS + 1); Why is this variable allocated on the heap and not the stack, wouldn’t a traditional stack allocation be faster?

Update: Just saw the " Merge pull request #222 from purduesigbots/increase-char" on github for the commit (which I assume fixes this issue). Should’ve read more carefully before posting, just caused a huge headache and didn’t look too much into it after I discovered the problem. Hoping for a updated PROS Kernel too be released soon!

2 Likes

Hi 6403B,

This pull request did not fix the issue. It instead increased the maximum characters you could have from 15 to 19 (which is coming in the next kernel update) since VEXCode and RMS both also have their maximum char size at 19. The issue of the controller screen not clearing properly is also documented in RMS and VEXCode as well (more details in this closed issue here: https://github.com/purduesigbots/pros/issues/217#issuecomment-657953044). Either way, we’d have to wait for some sort of VEXos update to allow for us to fix this.

Thanks for trying to bring this up to our attention though, we appreciate your vigilance for issues in our code :slight_smile: .

9 Likes

sending a string of 0 length is supposed to clear a line, not sure if I did that in VEXcode or not, I’ll check it tomorrow.

4 Likes

Wouldn’t increasing the maximum amount of characters allow the screen to clear properly since the clear line functions works by writing a string of spaces to the screen though?

Yes, theoretically that’d be true. However, we’ve tried increasing the text length past its 19 char limit, and there’s a VEXos limit that we can’t do anything about at 19.

4 Likes

Sorry I must not be understanding this correctly. The version of PROS that is available right now only has a 15 char limit, and only a few characters on the screen wont be removed in some cases. However it has been increased by 4 more char. Is the increase not large enough?

See my comment above. The 20 char limit is a vexos limit, nothing PROS can do about that.

6 Likes

I think I understand, you also mentioned sending a string of length zero to signal a line clear to the controller. Why can’t PROS do this as well?

The issue with this then is that since we’re now allowing users to have 19 chars, is that now there are even longer lines of text that we can’t clear with 4 more spaces. And thus, the problem repeats itself.

1 Like

But wont the increase just clear the whole line still though? Even if someone makes anything larger than that it will not be able to fully print to the screen anyways

They could, but I need to check that it still works.

1 Like

The reason that PROS cannot currently send a 0-length string is because it forces you to send a string that’s length 20 (or 16 on the current release), just by how the API was designed.

Hopefully this will be fixed on the next release, I know @RanchSauce is looking into it.

If you’re interested, you can look into the pros source code to find out why you can’t send a 0-length string at the moment, it’s all open-source

2 Likes

Are there files that handle lower level IO of the controller? I thought calls from “v5_api.h” were as low level as the PROS Kernel interacted with.

That is correct.

PROS as it stands cannot send a 0-length string to the controller’s API, and you can see why if you look into the source code.

I would assume your talking about the call to: vsnprintf(buf, CONTROLLER_MAX_COLS + 1, fmt, args); But couldn’t this be fixed with a few minor changes? Unless it’s something else

Yes, it could. That is in progress, as I mentioned above.

Thanks for clearing it up more, just wanted to understand why it was like that. Can’t wait for the next Kernel update though!

Could be a bit, since the next release seems to be planned to be PROS 4 (there’s an rfc and a project set up for it), with some other major improvements that are gonna take a lot of work. I’ve seen a template of the version with a 19 character limit somewhere, it’s either in the github issue or somewhere in VTOW #software.

What? I think you should look again.

2 Likes