Commit 4464b45d authored by David Košenina's avatar David Košenina

- new firmware

- more responsive user interface while hardware is busy
- 500Mhz friendly controls
- calibrate save fix
parent 9e2d21a0
......@@ -84,8 +84,7 @@ void OsciloskopSoftwareGenerator::SoftwareGeneratorOnInitDialog(wxInitDialogEven
}
}
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_comboBoxType0OnCombobox(wxCommandEvent& event)
......@@ -93,8 +92,7 @@ void OsciloskopSoftwareGenerator::m_comboBoxType0OnCombobox(wxCommandEvent& even
// TODO: Implement m_comboBoxType0OnCombobox
pOsciloscope->window.softwareGenerator.channel[0].type = (GenerateType)m_comboBoxType0->GetSelection();
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_textCtrlPeriod0OnTextEnter(wxCommandEvent& event)
......@@ -102,8 +100,7 @@ void OsciloskopSoftwareGenerator::m_textCtrlPeriod0OnTextEnter(wxCommandEvent& e
// TODO: Implement m_textCtrlPeriod0OnTextEnter
pOsciloscope->window.softwareGenerator.channel[0].period = pFormat->stringToFloat(m_textCtrlPeriod0->GetValue().ToAscii().data()) * multiplyerFromEnum(m_comboBoxPeriod0->GetSelection());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_comboBoxPeriod0OnCombobox(wxCommandEvent& event)
......@@ -111,8 +108,7 @@ void OsciloskopSoftwareGenerator::m_comboBoxPeriod0OnCombobox(wxCommandEvent& ev
// TODO: Implement m_comboBoxPeriod0OnCombobox
pOsciloscope->window.softwareGenerator.channel[0].period = pFormat->stringToFloat(m_textCtrlPeriod0->GetValue().ToAscii().data()) * multiplyerFromEnum(m_comboBoxPeriod0->GetSelection());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_textCtrlPeek0OnTextEnter(wxCommandEvent& event)
......@@ -120,8 +116,7 @@ void OsciloskopSoftwareGenerator::m_textCtrlPeek0OnTextEnter(wxCommandEvent& eve
// TODO: Implement m_textCtrlPeek0OnTextEnter
pOsciloscope->window.softwareGenerator.channel[0].peakToPeak = pFormat->stringToFloat(m_textCtrlPeek0->GetValue().ToAscii().data()) * multiplyerFromEnum(m_comboBoxPeek0->GetSelection());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_comboBoxPeek0OnCombobox(wxCommandEvent& event)
......@@ -129,8 +124,7 @@ void OsciloskopSoftwareGenerator::m_comboBoxPeek0OnCombobox(wxCommandEvent& even
// TODO: Implement m_comboBoxPeek0OnCombobox
pOsciloscope->window.softwareGenerator.channel[0].peakToPeak = pFormat->stringToFloat(m_textCtrlPeek0->GetValue().ToAscii().data()) * multiplyerFromEnum(m_comboBoxPeek0->GetSelection());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_textCtrlSpeed0OnTextEnter(wxCommandEvent& event)
......@@ -138,8 +132,7 @@ void OsciloskopSoftwareGenerator::m_textCtrlSpeed0OnTextEnter(wxCommandEvent& ev
// TODO: Implement m_textCtrlSpeed0OnTextEnter
pOsciloscope->window.softwareGenerator.channel[0].speed = pFormat->stringToFloat(m_textCtrlSpeed0->GetValue().ToAscii().data());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_textCtrlAvery0OnTextEnter(wxCommandEvent& event)
......@@ -147,16 +140,14 @@ void OsciloskopSoftwareGenerator::m_textCtrlAvery0OnTextEnter(wxCommandEvent& ev
// TODO: Implement m_textCtrlAvery0OnTextEnter
pOsciloscope->window.softwareGenerator.channel[0].every = pFormat->stringToFloat(m_textCtrlAvery0->GetValue().ToAscii().data());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_buttonOn0OnButtonClick(wxCommandEvent& event)
{
pOsciloscope->window.softwareGenerator.channel[0].onOff = 1;
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
if(!pOsciloscope->settings.getColors()->windowDefault)
{
m_buttonOn0->SetBackgroundColour(pOsciloscope->settings.getColors()->windowFront);
......@@ -170,8 +161,7 @@ void OsciloskopSoftwareGenerator::m_buttonOff0OnButtonClick(wxCommandEvent& even
{
pOsciloscope->window.softwareGenerator.channel[0].onOff = 0;
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
if(!pOsciloscope->settings.getColors()->windowDefault)
{
m_buttonOn0->SetBackgroundColour(pOsciloscope->settings.getColors()->windowBack);
......@@ -187,8 +177,7 @@ void OsciloskopSoftwareGenerator::m_comboBoxType1OnCombobox(wxCommandEvent& even
// TODO: Implement m_comboBoxType1OnCombobox
pOsciloscope->window.softwareGenerator.channel[1].type = (GenerateType)m_comboBoxType1->GetSelection();
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
......@@ -197,8 +186,7 @@ void OsciloskopSoftwareGenerator::m_textCtrlPeriod1OnTextEnter(wxCommandEvent& e
// TODO: Implement m_textCtrlPeriod1OnTextEnter
pOsciloscope->window.softwareGenerator.channel[1].period = pFormat->stringToFloat(m_textCtrlPeriod1->GetValue().ToAscii().data()) * multiplyerFromEnum(m_comboBoxPeriod1->GetSelection());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_comboBoxPeriod1OnCombobox(wxCommandEvent& event)
......@@ -206,8 +194,7 @@ void OsciloskopSoftwareGenerator::m_comboBoxPeriod1OnCombobox(wxCommandEvent& ev
// TODO: Implement m_comboBoxPeriod1OnCombobox
pOsciloscope->window.softwareGenerator.channel[1].period = pFormat->stringToFloat(m_textCtrlPeriod1->GetValue().ToAscii().data()) * multiplyerFromEnum(m_comboBoxPeriod1->GetSelection());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_textCtrlPeek1OnTextEnter(wxCommandEvent& event)
......@@ -215,8 +202,7 @@ void OsciloskopSoftwareGenerator::m_textCtrlPeek1OnTextEnter(wxCommandEvent& eve
// TODO: Implement m_textCtrlPeek1OnTextEnter
pOsciloscope->window.softwareGenerator.channel[1].peakToPeak = pFormat->stringToFloat(m_textCtrlPeek1->GetValue().ToAscii().data()) * multiplyerFromEnum(m_comboBoxPeek1->GetSelection());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_comboBoxPeek1OnCombobox(wxCommandEvent& event)
......@@ -224,8 +210,7 @@ void OsciloskopSoftwareGenerator::m_comboBoxPeek1OnCombobox(wxCommandEvent& even
// TODO: Implement m_comboBoxPeek1OnCombobox
pOsciloscope->window.softwareGenerator.channel[1].peakToPeak = pFormat->stringToFloat(m_textCtrlPeek1->GetValue().ToAscii().data()) * multiplyerFromEnum(m_comboBoxPeek1->GetSelection());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_textCtrlSpeed1OnTextEnter(wxCommandEvent& event)
......@@ -233,8 +218,7 @@ void OsciloskopSoftwareGenerator::m_textCtrlSpeed1OnTextEnter(wxCommandEvent& ev
// TODO: Implement m_textCtrlSpeed1OnTextEnter
pOsciloscope->window.softwareGenerator.channel[1].speed = pFormat->stringToFloat(m_textCtrlSpeed1->GetValue().ToAscii().data());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_textCtrlAvery1OnTextEnter(wxCommandEvent& event)
......@@ -242,16 +226,14 @@ void OsciloskopSoftwareGenerator::m_textCtrlAvery1OnTextEnter(wxCommandEvent& ev
// TODO: Implement m_textCtrlAvery1OnTextEnter
pOsciloscope->window.softwareGenerator.channel[1].every = pFormat->stringToFloat(m_textCtrlAvery1->GetValue().ToAscii().data());
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
}
void OsciloskopSoftwareGenerator::m_buttonOn1OnButtonClick(wxCommandEvent& event)
{
pOsciloscope->window.softwareGenerator.channel[1].onOff = 1;
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
if(!pOsciloscope->settings.getColors()->windowDefault)
{
m_buttonOn1->SetBackgroundColour(pOsciloscope->settings.getColors()->windowFront);
......@@ -265,8 +247,7 @@ void OsciloskopSoftwareGenerator::m_buttonOff1OnButtonClick(wxCommandEvent& even
{
pOsciloscope->window.softwareGenerator.channel[1].onOff = 0;
SSimulate sim = pOsciloscope->GetServerSim();
sfSetSimulateData(getCtx(), &sim);
sfServerUpload(getCtx());
pOsciloscope->transmitSim(sim);
if(!pOsciloscope->settings.getColors()->windowDefault)
{
m_buttonOn1->SetBackgroundColour(pOsciloscope->settings.getColors()->windowBack);
......
......@@ -2134,6 +2134,8 @@ OsciloscopeMainControl::OsciloscopeMainControl()
{
version = 0;
pControl = 0;
lock = 0;
SDL_AtomicUnlock(&lock);
}
void OsciloscopeMainControl::setVersion(int ver)
......@@ -2151,16 +2153,31 @@ void OsciloscopeMainControl::setVersion(int ver)
void OsciloscopeMainControl::transferData()
{
SDL_AtomicLock(&lock);
if(version == 1)
{
SHardware1 hw = control1.client1Get();
int ret = sfHardwareConfig1(getCtx(), &hw);
hw1 = control1.client1Get();
}
if(version == 2)
{
SHardware2 hw = control2.client2Get();
int ret = sfHardwareConfig2(getCtx(), &hw);
hw2 = control2.client2Get();
}
SDL_AtomicSet(&pOsciloscope->transferData, 1);
SDL_AtomicUnlock(&lock);
}
void OsciloscopeMainControl::threadTransferData()
{
SDL_AtomicLock(&lock);
if (version == 1)
{
int ret = sfHardwareConfig1(getCtx(), &hw1);
}
if (version == 2)
{
int ret = sfHardwareConfig2(getCtx(), &hw2);
}
SDL_AtomicSet(&pOsciloscope->transferData, 0);
SDL_AtomicUnlock(&lock);
}
// server
......
......@@ -660,6 +660,9 @@ public:
class OsciloscopeMainControl : public OsciloscopeControlInterface
{
private:
SHardware1 hw1;
SHardware2 hw2;
SDL_SpinLock lock;
int version;
OsciloscopeControlInterface* pControl;
public:
......@@ -675,6 +678,7 @@ public:
};
public:
void transferData();
void threadTransferData();
public:
void setWindow(WndMain& main);
public:
......
This diff is collapsed.
......@@ -827,12 +827,40 @@ public:
bool serverActive;
SDL_Thread* serverThread;
public:
SEeprom eeprom;
SDL_SpinLock simLock;
SSimulate simData;
SDisplay customDisplayData;
SDL_atomic_t simEnable;
SDL_atomic_t simEnableValue;
SDL_atomic_t version;
SDL_atomic_t headerSize;
SDL_atomic_t maxData;
SDL_atomic_t packetSize;
SDL_atomic_t isConnected;
SDL_atomic_t isOpen;
SDL_atomic_t transferData;
SDL_atomic_t transferSim;
SDL_atomic_t customDisplayCh0;
SDL_atomic_t customDisplayCh1;
SDL_atomic_t customDisplayFun;
SDL_atomic_t customDisplayDig;
SDL_SpinLock customDisplayLock;
public:
SDL_SpinLock usbLock;
SDL_atomic_t aOpenUsb;
SDL_atomic_t aOpenUsbEeprom;
SDL_atomic_t aResetUsb;
SDL_atomic_t aUploadFpga;
SDL_atomic_t aUploadFx2;
SDL_atomic_t aUploadFx3;
SDL_atomic_t aUploadFirmware;
SDL_atomic_t aReadEEPROM;
SDL_atomic_t aWriteEEPROM;
SDL_atomic_t aReadCallibrate;
SDL_atomic_t aWriteCallibrate;
SDL_atomic_t aEraseEEPROM;
SDL_atomic_t aCloseUsb;
public:
SDL_Thread* pHardwareThread;
SDL_Thread* pCatureThread;
......@@ -975,6 +1003,19 @@ public:
void WriteCallibrate();
void EraseEEPROM();
void closeUsb();
public:
void threadOpenUsb(int eeprom = 0);
void threadResetUsb();
void threadUploadFpga();
void threadUploadFx2();
void threadUploadFx3();
void threadUploadFirmware();
void threadReadEEPROM();
void threadWriteEEPROM();
void threadReadCallibrate();
void threadWriteCallibrate();
void threadEraseEEPROM();
void threadCloseUsb();
public:
int start();
int update(float dt);
......@@ -1013,6 +1054,11 @@ public:
void setupControl(WndMain window);
public:
SSimulate GetServerSim();
void transmitSim(SSimulate& sim);
void threadTransmitSim();
public:
void simOnOff(int value);
void threadSimOnOff();
};
SFContext* getCtx();
......
......@@ -1447,8 +1447,7 @@ void OsciloscopeThreadRenderer::renderAnalog(uint threadId, OsciloscopeThreadDat
////////////////////////////////////////////////////////////////////////////////
// double freq
////////////////////////////////////////////////////////////////////////////////
int version = 0;
sfGetFrameVersion(getCtx(), &version);
int version = SDL_AtomicGet(&pOsciloscope->version);
uint doubleFreq = 0;
if(version == HARDWARE_VERSION_2 && wndMain.horizontal.ETS == 0)
{
......
......@@ -120,8 +120,7 @@ uint multiplyerFromValue(float value)
const char* captureTimeToStr(int enumerated)
{
int version = 0;
sfGetFrameVersion(getCtx(), &version);
int version = SDL_AtomicGet(&pOsciloscope->version);
if(version == 1)
{
switch(enumerated)
......@@ -356,8 +355,7 @@ double captureTimeFromEnumVersion(int enumerated, int version)
ECallibrationType getCallibrationType(int enumerated)
{
int version = 0;
sfGetFrameVersion(getCtx(), &version);
int version = SDL_AtomicGet(&pOsciloscope->version);
if(version == 2 && enumerated == t2c2ns)
{
return ct500Mhz;
......@@ -367,8 +365,7 @@ ECallibrationType getCallibrationType(int enumerated)
ECallibrationType getCallibrationType(float value)
{
int version = 0;
sfGetFrameVersion(getCtx(), &version);
int version = SDL_AtomicGet(&pOsciloscope->version);
if(version == 2 && captureTimeFromValue(value) == t2c2ns)
{
return ct500Mhz;
......@@ -378,15 +375,13 @@ ECallibrationType getCallibrationType(float value)
double captureTimeFromEnum(int enumerated)
{
int version = 0;
sfGetFrameVersion(getCtx(), &version);
int version = SDL_AtomicGet(&pOsciloscope->version);
return captureTimeFromEnumVersion(enumerated, version);
}
uint captureTimeFromValue(float value)
{
int version = 0;
sfGetFrameVersion(getCtx(), &version);
int version = SDL_AtomicGet(&pOsciloscope->version);
if(version == 1)
{
if(value < 20.f * NANO)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment