Skip to content
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

Probable error in Y axis bounds checking #1

hydrogen18 opened this issue Jul 10, 2019 · 2 comments


Copy link

@hydrogen18 hydrogen18 commented Jul 10, 2019


I have a simple program that uses your library. It makes it very simple to display text and basic shapes, thank you for contributing this. Every once in a while it seems something writes all over the memory of my application with values like 0xff or 0x00.

I have some code that adjusts my internally managed X and Y offsets on a timer. So the displayed image is shifted by a few pixels all over the screen very slowly. This is meant to avoid burn in of the display.

I have been trying to understand this problem and was doing some basic code review of your code and noticed what seems like an error in your Y Axis bounds checking

void GLCD_GotoX(const uint8_t X)
	if (X < __GLCD_Screen_Width)
		__GLCD.X = X;

void GLCD_GotoY(const uint8_t Y)
	if (__GLCD.Y < __GLCD_Screen_Height)
		__GLCD.Y = Y;

My screen height and width are less than 255.

If I make a call like GLCD_GotoX(255) it will just do nothing.

But I call GLCD_GotoY(255) the first call checks the existing value __GLCD.Y against the maximum height. It then sets __GLCD.Y = 255. Now __GLCD.Y is stuck at too large of a value. Presumably now the graphics library is just writing all over the SRAM of my device.

I think the check in GLCD_GotoY should be if ( Y < __GLCD_ScreenHeight). Do you agree?



This comment has been minimized.

Copy link

@Tekl7 Tekl7 commented Jul 19, 2019


it's not my library but I fully agree with you :)


This comment has been minimized.

Copy link

@efthymios-ks efthymios-ks commented Jul 25, 2019

Hello everyone. You are right. Thanks for using the library and spotting the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.