roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
roo_display::Orientation Class Reference

Represents the orientation of a display device. More...

#include <orientation.h>

Public Types

enum class  HorizontalDirection { kLeftToRight = 0 , kRightToLeft = 1 }
 Horizontal direction of the display. More...
 
enum class  VerticalDirection { kTopToBottom = 0 , kBottomToTop = 1 }
 Vertical direction of the display. More...
 

Public Member Functions

constexpr Orientation ()
 
Orientation swapXY () const
 Swap the mapping between x/y and horizontal/vertical directions.
 
bool isXYswapped () const
 Return whether x maps to the vertical direction.
 
HorizontalDirection getHorizontalDirection () const
 Return the horizontal direction.
 
bool isLeftToRight () const
 Return whether horizontal direction is left-to-right.
 
bool isRightToLeft () const
 Return whether horizontal direction is right-to-left.
 
Orientation flipHorizontally () const
 Flip the horizontal direction.
 
VerticalDirection getVerticalDirection () const
 Return the vertical direction.
 
bool isTopToBottom () const
 Return whether vertical direction is top-to-bottom.
 
bool isBottomToTop () const
 Return whether vertical direction is bottom-to-top.
 
Orientation flipVertically () const
 Flip the vertical direction.
 
bool isMirrored () const
 Return whether text would appear mirrored in this orientation.
 
Orientation rotateRight () const
 Rotate 90 degrees clockwise.
 
Orientation rotateLeft () const
 Rotate 90 degrees counter-clockwise.
 
Orientation rotateUpsideDown () const
 Rotate 180 degrees.
 
Orientation rotateClockwise (int turns) const
 Rotate clockwise by turns * 90 degrees.
 
Orientation rotateCounterClockwise (int turns) const
 Rotate counter-clockwise by turns * 90 degrees.
 
int getRotationCount () const
 Return how many right rotations reach this orientation from default.
 
Orientation flipX () const
 Flip along the x axis (horizontal or vertical depending on swap).
 
Orientation flipY () const
 Flip along the y axis (vertical or horizontal depending on swap).
 
const charasString () const
 Return a common name for this orientation.
 

Static Public Member Functions

static constexpr Orientation Default ()
 Return the default orientation (RightDown).
 
static constexpr Orientation RightDown ()
 Return a specific orientation value.
 
static constexpr Orientation DownRight ()
 Return orientation where x increases downward and y increases to the right.
 
static constexpr Orientation LeftDown ()
 Return orientation where x increases to the left and y increases downward.
 
static constexpr Orientation DownLeft ()
 Return orientation where x increases downward and y increases to the left.
 
static constexpr Orientation RightUp ()
 Return orientation where x increases to the right and y increases upward.
 
static constexpr Orientation UpRight ()
 Return orientation where x increases upward and y increases to the right.
 
static constexpr Orientation LeftUp ()
 Return orientation where x increases to the left and y increases upward.
 
static constexpr Orientation UpLeft ()
 Return orientation where x increases upward and y increases to the left.
 
static Orientation RotatedByCount (int count)
 Return the default orientation rotated by count * 90 degrees.
 

Static Public Attributes

static constexpr HorizontalDirection kLeftToRight
 
static constexpr HorizontalDirection kRightToLeft
 
static constexpr VerticalDirection kTopToBottom
 
static constexpr VerticalDirection kBottomToTop
 
static constexpr HorizontalDirection LEFT_TO_RIGHT = kLeftToRight
 
static constexpr HorizontalDirection RIGHT_TO_LEFT = kRightToLeft
 
static constexpr VerticalDirection TOP_TO_BOTTOM = kTopToBottom
 
static constexpr VerticalDirection BOTTOM_TO_TOP = kBottomToTop
 

Friends

bool operator== (Orientation a, Orientation b)
 
bool operator!= (Orientation a, Orientation b)
 

Detailed Description

Represents the orientation of a display device.

A display has a natural physical placement defining absolute up/down/left/ right. Orientation maps logical (x, y) coordinates to those directions. Examples:

  • RightDown: x increases left-to-right, y increases top-to-bottom (default).
  • UpRight: x increases bottom-to-top, y increases left-to-right.

Internally, orientation is stored as a byte and can be passed by value. There are 8 possible values, which can be viewed as:

  • 4 rotations (90-degree steps) with optional mirror flip
  • 3 binary parameters: x/y swapped, horizontal direction, vertical direction.

Helper methods are provided for common transformations.

Definition at line 25 of file orientation.h.

Member Enumeration Documentation

◆ HorizontalDirection

Horizontal direction of the display.

Enumerator
kLeftToRight 
kRightToLeft 

Definition at line 28 of file orientation.h.

◆ VerticalDirection

Vertical direction of the display.

Enumerator
kTopToBottom 
kBottomToTop 

Definition at line 31 of file orientation.h.

Constructor & Destructor Documentation

◆ Orientation()

constexpr roo_display::Orientation::Orientation ( )
inlineconstexpr

Member Function Documentation

◆ asString()

const char * roo_display::Orientation::asString ( ) const
inline

Return a common name for this orientation.

Definition at line 184 of file orientation.h.

◆ Default()

◆ DownLeft()

static constexpr Orientation roo_display::Orientation::DownLeft ( )
inlinestaticconstexpr

Return orientation where x increases downward and y increases to the left.

Definition at line 69 of file orientation.h.

References Orientation().

◆ DownRight()

static constexpr Orientation roo_display::Orientation::DownRight ( )
inlinestaticconstexpr

Return orientation where x increases downward and y increases to the right.

Definition at line 65 of file orientation.h.

References Orientation().

◆ flipHorizontally()

Orientation roo_display::Orientation::flipHorizontally ( ) const
inline

Flip the horizontal direction.

Definition at line 108 of file orientation.h.

References Orientation().

Referenced by flipX(), and flipY().

◆ flipVertically()

Orientation roo_display::Orientation::flipVertically ( ) const
inline

Flip the vertical direction.

Definition at line 122 of file orientation.h.

References Orientation().

Referenced by flipX(), and flipY().

◆ flipX()

Orientation roo_display::Orientation::flipX ( ) const
inline

Flip along the x axis (horizontal or vertical depending on swap).

Definition at line 174 of file orientation.h.

References flipHorizontally(), flipVertically(), and isXYswapped().

◆ flipY()

Orientation roo_display::Orientation::flipY ( ) const
inline

Flip along the y axis (vertical or horizontal depending on swap).

Definition at line 179 of file orientation.h.

References flipHorizontally(), flipVertically(), and isXYswapped().

◆ getHorizontalDirection()

HorizontalDirection roo_display::Orientation::getHorizontalDirection ( ) const
inline

Return the horizontal direction.

Definition at line 93 of file orientation.h.

References kLeftToRight, and kRightToLeft.

Referenced by isLeftToRight(), and isRightToLeft().

◆ getRotationCount()

int roo_display::Orientation::getRotationCount ( ) const
inline

Return how many right rotations reach this orientation from default.

Definition at line 168 of file orientation.h.

◆ getVerticalDirection()

VerticalDirection roo_display::Orientation::getVerticalDirection ( ) const
inline

Return the vertical direction.

Definition at line 111 of file orientation.h.

References kBottomToTop, and kTopToBottom.

Referenced by isBottomToTop(), and isTopToBottom().

◆ isBottomToTop()

bool roo_display::Orientation::isBottomToTop ( ) const
inline

◆ isLeftToRight()

◆ isMirrored()

bool roo_display::Orientation::isMirrored ( ) const
inline

Return whether text would appear mirrored in this orientation.

Definition at line 125 of file orientation.h.

◆ isRightToLeft()

◆ isTopToBottom()

◆ isXYswapped()

◆ LeftDown()

static constexpr Orientation roo_display::Orientation::LeftDown ( )
inlinestaticconstexpr

Return orientation where x increases to the left and y increases downward.

Definition at line 67 of file orientation.h.

References Orientation().

Referenced by roo_display::products::noname::ili9341_red::Kmrtm32032Spi< pinLcdCs, pinTouchCs, pinLcdDc, pinLcdReset >::touch_calibration().

◆ LeftUp()

static constexpr Orientation roo_display::Orientation::LeftUp ( )
inlinestaticconstexpr

Return orientation where x increases to the left and y increases upward.

Definition at line 75 of file orientation.h.

References Orientation().

◆ RightDown()

static constexpr Orientation roo_display::Orientation::RightDown ( )
inlinestaticconstexpr

Return a specific orientation value.

Each static factory describes how logical x/y axes map to physical directions, using the naming convention {x-direction}{y-direction}. For example, RightDown means x increases to the right and y increases downward.

Definition at line 62 of file orientation.h.

References Orientation().

Referenced by Default(), and roo_display::products::noname::st7796s_black::Msp4031< pinLcdCs, pinLcdDc, pinLcdReset >::touch_calibration().

◆ RightUp()

static constexpr Orientation roo_display::Orientation::RightUp ( )
inlinestaticconstexpr

Return orientation where x increases to the right and y increases upward.

Definition at line 71 of file orientation.h.

References Orientation().

Referenced by roo_display::products::noname::ili9341_red::Tjctm24024Spi< pinLcdCs, pinTouchCs, pinLcdDc, pinLcdReset >::touch_calibration().

◆ rotateClockwise()

Orientation roo_display::Orientation::rotateClockwise ( int  turns) const
inline

Rotate clockwise by turns * 90 degrees.

Definition at line 146 of file orientation.h.

References rotateLeft(), rotateRight(), and rotateUpsideDown().

Referenced by rotateCounterClockwise().

◆ rotateCounterClockwise()

Orientation roo_display::Orientation::rotateCounterClockwise ( int  turns) const
inline

Rotate counter-clockwise by turns * 90 degrees.

Definition at line 163 of file orientation.h.

References rotateClockwise().

◆ RotatedByCount()

static Orientation roo_display::Orientation::RotatedByCount ( int  count)
inlinestatic

Return the default orientation rotated by count * 90 degrees.

Parameters
countNumber of 90-degree clockwise steps (negative allowed).

Definition at line 82 of file orientation.h.

References Default().

◆ rotateLeft()

Orientation roo_display::Orientation::rotateLeft ( ) const
inline

Rotate 90 degrees counter-clockwise.

Definition at line 137 of file orientation.h.

References rotateRight(), and rotateUpsideDown().

Referenced by rotateClockwise().

◆ rotateRight()

Orientation roo_display::Orientation::rotateRight ( ) const
inline

Rotate 90 degrees clockwise.

Definition at line 131 of file orientation.h.

References Orientation().

Referenced by rotateClockwise(), and rotateLeft().

◆ rotateUpsideDown()

Orientation roo_display::Orientation::rotateUpsideDown ( ) const
inline

Rotate 180 degrees.

Definition at line 140 of file orientation.h.

References Orientation().

Referenced by rotateClockwise(), and rotateLeft().

◆ swapXY()

Orientation roo_display::Orientation::swapXY ( ) const
inline

Swap the mapping between x/y and horizontal/vertical directions.

Definition at line 87 of file orientation.h.

References Orientation().

◆ UpLeft()

static constexpr Orientation roo_display::Orientation::UpLeft ( )
inlinestaticconstexpr

Return orientation where x increases upward and y increases to the left.

Definition at line 77 of file orientation.h.

References Orientation().

◆ UpRight()

static constexpr Orientation roo_display::Orientation::UpRight ( )
inlinestaticconstexpr

Return orientation where x increases upward and y increases to the right.

Definition at line 73 of file orientation.h.

References Orientation().

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( Orientation  a,
Orientation  b 
)
friend

Definition at line 204 of file orientation.h.

◆ operator==

bool operator== ( Orientation  a,
Orientation  b 
)
friend

Definition at line 200 of file orientation.h.

Field Documentation

◆ BOTTOM_TO_TOP

constexpr VerticalDirection roo_display::Orientation::BOTTOM_TO_TOP = kBottomToTop
staticconstexpr

Definition at line 49 of file orientation.h.

◆ kBottomToTop

constexpr VerticalDirection roo_display::Orientation::kBottomToTop
staticconstexpr

◆ kLeftToRight

constexpr HorizontalDirection roo_display::Orientation::kLeftToRight
staticconstexpr

◆ kRightToLeft

constexpr HorizontalDirection roo_display::Orientation::kRightToLeft
staticconstexpr

◆ kTopToBottom

constexpr VerticalDirection roo_display::Orientation::kTopToBottom
staticconstexpr

◆ LEFT_TO_RIGHT

constexpr HorizontalDirection roo_display::Orientation::LEFT_TO_RIGHT = kLeftToRight
staticconstexpr

Definition at line 43 of file orientation.h.

◆ RIGHT_TO_LEFT

constexpr HorizontalDirection roo_display::Orientation::RIGHT_TO_LEFT = kRightToLeft
staticconstexpr

Definition at line 45 of file orientation.h.

◆ TOP_TO_BOTTOM

constexpr VerticalDirection roo_display::Orientation::TOP_TO_BOTTOM = kTopToBottom
staticconstexpr

Definition at line 47 of file orientation.h.


The documentation for this class was generated from the following file: