mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-05 14:35:23 +00:00
Bugfixes
This commit is contained in:
parent
9b1b5e3b5a
commit
1e64875915
21 changed files with 405 additions and 74 deletions
|
|
@ -19,6 +19,10 @@ RawRegisterDialog::RawRegisterDialog(Device *dev, QWidget *parent) :
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// setWindowFlags(Qt::Window);
|
||||
setWindowState(windowState() & Qt::WindowMaximized);
|
||||
// showFullScreen();
|
||||
|
||||
devices.resize(dev->Info().num_directRegisterDevices);
|
||||
|
||||
connect(dev, &Device::ReceivedDirectRegisterInfo, this, &RawRegisterDialog::receivedDirectRegisterInfo);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
<property name="windowTitle">
|
||||
<string>Device Registers</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabs">
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Register::Register(QString name, int address, int width)
|
|||
void Register::assignUI(QCheckBox *cb, int bitpos, bool inverted)
|
||||
{
|
||||
connect(this, &Register::valueChanged, [=](unsigned int newval) {
|
||||
bool bit = newval & (1UL << bitpos);
|
||||
bool bit = newval & (1ULL << bitpos);
|
||||
if(inverted) {
|
||||
bit = !bit;
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ void Register::assignUI(QComboBox *cb, int pos, int width, int ui_bitoffset)
|
|||
{
|
||||
connect(this, &Register::valueChanged, [=]() {
|
||||
auto value = getValue(pos, width);
|
||||
auto mask = (1UL << width) - 1;
|
||||
auto mask = createMask(width);
|
||||
mask <<= ui_bitoffset;
|
||||
value <<= ui_bitoffset;
|
||||
auto old_gui = cb->currentIndex();
|
||||
|
|
@ -58,7 +58,7 @@ void Register::assignUI(QSpinBox *sb, int pos, int width, int ui_bitoffset)
|
|||
{
|
||||
connect(this, &Register::valueChanged, [=]() {
|
||||
auto value = getValue(pos, width);
|
||||
auto mask = (1UL << width) - 1;
|
||||
auto mask = createMask(width);
|
||||
mask <<= ui_bitoffset;
|
||||
value <<= ui_bitoffset;
|
||||
auto old_gui = sb->value();
|
||||
|
|
@ -117,28 +117,28 @@ bool Register::setFromString(QString s)
|
|||
return okay;
|
||||
}
|
||||
|
||||
unsigned long Register::getValue()
|
||||
unsigned long long Register::getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
unsigned long Register::getValue(int pos, int width)
|
||||
unsigned long long Register::getValue(int pos, int width)
|
||||
{
|
||||
unsigned long mask = (1UL << width) - 1;
|
||||
unsigned long mask = createMask(width);
|
||||
mask <<= pos;
|
||||
auto masked = value & mask;
|
||||
masked >>= pos;
|
||||
return masked;
|
||||
}
|
||||
|
||||
void Register::setValue(unsigned long newval)
|
||||
void Register::setValue(unsigned long long newval)
|
||||
{
|
||||
setValue(newval, 0, width);
|
||||
}
|
||||
|
||||
void Register::setValue(unsigned long newval, int pos, int width)
|
||||
void Register::setValue(unsigned long long newval, int pos, int width)
|
||||
{
|
||||
unsigned long mask = (1UL << width) - 1;
|
||||
unsigned long long mask = createMask(width);
|
||||
newval &= mask;
|
||||
newval <<= pos;
|
||||
mask <<= pos;
|
||||
|
|
@ -160,6 +160,13 @@ Register *Register::findByAddress(std::vector<Register *> regs, int address)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned long long Register::createMask(int width)
|
||||
{
|
||||
// can't shift by 64 bits at a time (apparantly a limit of the instruction set: https://stackoverflow.com/questions/55376273/weird-result-in-left-shift-1ull-s-1-if-s-64)
|
||||
// Maximum register width is 64 for now, so shift by one less than width and then shift again by one
|
||||
return ((1ULL << (width - 1)) << 1) - 1;
|
||||
}
|
||||
|
||||
int Register::getAddress() const
|
||||
{
|
||||
return address;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ public:
|
|||
|
||||
QString hexString();
|
||||
bool setFromString(QString hex);
|
||||
unsigned long getValue();
|
||||
unsigned long getValue(int pos, int width);
|
||||
unsigned long long getValue();
|
||||
unsigned long long getValue(int pos, int width);
|
||||
QString getName() const;
|
||||
|
||||
static void fillTableWidget(QTableWidget *w, std::vector<Register*> regs);
|
||||
|
|
@ -37,16 +37,17 @@ public:
|
|||
int getAddress() const;
|
||||
|
||||
public slots:
|
||||
void setValue(unsigned long newval);
|
||||
void setValue(unsigned long newval, int pos, int width);
|
||||
void setValue(unsigned long long newval);
|
||||
void setValue(unsigned long long newval, int pos, int width);
|
||||
signals:
|
||||
void valueChanged(unsigned long newval);
|
||||
void valueChanged(unsigned long long newval);
|
||||
private:
|
||||
static Register *findByAddress(std::vector<Register*> regs, int address);
|
||||
static unsigned long long createMask(int width);
|
||||
QString name;
|
||||
int address;
|
||||
int width;
|
||||
unsigned long value;
|
||||
unsigned long long value;
|
||||
bool updating; // for preventing endless recursion when updating register/its UI connections
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "max2871.h"
|
||||
#include "stw81200.h"
|
||||
#include "ad9913.h"
|
||||
#include "si5332.h"
|
||||
#include "Device/device.h"
|
||||
|
||||
RegisterDevice *RegisterDevice::create(Device *dev, int number, QString partnumber, QString name)
|
||||
|
|
@ -14,6 +15,8 @@ RegisterDevice *RegisterDevice::create(Device *dev, int number, QString partnumb
|
|||
regdev = new STW81200();
|
||||
} else if(partnumber == "AD9913") {
|
||||
regdev = new AD9913();
|
||||
} else if(partnumber == "Si5332") {
|
||||
regdev = new SI5332();
|
||||
}
|
||||
if(regdev) {
|
||||
regdev->dev = dev;
|
||||
|
|
@ -38,7 +41,7 @@ RegisterDevice::~RegisterDevice()
|
|||
delete widget;
|
||||
}
|
||||
|
||||
void RegisterDevice::setRegister(int address, unsigned long value)
|
||||
void RegisterDevice::setRegister(int address, unsigned long long value)
|
||||
{
|
||||
for(auto reg : regs) {
|
||||
if(reg->getAddress() == address) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public:
|
|||
static RegisterDevice *create(Device *dev, int number, QString partnumber, QString name);
|
||||
~RegisterDevice();
|
||||
|
||||
void setRegister(int address, unsigned long value);
|
||||
void setRegister(int address, unsigned long long value);
|
||||
|
||||
QWidget *getWidget() const;
|
||||
QString getPartnumber() const;
|
||||
|
|
|
|||
|
|
@ -60,10 +60,16 @@ SI5332::SI5332()
|
|||
Register::assignUI(regs, 0x35, ui->ID0_CFG_SEL, 6, 1);
|
||||
Register::assignUI(regs, 0x35, ui->HSDIV4_DIV_SEL, 4, 1);
|
||||
Register::assignUI(regs, 0x35, ui->ID1_CFG_SEL, 7, 1);
|
||||
Register::assignUI(regs, 0x35, ui->HSDIV2_DIV_SEL, 3, 1);
|
||||
Register::assignUI(regs, 0x35, ui->HSDIV0_DIV_SEL, 2, 1);
|
||||
Register::assignUI(regs, 0x35, ui->HSDIV3_DIV_SEL, 0, 1);
|
||||
Register::assignUI(regs, 0x35, ui->HSDIV0_DIV_SEL, 1, 1);
|
||||
Register::assignUI(regs, 0x35, ui->HSDIV2_DIV_SEL, 2, 1);
|
||||
Register::assignUI(regs, 0x35, ui->HSDIV0_DIV_SEL, 0, 1);
|
||||
Register::assignUI(regs, 0x35, ui->HSDIV1_DIV_SEL, 1, 1);
|
||||
|
||||
Register::assignUI(regs, 0x36, ui->ID0A_INTG, 0, 8);
|
||||
Register::assignUI(regs, 0x37, ui->ID0A_INTG, 0, 8, 8);
|
||||
Register::assignUI(regs, 0x38, ui->ID0A_RES, 0, 8);
|
||||
Register::assignUI(regs, 0x39, ui->ID0A_RES, 0, 8, 8);
|
||||
Register::assignUI(regs, 0x3A, ui->ID0A_DEN, 0, 8);
|
||||
Register::assignUI(regs, 0x3B, ui->ID0A_DEN, 0, 8, 8);
|
||||
|
||||
Register::fillTableWidget(ui->table, regs);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue