replace Arecord with Qtmultimedia (requiers pulse?)
This commit is contained in:
@ -1,24 +1,6 @@
|
||||
#include "microcontroller.h"
|
||||
|
||||
Microcontroller::Microcontroller(QIODevice* port): _port(port)
|
||||
{
|
||||
getState();
|
||||
}
|
||||
|
||||
Microcontroller::Microcontroller()
|
||||
{
|
||||
}
|
||||
|
||||
Microcontroller::~Microcontroller()
|
||||
{
|
||||
if(_port != nullptr) delete _port;
|
||||
}
|
||||
|
||||
void Microcontroller::setIODevice(QIODevice *port)
|
||||
{
|
||||
_port = port;
|
||||
getState();
|
||||
}
|
||||
//relays
|
||||
|
||||
void Microcontroller::relayToggle(int state, int relay)
|
||||
{
|
||||
@ -30,6 +12,18 @@ void Microcontroller::relayToggle(int state, int relay)
|
||||
if(_port != nullptr) _port->write(buffer, length);
|
||||
}
|
||||
|
||||
void Microcontroller::relayOn(int relay)
|
||||
{
|
||||
relayToggle(true, relay);
|
||||
}
|
||||
|
||||
void Microcontroller::relayOff(int relay)
|
||||
{
|
||||
relayToggle(false, relay);
|
||||
}
|
||||
|
||||
//rgb lights
|
||||
|
||||
void Microcontroller::rgbOn()
|
||||
{
|
||||
if(_port != nullptr) _port->write("rgb on\n", sizeof("rgb on\n")-1);
|
||||
@ -57,16 +51,6 @@ void Microcontroller::setPattern(int pattern)
|
||||
_port->write(buffer, length);
|
||||
}
|
||||
|
||||
void Microcontroller::relayOn(int relay)
|
||||
{
|
||||
relayToggle(true, relay);
|
||||
}
|
||||
|
||||
void Microcontroller::relayOff(int relay)
|
||||
{
|
||||
relayToggle(false, relay);
|
||||
}
|
||||
|
||||
bool Microcontroller::connected()
|
||||
{
|
||||
if(_port != nullptr) return _port->isOpen();
|
||||
@ -86,7 +70,7 @@ void Microcontroller::run()
|
||||
loop->exec();
|
||||
}
|
||||
|
||||
void Microcontroller::getState()
|
||||
void Microcontroller::requestState()
|
||||
{
|
||||
if(_port != nullptr) _port->write("relay state\n", sizeof("relay state\n"));
|
||||
}
|
||||
@ -100,6 +84,34 @@ void Microcontroller::abort()
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<bool> Microcontroller::getLastState()
|
||||
{
|
||||
return _relayStates;
|
||||
}
|
||||
|
||||
//housekeeping
|
||||
|
||||
Microcontroller::Microcontroller(QIODevice* port): _port(port)
|
||||
{
|
||||
requestState();
|
||||
}
|
||||
|
||||
Microcontroller::Microcontroller()
|
||||
{
|
||||
}
|
||||
|
||||
Microcontroller::~Microcontroller()
|
||||
{
|
||||
if(_port != nullptr) delete _port;
|
||||
}
|
||||
|
||||
void Microcontroller::setIODevice(QIODevice *port)
|
||||
{
|
||||
_port = port;
|
||||
requestState();
|
||||
}
|
||||
|
||||
|
||||
void Microcontroller::processMicroReturn()
|
||||
{
|
||||
QString workbuff = _buffer;
|
||||
|
Reference in New Issue
Block a user