kopia lustrzana https://gitlab.com/eliggett/wfview
More shuttle changes
rodzic
a2d7ae0e56
commit
4bbd06a988
80
shuttle.cpp
80
shuttle.cpp
|
@ -85,12 +85,11 @@ void shuttle::run()
|
|||
|
||||
void shuttle::runTimer()
|
||||
{
|
||||
int res;
|
||||
int res=1;
|
||||
while (res > 0) {
|
||||
QByteArray data(HIDDATALENGTH, 0x0);
|
||||
res = hid_read(handle, (unsigned char*)data.data(), HIDDATALENGTH);
|
||||
if (res == 0)
|
||||
;//printf("waiting...\n");
|
||||
else if (res < 0)
|
||||
if (res < 0)
|
||||
{
|
||||
qInfo() << "USB Device disconnected?";
|
||||
hid_close(handle);
|
||||
|
@ -161,20 +160,45 @@ void shuttle::runTimer()
|
|||
{
|
||||
// This is a response from the Icom RC28
|
||||
data.resize(8); // Might as well get rid of the unused data.
|
||||
qDebug() << "RC28 Data received: "
|
||||
<< hex << (unsigned char)data[0] << ":"
|
||||
<< hex << (unsigned char)data[1] << ":"
|
||||
<< hex << (unsigned char)data[2] << ":"
|
||||
<< hex << (unsigned char)data[3] << ":"
|
||||
<< hex << (unsigned char)data[4] << ":"
|
||||
<< hex << (unsigned char)data[5] << ":"
|
||||
<< hex << (unsigned char)data[6] << ":"
|
||||
<< hex << (unsigned char)data[7];
|
||||
if ((unsigned char)data[0] == 0x01) {
|
||||
|
||||
|
||||
if (((unsigned char)data[5] == 0x06) && ((unsigned char)lastData[5] != 0x06))
|
||||
{
|
||||
emit button(true, 6);
|
||||
}
|
||||
else if (((unsigned char)data[5] != 0x06) && ((unsigned char)lastData[5] == 0x06))
|
||||
{
|
||||
emit button(false, 6);
|
||||
}
|
||||
else if (((unsigned char)data[5] == 0x03) && ((unsigned char)lastData[5] != 0x03))
|
||||
{
|
||||
emit button(true, 7);
|
||||
}
|
||||
else if (((unsigned char)data[5] != 0x03) && ((unsigned char)lastData[5] == 0x03))
|
||||
{
|
||||
emit button(false, 7);
|
||||
}
|
||||
else if (((unsigned char)data[5] == 0x7d) && ((unsigned char)lastData[5] != 0x7d))
|
||||
{
|
||||
emit button(true, 5);
|
||||
}
|
||||
else if (((unsigned char)data[5] != 0x7d) && ((unsigned char)lastData[5] == 0x7d))
|
||||
{
|
||||
emit button(false, 5);
|
||||
}
|
||||
|
||||
if ((unsigned char)data[5] == 0x07)
|
||||
{
|
||||
if ((unsigned char)data[3]==0x01)
|
||||
{
|
||||
qDebug() << "Frequency UP";
|
||||
emit jogPlus();
|
||||
}
|
||||
else if ((unsigned char)data[3] == 0x02)
|
||||
{
|
||||
qDebug() << "Frequency DOWN";
|
||||
emit jogMinus();
|
||||
}
|
||||
}
|
||||
lastData = data;
|
||||
}
|
||||
|
||||
if (lastShuttle.msecsTo(QTime::currentTime()) >= 1000)
|
||||
|
@ -194,8 +218,30 @@ void shuttle::runTimer()
|
|||
lastShuttle = QTime::currentTime();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// Run every 25ms
|
||||
QTimer::singleShot(25, this, SLOT(runTimer()));
|
||||
}
|
||||
|
||||
#define BIT_CLEAR(a,b) ((a) &= ~(1ULL<<(b)))
|
||||
void shuttle::ledControl(bool on, unsigned char num)
|
||||
{
|
||||
QByteArray data(9,0x0);
|
||||
data[0] = 8;
|
||||
data[1] = 0x01;
|
||||
unsigned char ledNum=0x07;
|
||||
if (on)
|
||||
ledNum &= ~(1ULL << (num - 1));
|
||||
|
||||
data[2] = ledNum;
|
||||
|
||||
int res = hid_write(handle, (const unsigned char*)data.constData(), 8);
|
||||
|
||||
if (res < 0) {
|
||||
qDebug() << "Unable to write(), Error:" << hid_error(handle);
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "write() success";
|
||||
|
||||
}
|
|
@ -37,6 +37,7 @@ public slots:
|
|||
void init();
|
||||
void run();
|
||||
void runTimer();
|
||||
void ledControl(bool on, unsigned char num);
|
||||
|
||||
signals:
|
||||
void jogPlus();
|
||||
|
@ -55,7 +56,8 @@ private:
|
|||
unsigned char shutMult = 0;
|
||||
enum { NONE, shuttleXpress, shuttlePro2, RC28 }usbDevice;
|
||||
QTime lastShuttle = QTime::currentTime();
|
||||
|
||||
QByteArray lastData="";
|
||||
unsigned char lastDialPos=0;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue