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

Custom page selection for paged display #990

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add some comments.
  • Loading branch information
JohannesWilde committed Sep 8, 2019
commit a0ed1d9f850cefc760cc974187614ba7b563bf85
7 changes: 7 additions & 0 deletions csrc/u8g2_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,15 @@ void u8g2_SetBufferCurrTileRow(u8g2_t *u8g2, uint8_t row)
u8g2->cb->update_page_win(u8g2);
}

/* Calculates the first row of the specified page - does not detect overflows
* or pages out of scope for the current display. */
uint8_t u8g2_PageFirstRow(u8g2_t const * const u8g2, uint8_t const page)
{
return u8g2->tile_buf_height * page;
}

/* Sets the current buffer to the page specified.
* Returns 0 in case the page is invalid - otherwise 1. */
uint8_t u8g2_CustomPage(u8g2_t * const u8g2, uint8_t const page)
{
uint8_t const row = u8g2_PageFirstRow(u8g2, page);
Expand All @@ -127,6 +131,7 @@ uint8_t u8g2_CustomPage(u8g2_t * const u8g2, uint8_t const page)
}
}

/* Specialization [faster!] for setting the current buffer to the first page. */
void u8g2_FirstPage(u8g2_t *u8g2)
{
if ( u8g2->is_auto_page_clear )
Expand All @@ -136,6 +141,8 @@ void u8g2_FirstPage(u8g2_t *u8g2)
u8g2_SetBufferCurrTileRow(u8g2, 0);
}

/* Sends the current buffer to the display and attempts to set the buffer to the next page.
* Returns 0 in case the next page is invalid - otherwise 1 */
uint8_t u8g2_NextPage(u8g2_t *u8g2)
{
uint8_t row;
Expand Down