Significant revamp of RigState to only send changes. Not done yet.
This commit is contained in:
@@ -299,94 +299,3 @@ int GetI2CSmeterValue(int valueType)
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
|
||||
void doRaduinoToTeensy(UBitxRigState* r) {
|
||||
uint8_t* ptr = (uint8_t*)r;
|
||||
|
||||
Wire.beginTransmission(I2CMETER_ADDR);
|
||||
Wire.write(I2CMETER_RIGINF);
|
||||
//for (size_t i = 0; i < sizeof(UBitxRigState); i++) {
|
||||
// Wire.write(ptr[i]);
|
||||
//}
|
||||
//Note, I can switch this back...
|
||||
Wire.write(ptr, sizeof(UBitxRigState));
|
||||
Wire.endTransmission();
|
||||
|
||||
Serial.println("BEFORE:");
|
||||
Serial.print("VFO A: ");
|
||||
Serial.print(r->vfo[0]);
|
||||
Serial.print(", VFO B: ");
|
||||
Serial.print(r->vfo[1]);
|
||||
Serial.print(", Data Size: ");
|
||||
Serial.print(sizeof(UBitxRigState));
|
||||
Serial.println();
|
||||
|
||||
// First we need to see if there's any updated state.
|
||||
Wire.requestFrom(I2CMETER_ADDR, sizeof(uint8_t));
|
||||
int len = 0;
|
||||
int readflag = Wire.read();
|
||||
if (readflag != 0) {
|
||||
Wire.requestFrom(I2CMETER_ADDR, sizeof(UBitxRigState));
|
||||
|
||||
UBitxRigState tmp;
|
||||
|
||||
//int len = 0;
|
||||
//ptr = (uint8_t*)&tmp;
|
||||
|
||||
while (Wire.available() > 0) {
|
||||
uint8_t b = Wire.read();
|
||||
if (len < sizeof(UBitxRigState)) {
|
||||
ptr[len++] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("AFTER:");
|
||||
Serial.print("VFO A: ");
|
||||
Serial.print(r->vfo[0]);
|
||||
Serial.print(", VFO B: ");
|
||||
Serial.print(r->vfo[1]);
|
||||
Serial.print(", Data Size: ");
|
||||
Serial.print(len);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void updateStateFromRaduino(UBitxRigState& r) {
|
||||
// Note, we really need to be checking a dirty flag for this. But, I don't have a dirty flag in this version of the data type...
|
||||
if (vfoActive == VFO_A) {
|
||||
rigState.vfo[0] = frequency;
|
||||
rigState.flags &= ~UBITX_VFOB_FLAG;
|
||||
} else if (vfoActive == VFO_B) {
|
||||
rigState.vfo[1] = frequency;
|
||||
rigState.flags |= UBITX_VFOB_FLAG;
|
||||
}
|
||||
rigState.rit = ritRxFrequency - frequency;
|
||||
rigState.flags = 0;
|
||||
rigState.flags |= (vfoActive == VFO_B ? UBITX_VFOB_FLAG : 0);
|
||||
rigState.flags |= (cwMode != 0 ? UBITX_CW_FLAG : 0);
|
||||
rigState.flags |= (isUSB != 0 ? UBITX_USB_FLAG : 0);
|
||||
rigState.flags |= (splitOn != 0 ? UBITX_SPLIT_FLAG : 0);
|
||||
rigState.flags |= (ritOn != 0 ? UBITX_RIT_FLAG : 0);
|
||||
}
|
||||
|
||||
void updateRaduinoFromState(UBitxRigState& r) {
|
||||
vfoActive = rigState.flags & UBITX_VFOB_FLAG ? VFO_B : VFO_A;
|
||||
if (vfoActive == VFO_A) {
|
||||
if (rigState.vfo[0] != frequency) {
|
||||
setFrequency(rigState.vfo[0]);
|
||||
}
|
||||
} else if (vfoActive == VFO_B) {
|
||||
if (rigState.vfo[1] != frequency) {
|
||||
setFrequency(rigState.vfo[1]);
|
||||
}
|
||||
}
|
||||
ritRxFrequency = frequency + rigState.rit;
|
||||
splitOn = rigState.flags & UBITX_SPLIT_FLAG ? 1 : 0;
|
||||
ritOn = rigState.flags & UBITX_RIT_FLAG ? 1 : 0;
|
||||
isUSB = rigState.flags & UBITX_USB_FLAG ? 1 : 0;
|
||||
if (rigState.flags & UBITX_CW_FLAG) {
|
||||
cwMode = isUSB ? 2 : 1; // 2 = cwu / 1 = cwl
|
||||
} else {
|
||||
cwMode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user