trikRuntime
trikControl::Brick Class Reference

Class representing TRIK controller board and devices installed on it, also provides access to peripherals like motors and sensors. More...

#include <brick.h>

Inheritance diagram for trikControl::Brick:
Collaboration diagram for trikControl::Brick:

Public Slots

void configure (const QString &portName, const QString &deviceName) override
 
void playSound (const QString &soundFileName) override
 
void playTone (int hzFreq, int msDuration) override
 
void say (const QString &text) override
 
void stop () override
 
MotorInterfacemotor (const QString &port) override
 
PwmCaptureInterfacepwmCapture (const QString &port) override
 
SensorInterfacesensor (const QString &port) override
 
QStringList motorPorts (MotorInterface::Type type) const override
 
QStringList pwmCapturePorts () const override
 
QStringList sensorPorts (SensorInterface::Type type) const override
 
QStringList encoderPorts () const override
 
VectorSensorInterfaceaccelerometer () override
 
GyroSensorInterfacegyroscope () override
 
LineSensorInterfacelineSensor (const QString &port) override
 
ColorSensorInterfacecolorSensor (const QString &port) override
 
ObjectSensorInterfaceobjectSensor (const QString &port) override
 
I2cDeviceInterfacei2c (int bus, int address) override
 
QVector< uint8_t > getStillImage () override
 
SoundSensorInterfacesoundSensor (const QString &port) override
 
EncoderInterfaceencoder (const QString &port) override
 
BatteryInterfacebattery () override
 
KeysInterfacekeys () override
 
DisplayInterfacedisplay () override
 
LedInterfaceled () override
 
GamepadInterfacegamepad () override
 
FifoInterfacefifo (const QString &port) override
 
MarkerInterfacemarker () override
 
EventDeviceInterfaceeventDevice (const QString &deviceFile) override
 
void stopEventDevice (const QString &deviceFile) override
 
- Public Slots inherited from trikControl::BrickInterface
virtual void configure (const QString &portName, const QString &deviceName)=0
 Configures given device on given port. More...
 
virtual void playSound (const QString &soundFileName)=0
 Plays given music file on a speaker (in format accepted by aplay or cvlc utilities). More...
 
virtual void playTone (int hzFreq, int msDuration)=0
 Generates sound with given frequency and given duration, plays it on a speaker. More...
 
virtual void say (const QString &text)=0
 Uses text synthesis to say given text on a speaker. More...
 
virtual void stop ()=0
 Stops all motors and shuts down all current activity. More...
 
virtual trikControl::MotorInterfacemotor (const QString &port)=0
 Returns reference to motor of a given type on a given port. More...
 
virtual trikControl::PwmCaptureInterfacepwmCapture (const QString &port)=0
 Returns reference to PWM signal capture device on a given port. More...
 
virtual trikControl::SensorInterfacesensor (const QString &port)=0
 Returns reference to sensor on a given port. More...
 
virtual QStringList motorPorts (MotorInterface::Type type) const =0
 Retruns list of ports for motors of a given type. More...
 
virtual QStringList pwmCapturePorts () const =0
 Returns list of PWM signal capture device ports. More...
 
virtual QStringList sensorPorts (SensorInterface::Type type) const =0
 Returns list of ports for sensors of a given type. More...
 
virtual QStringList encoderPorts () const =0
 Returns list of encoder ports. More...
 
virtual trikControl::VectorSensorInterfaceaccelerometer ()=0
 Returns on-board accelerometer. More...
 
virtual trikControl::GyroSensorInterfacegyroscope ()=0
 Returns on-board gyroscope. More...
 
virtual trikControl::LineSensorInterfacelineSensor (const QString &port)=0
 Returns high-level line detector sensor using camera on given port (video0 or video1). More...
 
virtual trikControl::ColorSensorInterfacecolorSensor (const QString &port)=0
 Returns high-level color sensor using camera on given port (video0 or video1). More...
 
virtual trikControl::ObjectSensorInterfaceobjectSensor (const QString &port)=0
 Returns high-level object detector sensor using camera on given port (video0 or video1). More...
 
virtual trikControl::I2cDeviceInterfacei2c (int bus, int address)=0
 Returns i2c device object. More...
 
virtual QVector< uint8_t > getStillImage ()=0
 Returns QVector<uin8_t> with image using camera on given port (video0 or video1). More...
 
virtual trikControl::SoundSensorInterfacesoundSensor (const QString &port)=0
 Returns high-level sound detector sensor using microphones. More...
 
virtual trikControl::EncoderInterfaceencoder (const QString &port)=0
 Returns encoder on given port. More...
 
virtual trikControl::BatteryInterfacebattery ()=0
 Returns battery. More...
 
virtual trikControl::KeysInterfacekeys ()=0
 Returns keys on a control brick. More...
 
virtual trikControl::DisplayInterfacedisplay ()=0
 Returns class that provides drawing on display. More...
 
virtual trikControl::LedInterfaceled ()=0
 Returns LED control class. More...
 
virtual trikControl::GamepadInterfacegamepad ()=0
 Returns handler for Android gamepad. More...
 
virtual trikControl::FifoInterfacefifo (const QString &port)=0
 Returns custom FIFO file which can be used as sensor. More...
 
virtual trikControl::MarkerInterfacemarker ()=0
 Returns marker. More...
 
virtual trikControl::EventDeviceInterfaceeventDevice (const QString &deviceFile)=0
 Returns custom event device that can be used as a sensor, for example, for custom gamepad support. More...
 
virtual void stopEventDevice (const QString &deviceFile)=0
 Stops listening given event device and destroys its watcher object. More...
 

Public Member Functions

 Brick (const QString &systemConfig, const QString &modelConfig, const QString &mediaPath)
 Constructor. More...
 
 Brick (trikHal::HardwareAbstractionInterface &hardwareAbstraction, const QString &systemConfig, const QString &modelConfig, const QString &mediaPath)
 Secondary constructor, takes explicit hardware abstraction object. More...
 
 ~Brick () override
 
void reset () override
 Do reset (stop motors, reset keys, clear screen, etc). More...
 
DisplayWidgetInterfacegraphicsWidget () override
 Returns a widget on which display output is drawn. More...
 
QString configVersion () const override
 Returns version of system configuration file. More...
 

Additional Inherited Members

- Signals inherited from trikControl::BrickInterface
void stopped ()
 Emitted when all deferred deinitialization is completed and brick completely stopped. More...
 

Detailed Description

Class representing TRIK controller board and devices installed on it, also provides access to peripherals like motors and sensors.

Is NOT thread-safe.

Constructor & Destructor Documentation

Brick::Brick ( const QString &  systemConfig,
const QString &  modelConfig,
const QString &  mediaPath 
)

Constructor.

Parameters
systemConfig- file name (with path) of system config, absolute or relative to current directory.
modelConfig- file name (with path) of model config, absolute or relative to current directory.
mediaPath- path to the directory with media files (it is expected to be ending with "/").
Brick::Brick ( trikHal::HardwareAbstractionInterface hardwareAbstraction,
const QString &  systemConfig,
const QString &  modelConfig,
const QString &  mediaPath 
)

Secondary constructor, takes explicit hardware abstraction object.

Parameters
hardwareAbstraction- hardware abstraction layer implementation.
systemConfig- file name (with path) of system config, absolute or relative to current directory.
modelConfig- file name (with path) of model config, absolute or relative to current directory.
mediaPath- path to the directory with media files (it is expected to be ending with "/").
Brick::~Brick ( )
override

Member Function Documentation

VectorSensorInterface * Brick::accelerometer ( )
overrideslot
BatteryInterface * Brick::battery ( )
overrideslot
ColorSensorInterface * Brick::colorSensor ( const QString &  port)
overrideslot
void Brick::configure ( const QString &  portName,
const QString &  deviceName 
)
overrideslot
QString Brick::configVersion ( ) const
overridevirtual

Returns version of system configuration file.

Implements trikControl::BrickInterface.

DisplayInterface * Brick::display ( )
overrideslot
EncoderInterface * Brick::encoder ( const QString &  port)
overrideslot
QStringList Brick::encoderPorts ( ) const
overrideslot
EventDeviceInterface * Brick::eventDevice ( const QString &  deviceFile)
overrideslot
trikControl::FifoInterface * Brick::fifo ( const QString &  port)
overrideslot
GamepadInterface * Brick::gamepad ( )
overrideslot
QVector< uint8_t > Brick::getStillImage ( )
overrideslot
DisplayWidgetInterface * Brick::graphicsWidget ( )
overridevirtual

Returns a widget on which display output is drawn.

Implements trikControl::BrickInterface.

GyroSensorInterface * Brick::gyroscope ( )
overrideslot
I2cDeviceInterface * Brick::i2c ( int  bus,
int  address 
)
overrideslot
KeysInterface * Brick::keys ( )
overrideslot
LedInterface * Brick::led ( )
overrideslot
LineSensorInterface * Brick::lineSensor ( const QString &  port)
overrideslot
MarkerInterface * Brick::marker ( )
overrideslot
MotorInterface * Brick::motor ( const QString &  port)
overrideslot
QStringList Brick::motorPorts ( MotorInterface::Type  type) const
overrideslot
ObjectSensorInterface * Brick::objectSensor ( const QString &  port)
overrideslot
void Brick::playSound ( const QString &  soundFileName)
overrideslot
void Brick::playTone ( int  hzFreq,
int  msDuration 
)
overrideslot
PwmCaptureInterface * Brick::pwmCapture ( const QString &  port)
overrideslot
QStringList Brick::pwmCapturePorts ( ) const
overrideslot
void Brick::reset ( )
overridevirtual

Do reset (stop motors, reset keys, clear screen, etc).

We should call it before executing any script with this instance.

Todo:
Temporary, we need more carefully init/deinit range sensors.

Implements trikControl::BrickInterface.

void Brick::say ( const QString &  text)
overrideslot
SensorInterface * Brick::sensor ( const QString &  port)
overrideslot
QStringList Brick::sensorPorts ( SensorInterface::Type  type) const
overrideslot
SoundSensorInterface * Brick::soundSensor ( const QString &  port)
overrideslot
void Brick::stop ( )
overrideslot
Todo:
: Also be able to stop initializing sensor.
void Brick::stopEventDevice ( const QString &  deviceFile)
overrideslot

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