We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
in the sample
for(int y=0, i=1; y>=0; y+=i) { ssd1306_draw_line(&disp, 0, 31-y, 127, 31+y); ssd1306_draw_line(&disp, 0, 31+y, 127, 31-y); ssd1306_show(&disp); sleep_ms(SLEEPTIME); ssd1306_clear(&disp); if(y==32) i=-1; }
only one line (and a dot) is drawn!
The function should read:
void ssd1306_draw_line(ssd1306_t *p, uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2) { if (x1 > x2) { swap(&x1, &x2); swap(&y1, &y2); } if (x1 == x2) { if (y1 > y2) swap(&y1, &y2); for (int32_t i = y1; i <= y2; ++i) ssd1306_draw_pixel(p, x1, i); return; } // NOTE The cast to int32_t before subtracting y2 - y1 float m = (float)((int32_t)y2 - (int32_t)y1) / (float)(x2 - x1); for (int32_t i = x1; i <= x2; ++i) { float y = m * (float)(i - x1) + (float)y1; ssd1306_draw_pixel(p, i, (uint32_t)y); } }
The text was updated successfully, but these errors were encountered:
Thank you for your contribution. Could you submit a PR?
Sorry, something went wrong.
No branches or pull requests
in the sample
only one line (and a dot) is drawn!
The function should read:
The text was updated successfully, but these errors were encountered: