8x8 Led Matrix Library 1.0.0
This is a library for the 8x8 Led Matrix by Soldered
Loading...
Searching...
No Matches
MD_RobotEyes Class Reference

#include <MD_RobotEyes.h>

Classes

struct  animFrame_t
 
struct  animTable_t
 

Public Types

enum  emotion_t {
  E_NONE , E_NEUTRAL , E_BLINK , E_WINK ,
  E_LOOK_L , E_LOOK_R , E_LOOK_U , E_LOOK_D ,
  E_ANGRY , E_SAD , E_EVIL , E_EVIL2 ,
  E_SQUINT , E_DEAD , E_SCAN_UD , E_SCAN_LR
}
 

Public Member Functions

 MD_RobotEyes (void)
 
 ~MD_RobotEyes (void)
 
void begin (Led_Matrix *M, uint8_t moduleStart=0)
 
void setAnimation (emotion_t e, bool r, bool b=false)
 
void setBlinkTime (uint16_t t)
 
void setAutoBlink (bool b)
 
bool setText (const char *pText)
 
bool runAnimation (void)
 

Protected Types

enum  animState_t {
  S_IDLE , S_RESTART , S_ANIMATE , S_PAUSE ,
  S_TEXT
}
 

Protected Member Functions

void loadEye (uint8_t module, uint8_t ch)
 
void drawEyes (uint8_t L, uint8_t R)
 
uint8_t loadSequence (emotion_t e)
 
void loadFrame (animFrame_t *pBuf)
 
void showText (bool bInit=false)
 
void dumpSequence (const animFrame_t *pBuf, uint8_t numElements)
 

Protected Attributes

Led_Matrix_M
 
uint16_t _sd
 
uint32_t _timeStartPause
 
uint32_t _timeLastAnimation
 
uint16_t _timeBlinkMinimum
 
animState_t _animState
 
bool _autoBlink
 
uint16_t _scrollDelay
 
animTable_t _animEntry
 
int8_t _animIndex
 
bool _animReverse
 
bool _autoReverse
 
emotion_t _nextEmotion
 
const char * _pText
 

Static Protected Attributes

static const animFrame_t seqBlink []
 
static const animFrame_t seqWink []
 
static const animFrame_t seqLeft []
 
static const animFrame_t seqRight []
 
static const animFrame_t seqUp []
 
static const animFrame_t seqDown []
 
static const animFrame_t seqAngry []
 
static const animFrame_t seqSad []
 
static const animFrame_t seqEvil []
 
static const animFrame_t seqEvil2 []
 
static const animFrame_t seqSquint []
 
static const animFrame_t seqDead []
 
static const animFrame_t seqScanUpDown []
 
static const animFrame_t seqScanLeftRight []
 
static const animTable_t lookupTable []
 

Detailed Description

Robot Eyes Class. This class manages the displayed of animated eyes using LED matrices using the functions provided by the Led_Matrix library.

Member Enumeration Documentation

◆ animState_t

enum MD_RobotEyes::animState_t
protected
Enumerator
S_IDLE 
S_RESTART 
S_ANIMATE 
S_PAUSE 
S_TEXT 

◆ emotion_t

Emotions enumerated type.

This enumerated type defines the emotion animations available in the class for the eyes display

Enumerator
E_NONE 

Placeholder for no emotions, not user selectable.

E_NEUTRAL 

Eyes in neutral position (no animation)

E_BLINK 

Both eyes blink.

E_WINK 

One eye blink.

E_LOOK_L 

Both eyes look left.

E_LOOK_R 

Both eyes look right.

E_LOOK_U 

Both eyes look up.

E_LOOK_D 

Both eyes look down.

E_ANGRY 

Eyes look angry (symmetrical)

E_SAD 

Eyes look sad (symmetrical)

E_EVIL 

Eyes look evil (symmetrical)

E_EVIL2 

Eyes look evil (asymmetrical)

E_SQUINT 

Both eye squint.

E_DEAD 

Eyes indicate dead (different)

E_SCAN_UD 

Both eyes scanning Up/Down.

E_SCAN_LR 

Both eyes scanning Left/Right.

Constructor & Destructor Documentation

◆ MD_RobotEyes()

MD_RobotEyes::MD_RobotEyes ( void )

Class Constructor.

Instantiate a new instance of the class.

◆ ~MD_RobotEyes()

MD_RobotEyes::~MD_RobotEyes ( void )
inline

Class Destructor.

Released any allocated memory and does the necessary to clean up once the object is no longer required.

Member Function Documentation

◆ begin()

void MD_RobotEyes::begin ( Led_Matrix * M,
uint8_t moduleStart = 0 )

Initialize the object.

Initialize the object data. This needs to be called during setup() to initialize new data for the class that cannot be done during the object creation.

Outside of the class, the Led_Matrix library should be initialized and the pointer to the Led_Matrix object passed to the parameter. Also, as the eyes could be in the middle of a string of LED modules, the first 'eye' module can be specified.

/param M Pointer to the Led_Matrix library object. /param moduleStart The first 'eye' LED module. Defaults to 0 if not specified.

◆ drawEyes()

void MD_RobotEyes::drawEyes ( uint8_t L,
uint8_t R )
protected

◆ dumpSequence()

void MD_RobotEyes::dumpSequence ( const animFrame_t * pBuf,
uint8_t numElements )
protected

◆ loadEye()

void MD_RobotEyes::loadEye ( uint8_t module,
uint8_t ch )
protected

◆ loadFrame()

void MD_RobotEyes::loadFrame ( animFrame_t * pBuf)
protected

◆ loadSequence()

uint8_t MD_RobotEyes::loadSequence ( emotion_t e)
protected

◆ runAnimation()

bool MD_RobotEyes::runAnimation ( void )

Animate the display.

This method needs to be invoked as often as possible to ensure smooth animation.

The calling program should monitor the return value for 'true' in order to know when the animation has concluded. A 'true' return value means that the animation is complete.

Returns
bool True if the animation has completed, false otherwise.

◆ setAnimation()

void MD_RobotEyes::setAnimation ( emotion_t e,
bool r,
bool b = false )
inline

Set the animation type and parameters.

Set the next animations to the specified. Additionally, set whether the animation should auto reverse the action (eg, blink down then back up again) and whether the animation should be run in reverse.

Animations are generally symmetric, so only half the animation needs to be specified. If an animated expression needs to be held, the animation should be run without auto reverse, which holds the animation at the end point, and then later run the animation in reverse from the last position to return to the idle state.

Parameters
eThe type of emotion to be displayed, one of the emotion_T enumerated values.
rIf true, run auto reverse.
bIf true, start the animation from the end of the sequence.

◆ setAutoBlink()

void MD_RobotEyes::setAutoBlink ( bool b)
inline

Set or reset auto blink mode.

When no animation is running and AutoBlink is set, the eyes will occasionally blink.

Parameters
bSet auto blink if true, reset auto blink if false.

◆ setBlinkTime()

void MD_RobotEyes::setBlinkTime ( uint16_t t)
inline

Set the blink time.

When no animation is running and AutoBlink is set, the eyes will occasionally blink. Set the minimum time period between blinks. A blink will occur a random time after this.

Parameters
tThe minimum time between blinking actions in milliseconds.

◆ setText()

bool MD_RobotEyes::setText ( const char * pText)
inline

Display a text message.

At the end of the current animation, the text will be scrolled across the 'eyes' and then the eyes are returned to the neutral expression

Parameters
pA pointer to a char array containing a nul terminated string. The string must remain in scope while the message is being displayed.

◆ showText()

void MD_RobotEyes::showText ( bool bInit = false)
protected

Member Data Documentation

◆ _animEntry

animTable_t MD_RobotEyes::_animEntry
protected

◆ _animIndex

int8_t MD_RobotEyes::_animIndex
protected

◆ _animReverse

bool MD_RobotEyes::_animReverse
protected

◆ _animState

animState_t MD_RobotEyes::_animState
protected

◆ _autoBlink

bool MD_RobotEyes::_autoBlink
protected

◆ _autoReverse

bool MD_RobotEyes::_autoReverse
protected

◆ _M

Led_Matrix* MD_RobotEyes::_M
protected

◆ _nextEmotion

emotion_t MD_RobotEyes::_nextEmotion
protected

◆ _pText

const char* MD_RobotEyes::_pText
protected

◆ _scrollDelay

uint16_t MD_RobotEyes::_scrollDelay
protected

◆ _sd

uint16_t MD_RobotEyes::_sd
protected

◆ _timeBlinkMinimum

uint16_t MD_RobotEyes::_timeBlinkMinimum
protected

◆ _timeLastAnimation

uint32_t MD_RobotEyes::_timeLastAnimation
protected

◆ _timeStartPause

uint32_t MD_RobotEyes::_timeStartPause
protected

◆ lookupTable

const MD_RobotEyes::animTable_t MD_RobotEyes::lookupTable
staticprotected
Initial value:
= {
}
static const animFrame_t seqEvil2[]
Definition MD_RobotEyes.h:223
static const animFrame_t seqRight[]
Definition MD_RobotEyes.h:222
static const animFrame_t seqDown[]
Definition MD_RobotEyes.h:222
static const animFrame_t seqUp[]
Definition MD_RobotEyes.h:222
static const animFrame_t seqSquint[]
Definition MD_RobotEyes.h:224
static const animFrame_t seqScanUpDown[]
Definition MD_RobotEyes.h:225
static const animFrame_t seqSad[]
Definition MD_RobotEyes.h:223
static const animFrame_t seqAngry[]
Definition MD_RobotEyes.h:223
@ E_LOOK_R
Both eyes look right.
Definition MD_RobotEyes.h:44
@ E_ANGRY
Eyes look angry (symmetrical)
Definition MD_RobotEyes.h:47
@ E_SAD
Eyes look sad (symmetrical)
Definition MD_RobotEyes.h:48
@ E_SQUINT
Both eye squint.
Definition MD_RobotEyes.h:51
@ E_BLINK
Both eyes blink.
Definition MD_RobotEyes.h:41
@ E_LOOK_U
Both eyes look up.
Definition MD_RobotEyes.h:45
@ E_SCAN_LR
Both eyes scanning Left/Right.
Definition MD_RobotEyes.h:54
@ E_LOOK_D
Both eyes look down.
Definition MD_RobotEyes.h:46
@ E_EVIL2
Eyes look evil (asymmetrical)
Definition MD_RobotEyes.h:50
@ E_EVIL
Eyes look evil (symmetrical)
Definition MD_RobotEyes.h:49
@ E_NEUTRAL
Eyes in neutral position (no animation)
Definition MD_RobotEyes.h:40
@ E_DEAD
Eyes indicate dead (different)
Definition MD_RobotEyes.h:52
@ E_SCAN_UD
Both eyes scanning Up/Down.
Definition MD_RobotEyes.h:53
@ E_WINK
One eye blink.
Definition MD_RobotEyes.h:42
@ E_LOOK_L
Both eyes look left.
Definition MD_RobotEyes.h:43
static const animFrame_t seqWink[]
Definition MD_RobotEyes.h:221
static const animFrame_t seqEvil[]
Definition MD_RobotEyes.h:223
static const animFrame_t seqScanLeftRight[]
Definition MD_RobotEyes.h:225
static const animFrame_t seqBlink[]
Definition MD_RobotEyes.h:221
static const animFrame_t seqDead[]
Definition MD_RobotEyes.h:224
static const animFrame_t seqLeft[]
Definition MD_RobotEyes.h:222

◆ seqAngry

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqAngry
staticprotected
Initial value:
= {
{{00, 00}, FRAME_TIME}, {{22, 17}, FRAME_TIME}, {{23, 18}, FRAME_TIME}, {{24, 19}, FRAME_TIME}, {{25, 20}, 2000},
}

◆ seqBlink

const animFrame_t MD_RobotEyes::seqBlink[]
staticprotected

◆ seqDead

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqDead
staticprotected
Initial value:
= {
{{52, 52}, FRAME_TIME * 4},
{{53, 53}, FRAME_TIME * 4},
{{52, 52}, FRAME_TIME * 2},
}

◆ seqDown

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqDown
staticprotected
Initial value:
= {
{{00, 00}, FRAME_TIME},
{{14, 14}, FRAME_TIME},
{{15, 15}, FRAME_TIME},
{{16, 16}, FRAME_TIME * 5},
}

◆ seqEvil

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqEvil
staticprotected
Initial value:
= {
{{00, 00}, FRAME_TIME},
{{39, 37}, FRAME_TIME},
{{40, 38}, 2000},
}

◆ seqEvil2

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqEvil2
staticprotected
Initial value:
= {
{{00, 00}, FRAME_TIME}, {{54, 17}, FRAME_TIME}, {{55, 18}, FRAME_TIME}, {{56, 19}, FRAME_TIME}, {{57, 20}, 2000},
}

◆ seqLeft

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqLeft
staticprotected
Initial value:
= {
{{0, 0}, FRAME_TIME},
{{8, 8}, FRAME_TIME},
{{9, 9}, FRAME_TIME * 5},
}

◆ seqRight

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqRight
staticprotected
Initial value:
= {
{{0, 0}, FRAME_TIME},
{{6, 6}, FRAME_TIME},
{{7, 7}, FRAME_TIME * 5},
}

◆ seqSad

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqSad
staticprotected
Initial value:
= {
{{00, 00}, FRAME_TIME},
{{32, 27}, FRAME_TIME},
{{33, 28}, FRAME_TIME},
{{34, 29}, 2000},
}

◆ seqScanLeftRight

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqScanLeftRight
staticprotected
Initial value:
= {
{{41, 41}, FRAME_TIME * 2},
{{42, 42}, FRAME_TIME},
{{43, 43}, FRAME_TIME},
{{44, 44}, FRAME_TIME},
}

◆ seqScanUpDown

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqScanUpDown
staticprotected
Initial value:
= {
{{46, 46}, FRAME_TIME * 2}, {{47, 47}, FRAME_TIME}, {{48, 48}, FRAME_TIME},
{{49, 49}, FRAME_TIME}, {{50, 50}, FRAME_TIME}, {{51, 51}, FRAME_TIME},
}

◆ seqSquint

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqSquint
staticprotected
Initial value:
= {
{{00, 00}, FRAME_TIME}, {{54, 54}, FRAME_TIME}, {{55, 55}, FRAME_TIME}, {{56, 56}, FRAME_TIME}, {{57, 57}, 2000},
}

◆ seqUp

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqUp
staticprotected
Initial value:
= {
{{00, 00}, FRAME_TIME},
{{11, 11}, FRAME_TIME},
{{12, 12}, FRAME_TIME},
{{13, 13}, FRAME_TIME * 5},
}

◆ seqWink

const MD_RobotEyes::animFrame_t MD_RobotEyes::seqWink
staticprotected
Initial value:
= {
{{0, 0}, FRAME_TIME / 2}, {{1, 0}, FRAME_TIME / 2}, {{2, 0}, FRAME_TIME / 2},
{{3, 0}, FRAME_TIME / 2}, {{4, 0}, FRAME_TIME / 2}, {{5, 0}, FRAME_TIME * 2},
}

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