More scary updates. Implemented some basic CAT control via USB serial, for the TeensyDSP. More fully fleshed out a RigState and Rig types. Compiles. Still MAY need to update the Raduino to match the TeensyDSP (it may actually be okay, because right now only the RIGINF command is being sent.

This commit is contained in:
Rob French 2021-02-06 23:45:19 -06:00
parent 4186fdcdd4
commit b9be616361
3 changed files with 17 additions and 62 deletions

View File

@ -1,6 +1,8 @@
#ifndef __RigState_h__
#define __RigState_h__
#include <Arduino.h>
#define UBITX_VFOA_UPDATE 0x01
#define UBITX_VFOB_UPDATE 0x02
#define UBITX_RIT_UPDATE 0x04
@ -18,59 +20,9 @@
struct UBitxRigState {
uint8_t header = 0;
uint32_t vfo[2];
uint16_t rit;
uint16_t xit;
int16_t rit;
int16_t xit;
uint8_t flags = 0;
};
/*
class UBitxRig {
public:
inline int freqA() const { return state.vfo[0]; }
inline int freqB() const { return state.vfo[1]; }
inline int freqRIT() const { return state.rit; }
inline int freqXIT() const { return state.xit; }
inline char vfo() const { return (state.flags & UBITX_VFOB_FLAG) == UBITX_VFOB_FLAG; }
inline char isSplit() const { return (state.flags & UBITX_SPLIT_FLAG) == UBITX_SPLIT_FLAG; }
inline char isRIT() const { return (state.flags & UBITX_RIT_FLAG) == UBITX_RIT_FLAG; }
inline char isXIT() const { return (state.flags & UBITX_XIT_FLAG) == UBITX_XIT_FLAG; }
inline char isCW() const { return (state.flags & UBITX_CW_FLAG) == UBITX_CW_FLAG; }
inline char isLSB() const { return (state.flags & UBITX_USB_FLAG) != UBITX_USB_FLAG; }
inline char isUSB() const { return (state.flags & UBITX_USB_FLAG) == UBITX_USB_FLAG; }
char* packDelta() {
buflen = 0;
// first byte: what fields have changed
buf[buflen++] = uint8_t(state.dirty);
// next (if req'd): VFO A frequency
if (state.dirty & UBITX_VFOA_UPDATE) {
packInt(state.vfo[0];
}
// next (if req'd): VFO B frequency
if (state.dirty & UBITX_VFOB_UPDATE) {
packInt(state.vfo[0];
}
private:
inline void packByte(uint8_t b) { buf[buflen++] = uint8_t(state.dirty);
inline void packInt(int i) {
int tmp = i;
for (int j = 0; j < 32; j+=8) {
tmp = tmp >> j;
buf[buflen++] = uint8_t(tmp & 0x000000FF);
}
}
UBitxRigState state;
uint8_t buf[sizeof(uint8_t) + sizeof(UBitxRigState)];
int buflen = 0;
};
*/
#endif

View File

@ -11,6 +11,7 @@ KD8CEC, Ian Lee
#include "Debug.h"
#include "DSP.h"
#include "Nextion.h"
#include "Rig.h"
#include "RigState.h"
#include "Sensors.h"
#include "TR.h"

View File

@ -47,11 +47,6 @@ bool isTX = false;
/**********************************************************************/
UBitxRigState catState;
UBitxRigState rigState;
/**********************************************************************/
void responseConfig()
{
if (responseCommand == 2)
@ -383,13 +378,14 @@ void i2cReceiveEvent(size_t numBytes)
readCommand = Wire1.read();
if (readCommand == I2CMETER_RIGINF) {
size_t len = 0;
uint8_t* ptr = (uint8_t*)&rigState;
uint8_t* const ptr = Rig.stateAsBytes();
while (Wire.available() > 0) {
uint8_t b = Wire.read();
if (len < sizeof(UBitxRigState)) {
ptr[len++] = b;
}
}
}
Rig.setRaduinoUpdate();
}
}
@ -455,12 +451,18 @@ void i2cRequestEvent(void)
case I2CMETER_RIGINF:
// Receive current rig state; transmit any CAT updates, if required.
Wire1.write(catState.header); // temporary - just writing a single, null byte
break;
//Wire1.write(catState.header); // temporary - just writing a single, null byte
//break;
case I2CMETER_REQCAT:
// Provide latest CAT updates, if any.
//Wire1.write(catState.header); // temporary - just writing a single, null byte
if (Rig.updatedByCAT()) {
Wire1.write(Rig.stateAsBytes(), sizeof(UBitxRigState));
Rig.clearUpdate();
} else {
Wire1.write(Rig.stateAsBytes(), sizeof(uint8_t));
}
break;
default: