Doly C++ SDK v1.00
Loading...
Searching...
No Matches
EyeControl Namespace Reference

Functions

int8_t init (ColorCode eye_color, ColorCode bg_color)
 Initialize the eye subsystem (LCD + eye assets).
void Abort ()
 Abort/terminate the active animation.
bool isActive ()
 Check whether the subsystem is active (initialized and running).
bool isAnimating ()
 Check whether an animation is currently running.
int8_t setEyes (IrisShape shape, ColorCode iris_color, ColorCode bg_color)
 Set both iris and background to built-in presets.
int8_t setIris (IrisShape shape, ColorCode color, EyeSide side)
 Set iris preset for a given side.
int8_t setIris (VContent *eye_image, EyeSide side)
 Set iris image content for a given side.
int8_t setLid (VContent *lid_image, bool isTop, EyeSide side)
 Set eyelid image content for a given side.
int8_t setBackground (Color color)
 Set background color (solid).
int8_t setBackground (VContent *bg_image, EyeSide side)
 Set background image content for a given side.
int8_t setAnimation (uint16_t id, std::string_view name)
 Start a named eye animation (non-blocking).
int8_t setPosition (EyeSide side, int16_t centerX, int16_t centerY, float scaleX=1, float scaleY=1, uint8_t lid_top_end=0, uint8_t lid_bot_start=240)
 Set iris position/scale and eyelid limits for a given side.
int8_t getIrisPosition (EyeSide side, int16_t &x, int16_t &y)
 Get the current iris center position for a given side.
float getVersion ()
 Get current library version.

Function Documentation

◆ Abort()

void EyeControl::Abort ( )

Abort/terminate the active animation.

This is intended as a stop/emergency action for ongoing animations.

◆ getIrisPosition()

int8_t EyeControl::getIrisPosition ( EyeSide side,
int16_t & x,
int16_t & y )

Get the current iris center position for a given side.

Parameters
sideTarget eye side (LEFT or RIGHT).
xOutput X coordinate.
yOutput Y coordinate.
Returns
Status code:
  • 0 : success
  • -1 : wrong side (accepts Left or Right)
Note
The top-left corner of each display is defined as x=0, y=0.
Examples
EyeControl/main.cpp.

◆ getVersion()

float EyeControl::getVersion ( )

Get current library version.

Original note: format 0.XYZ (3 digits after major).

Returns
Version as float.
Examples
EyeControl/main.cpp.

◆ init()

int8_t EyeControl::init ( ColorCode eye_color,
ColorCode bg_color )

Initialize the eye subsystem (LCD + eye assets).

This must be called once before other control functions.

Parameters
eye_colorDefault iris color (see Color.h).
bg_colorDefault background color (see Color.h).
Returns
Status code:
  • 0 : success
  • 1 : already initialized
  • -1 : loadEyeFiles failed
  • -2 : LCD init failed
Examples
EyeControl/main.cpp.

◆ isActive()

bool EyeControl::isActive ( )

Check whether the subsystem is active (initialized and running).

Returns
true if initialized, false otherwise.

◆ isAnimating()

bool EyeControl::isAnimating ( )

Check whether an animation is currently running.

Returns
true if an animation continues, false otherwise.
Examples
EyeControl/main.cpp.

◆ setAnimation()

int8_t EyeControl::setAnimation ( uint16_t id,
std::string_view name )

Start a named eye animation (non-blocking).

The animation runs on an internal worker thread. Start/complete/abort are reported via EyeEvent/EyeEventListener.

Parameters
idUser-defined id forwarded to event callbacks.
nameAnimation name (see EyeExpressions).
Returns
Status code:
  • 0 : success
  • -1 : can not found animation, check name
Examples
EyeControl/main.cpp.

◆ setBackground() [1/2]

int8_t EyeControl::setBackground ( Color color)

Set background color (solid).

Parameters
colorBackground color (RGB).
Returns
Status code:
  • 0 : success
  • -1 : failed

◆ setBackground() [2/2]

int8_t EyeControl::setBackground ( VContent * bg_image,
EyeSide side )

Set background image content for a given side.

Parameters
bg_imageBackground image content.
sideTarget eye side.
Returns
Status code:
  • 0 : success
  • -1 : null image pointer

◆ setEyes()

int8_t EyeControl::setEyes ( IrisShape shape,
ColorCode iris_color,
ColorCode bg_color )

Set both iris and background to built-in presets.

Parameters
shapeBuilt-in iris shape preset.
iris_colorIris color.
bg_colorBackground color.
Returns
Status code:
  • 0 : success
  • -1 : getIris() failed, out of array
  • -2 : getBackground() failed, out of array

◆ setIris() [1/2]

int8_t EyeControl::setIris ( IrisShape shape,
ColorCode color,
EyeSide side )

Set iris preset for a given side.

Parameters
shapeIris preset to apply.
colorIris color.
sideTarget eye side.
Returns
Status code:
  • 0 : success
  • -1 : out of array, check color
  • -2 : out of array, check shape
Examples
EyeControl/main.cpp.

◆ setIris() [2/2]

int8_t EyeControl::setIris ( VContent * eye_image,
EyeSide side )

Set iris image content for a given side.

Parameters
eye_imageIris image content.
sideTarget eye side.
Returns
Status code:
  • 0 : success
  • -1 : null image pointer

◆ setLid()

int8_t EyeControl::setLid ( VContent * lid_image,
bool isTop,
EyeSide side )

Set eyelid image content for a given side.

Parameters
lid_imageLid image content.
isTopTrue for top lid, false for bottom lid.
sideTarget eye side.
Returns
Status code:
  • 0 : success
  • -1 : null image pointer
Examples
EyeControl/main.cpp.

◆ setPosition()

int8_t EyeControl::setPosition ( EyeSide side,
int16_t centerX,
int16_t centerY,
float scaleX = 1,
float scaleY = 1,
uint8_t lid_top_end = 0,
uint8_t lid_bot_start = 240 )

Set iris position/scale and eyelid limits for a given side.

Parameters
sideEye side.
centerXIris center X location (-250..0..250).
centerYIris center Y location (-250..0..250).
scaleXScale factor for iris image (default 1).
scaleYScale factor for iris image (default 1).
lid_top_endTop eyelid Y end position.
lid_bot_startBottom eyelid Y start position.
Note
Coordinate reference: top-left of LCD is (0,0); center is (120,120).
Returns
Status code:
  • 0 : success
  • -1 : centerX or centerY out of range (-250..0..250)
Examples
EyeControl/main.cpp.