Class VerticalScrollLogicHandler

Class Documentation

class VerticalScrollLogicHandler

Encapsulates the logic necessary for determining the location of the cursor and the smallest and largset indices to be displayed on the OLED display.

For example, suppose we have a menu with 10 entries but only 5 fit on the screen at one time. Initially, the user’s cursor starts at index 0 and indices 0 and 4 are the min and max indices displayed by the OLED display. When the user presses the down button a few times such that the cursor index is 5, the min and max indices must be shifted by 1 so they are now 1 and 5. This class handles this sort of logic for you. Call this function in a menu’s shortButtonPress function and use the known cursorIndex, smallestIndexDisplayed, and largestIndexDisplayed when drawing.

Note

Zero indexing is used.

Public Functions

VerticalScrollLogicHandler(Drivers *drivers, int8_t size, int8_t maxEntries)
Parameters:
  • size[in] The number of elements that the scroll logic handler will enumerate through. If less than 0, an error will be raised and this object will not operate properly. If 0, no errors will be raised but the object will not do anything.

  • maxEntries[in] The maximum number of entries you can display on the OLED at one time. Must be greater than 0. If <= 0, error is raised and maxEntries set to 1.

void setSize(int8_t size)
void onShortButtonPress(modm::MenuButtons::Button button)
bool acknowledgeCursorChanged()
inline int8_t getCursorIndex() const
inline int8_t getSmallestIndexDisplayed() const

Returns the smallest (inclusive) entry index currently visible.

inline int8_t getLargestIndexDisplayed() const

Returns the largest (inclusive) entry index currently visible.

Note

There may be blank space following the largest entry if the size is less than the max number of entries.

inline int8_t getSize() const