Commit ab6c0dee authored by David Košenina's avatar David Košenina

use callibration from eeprom

parent 48f29b62
......@@ -2323,6 +2323,7 @@ void OsciloskopOsciloskop::m_menuItemResetEEPROMOnMenuSelection(wxCommandEvent&
void OsciloskopOsciloskop::m_buttonConnectOnButtonClick(wxCommandEvent& event)
{
pOsciloscope->thread.openUSB(pOsciloscope->settings.getHardware());
pOsciloscope->thread.useEepromCallibration(pOsciloscope->settings.getHardware());
}
void OsciloskopOsciloskop::m_buttonDisconnectOnButtonClick(wxCommandEvent& event)
......
......@@ -570,8 +570,10 @@ int ThreadApi::writeFpgaToArtix7(SHardware1* ctrl1, SHardware2* ctrl2, OscHardwa
}
// open
function(afOpenUsb);
wait();
openUSB(hw);
// callibration
useEepromCallibration(hw);
// fpga
function(afUploadFpga);
......@@ -604,24 +606,27 @@ int ThreadApi::openUSB(OscHardware* hw)
function(afOpenUsb);
wait();
}
}
return 0;
}
int ThreadApi::useEepromCallibration(OscHardware* hw)
{
// callibration
if (SDL_AtomicGet(&open) == 1)
{
SDL_AtomicLock(&lock);
eepromSize = sizeof(OscHardware);
eepromOffset = 256000;
SDL_AtomicUnlock(&lock);
function(afEEPROMRead);
wait();
// callibration
if (SDL_AtomicGet(&open) == 1)
// use callibration from eeprom
if (result(afEEPROMRead) == 0 || eepromData.data.bytes[0] == 0)
{
SDL_AtomicLock(&lock);
eepromSize = sizeof(OscHardware);
eepromOffset = 256000;
SDL_AtomicUnlock(&lock);
function(afEEPROMRead);
wait();
// use callibration from eeprom
if (result(afEEPROMRead) == 0 || eepromData.data.bytes[0] == 0)
{
cJSON* json = hw->json;
SDL_memcpy(hw, &eepromData, eepromSize);
hw->json = json;
}
cJSON* json = hw->json;
SDL_memcpy(hw, &eepromData, eepromSize);
hw->json = json;
}
}
return 0;
......
......@@ -904,6 +904,7 @@ public:
public:
// controlThread
int openUSB(OscHardware* hw);
int useEepromCallibration(OscHardware* hw);
int writeFpgaToArtix7(SHardware1* ctrl1, SHardware2* ctrl2, OscHardware* hw);
int writeUsbToEEPROM(OscHardware* hw);
......
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