Roomba App  1.0
Joystick Class Reference

The Joystick class. More...

#include <joystick.hh>

Inheritance diagram for Joystick:
Collaboration diagram for Joystick:

Public Slots

void setX (const float &value)
 Set value of x coordinate. More...
 
void setY (const float &value)
 Set value of y coordinate. More...
 
void addXAnimation ()
 Add animation for x axis to return knop to home position. More...
 
void addYAnimation ()
 Add animation for y axis to return knop to home position. More...
 
void removeXAnimation ()
 Remove animation for x axis to return knop to home position. More...
 
void removeYAnimation ()
 Remove animation for y axis to return knop to home position. More...
 
void setAlignment (Qt::Alignment align)
 Set alignment needed for resizeEvent to work. More...
 
void movePos (const QPoint &coordinates)
 Change knop coordinates. More...
 

Signals

void xChange (float value)
 Signal emitted in order to realize value change of x coordinate. More...
 
void yChange (float value)
 Signal emitted in order to realize value change of y coordinate. More...
 

Public Member Functions

 Joystick (QWidget *parent=nullptr)
 Construct new Joystick object. More...
 
float x () const
 Get x coordinate value. More...
 
float y () const
 Get y coordinate value. More...
 
 ~Joystick ()
 Delete Joystick object. More...
 

Properties

float x
 
float y
 

Private Member Functions

float checkValue (const float &value, const float &min, const float &max) const
 Check if coordinate value is in proper range. More...
 
void resizeEvent (QResizeEvent *event) override
 Event handler to change size of widget. More...
 
virtual void paintEvent (QPaintEvent *event) override
 Draw analog joystick with it's background. More...
 

Private Attributes

const float _midPoint = 2048.0
 Middle value of raw analog joystick coordinates. More...
 
float _x
 Value of x coordinate. More...
 
float _y
 Value of y coordinate. More...
 
QRectF _bounds
 Bounds of background. More...
 
QRectF _knopBounds
 Bounds of knop. More...
 
QParallelAnimationGroup * _animation
 Animation group used to animate knop returning to home position. More...
 
QPropertyAnimation * _xAnimation
 Animation on x axis when knop is returning home position. More...
 
QPropertyAnimation * _yAnimation
 Animation on y axis when knop is returning home position. More...
 
Qt::Alignment _alignment
 Alignment used in resizeEvent. More...
 

Detailed Description

Definition at line 24 of file joystick.hh.

Constructor & Destructor Documentation

◆ Joystick()

Joystick::Joystick ( QWidget *  parent = nullptr)
explicit
Parameters
[in]parentPointer to parent QWidget object

Definition at line 22 of file joystick.cpp.

◆ ~Joystick()

Joystick::~Joystick ( )

Dummy descructor

Definition at line 39 of file joystick.cpp.

Member Function Documentation

◆ addXAnimation

void Joystick::addXAnimation ( )
slot

Definition at line 63 of file joystick.cpp.

◆ addYAnimation

void Joystick::addYAnimation ( )
slot

Definition at line 69 of file joystick.cpp.

◆ checkValue()

float Joystick::checkValue ( const float &  value,
const float &  min,
const float &  max 
) const
private
Parameters
[in]valueValue to be check
[in]minMinimal value
[in]maxMaximal value
Return values
min- value is below range
max- value is above range
value- value is in proper range

Definition at line 126 of file joystick.cpp.

Here is the caller graph for this function:

◆ movePos

void Joystick::movePos ( const QPoint &  coordinates)
slot

Calculate coordinates which will be used to draw knob from raw coordinates passed as parameter. Emit signal that coordionates changed.

Parameters
[in]coordinatesPoint with coordinates read from serial port

Definition at line 94 of file joystick.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ paintEvent()

void Joystick::paintEvent ( QPaintEvent *  event)
overrideprivatevirtual
Parameters
[in]eventPaint event [not used]

Definition at line 173 of file joystick.cpp.

◆ removeXAnimation

void Joystick::removeXAnimation ( )
slot

Definition at line 75 of file joystick.cpp.

◆ removeYAnimation

void Joystick::removeYAnimation ( )
slot

Definition at line 82 of file joystick.cpp.

◆ resizeEvent()

void Joystick::resizeEvent ( QResizeEvent *  event)
overrideprivate

Change geometry of widget to properly display visualization

Parameters
[in]eventResize event [not used]

Definition at line 131 of file joystick.cpp.

◆ setAlignment

void Joystick::setAlignment ( Qt::Alignment  align)
slot
Parameters
[in]alignType of alignment used in resizeEvent

Definition at line 89 of file joystick.cpp.

◆ setX

void Joystick::setX ( const float &  value)
slot
Parameters
[in]valueValue of x coordinate in range from -1.f to 1.f

Definition at line 41 of file joystick.cpp.

Here is the call graph for this function:

◆ setY

void Joystick::setY ( const float &  value)
slot
Parameters
[in]valueValue of y coordinate in range from -1.f to 1.f

Definition at line 52 of file joystick.cpp.

Here is the call graph for this function:

◆ x()

float Joystick::x ( ) const
inline
Returns
Value of x coordinate

Definition at line 41 of file joystick.hh.

◆ xChange

void Joystick::xChange ( float  value)
signal
Parameters
[in]valueValue of x coordinate
Here is the caller graph for this function:

◆ y()

float Joystick::y ( ) const
inline
Returns
Value of y coordinate

Definition at line 47 of file joystick.hh.

◆ yChange

void Joystick::yChange ( float  value)
signal
Parameters
[in]valueValue of y coordinate
Here is the caller graph for this function:

Member Data Documentation

◆ _alignment

Qt::Alignment Joystick::_alignment
private

Definition at line 184 of file joystick.hh.

◆ _animation

QParallelAnimationGroup* Joystick::_animation
private

Definition at line 169 of file joystick.hh.

◆ _bounds

QRectF Joystick::_bounds
private

Definition at line 159 of file joystick.hh.

◆ _knopBounds

QRectF Joystick::_knopBounds
private

Definition at line 164 of file joystick.hh.

◆ _midPoint

const float Joystick::_midPoint = 2048.0
private

Definition at line 144 of file joystick.hh.

◆ _x

float Joystick::_x
private

Definition at line 149 of file joystick.hh.

◆ _xAnimation

QPropertyAnimation* Joystick::_xAnimation
private

Definition at line 174 of file joystick.hh.

◆ _y

float Joystick::_y
private

Definition at line 154 of file joystick.hh.

◆ _yAnimation

QPropertyAnimation* Joystick::_yAnimation
private

Definition at line 179 of file joystick.hh.

Property Documentation

◆ x

float Joystick::x
readwrite

Definition at line 1 of file joystick.hh.

◆ y

float Joystick::y
readwrite

Definition at line 1 of file joystick.hh.


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