Add internal support for panel test modes, and rename "test mode" to "sensor test mode" to make the distinction clearer.

master
Glenn Maynard 6 years ago
parent 63e76f29cc
commit ce261c1ecb
  1. 15
      sdk/SMX.h
  2. 4
      sdk/Windows/SMX.cpp
  3. 4
      sdk/Windows/SMXDevice.cpp
  4. 2
      sdk/Windows/SMXDevice.h
  5. 44
      sdk/Windows/SMXManager.cpp
  6. 8
      sdk/Windows/SMXManager.h

@ -12,6 +12,7 @@
struct SMXInfo;
struct SMXConfig;
enum SensorTestMode;
enum PanelTestMode;
enum SMXUpdateCallbackReason;
struct SMXSensorTestModeData;
@ -101,10 +102,15 @@ SMX_API void SMX_FactoryReset(int pad);
// for diagnostics.
SMX_API void SMX_ForceRecalibration(int pad);
// Set a panel test mode and request test data. This is used by the configuration tool.
// Set a sensor test mode and request test data. This is used by the configuration tool.
SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode);
SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data);
// Set a panel test mode. These only appear as debug lighting on the panel and don't
// return data to us. Lights can't be updated while a panel test mode is active.
// This applies to all connected pads.
SMX_API void SMX_SetPanelTestMode(PanelTestMode mode);
// Return the build version of the DLL, which is based on the git tag at build time. This
// is only intended for diagnostic logging, and it's also the version we show in SMXConfig.
SMX_API const char *SMX_Version();
@ -291,4 +297,11 @@ struct SMXSensorTestModeData
bool iBadJumper[9][4];
};
// The values also correspond with the protocol and must not be changed.
// These are panel-side diagnostics modes.
enum PanelTestMode {
PanelTestMode_Off = '0',
PanelTestMode_PressureTest = '1',
};
#endif

@ -62,8 +62,10 @@ SMX_API void SMX_GetInfo(int pad, SMXInfo *info) { SMXManager::g_pSMX->GetDevice
SMX_API uint16_t SMX_GetInputState(int pad) { return SMXManager::g_pSMX->GetDevice(pad)->GetInputState(); }
SMX_API void SMX_FactoryReset(int pad) { SMXManager::g_pSMX->GetDevice(pad)->FactoryReset(); }
SMX_API void SMX_ForceRecalibration(int pad) { SMXManager::g_pSMX->GetDevice(pad)->ForceRecalibration(); }
SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode) { SMXManager::g_pSMX->GetDevice(pad)->SetSensorTestMode((SensorTestMode) mode); }
SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode) { SMXManager::g_pSMX->GetDevice(pad)->SetSensorTestMode(mode); }
SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data) { return SMXManager::g_pSMX->GetDevice(pad)->GetTestData(*data); }
SMX_API void SMX_SetPanelTestMode(PanelTestMode mode) { SMXManager::g_pSMX->SetPanelTestMode(mode); }
SMX_API void SMX_SetLights(const char lightData[864])
{
SMX_SetLights2(lightData, 864);

@ -359,7 +359,7 @@ void SMX::SMXDevice::Update(wstring &sError)
CheckActive();
SendConfig();
UpdateTestMode();
UpdateSensorTestMode();
{
uint16_t iOldState = m_pConnection->GetInputState();
@ -396,7 +396,7 @@ void SMX::SMXDevice::CheckActive()
}
// Check if we need to request test mode data.
void SMX::SMXDevice::UpdateTestMode()
void SMX::SMXDevice::UpdateSensorTestMode()
{
m_Lock.AssertLockedByCurrentThread();

@ -121,7 +121,7 @@ private:
bool IsConnectedLocked() const;
// Test/diagnostics mode handling.
void UpdateTestMode();
void UpdateSensorTestMode();
void HandleSensorTestDataResponse(const string &sReadBuffer);
SensorTestMode m_WaitingForSensorTestModeResponse = SensorTestMode_Off;
SensorTestMode m_SensorTestMode = SensorTestMode_Off;

@ -135,6 +135,9 @@ void SMX::SMXManager::ThreadMain()
// since this actually just queues commands, which are actually handled in Update.
SendLightUpdates();
// Send panel test mode commands if needed.
UpdatePanelTestMode();
// See if there are any new devices.
AttemptConnections();
@ -246,6 +249,10 @@ void SMX::SMXManager::SetLights(const string sPanelLights[2])
g_Lock.AssertNotLockedByCurrentThread();
LockMutex L(g_Lock);
// Don't send lights when a panel test mode is active.
if(m_PanelTestMode != PanelTestMode_Off)
return;
// Separate top and bottom lights commands.
//
// sPanelLights[iPad] is
@ -491,6 +498,43 @@ void SMX::SMXManager::SendLightUpdates()
m_aPendingLightsCommands.erase(m_aPendingLightsCommands.begin(), m_aPendingLightsCommands.begin()+1);
}
void SMX::SMXManager::SetPanelTestMode(PanelTestMode mode)
{
g_Lock.AssertNotLockedByCurrentThread();
LockMutex Lock(g_Lock);
m_PanelTestMode = mode;
}
void SMX::SMXManager::UpdatePanelTestMode()
{
// If the test mode has changed, send the new test mode.
//
// When the test mode is enabled, send the test mode again periodically, or it'll time
// out on the master and be turned off. Don't repeat the PanelTestMode_Off command.
g_Lock.AssertLockedByCurrentThread();
uint32_t now = GetTickCount();
if(m_PanelTestMode == m_LastSentPanelTestMode &&
(m_PanelTestMode == PanelTestMode_Off || now - m_SentPanelTestModeAtTicks < 1000))
return;
// When we first send the test mode command (not for repeats), turn off lights.
if(m_LastSentPanelTestMode == PanelTestMode_Off)
{
// The 'l' command used to set lights, but it's now only used to turn lights off
// for cases like this.
string sData = "l";
sData.append(108, 0);
sData += "\n";
for(int iPad = 0; iPad < 2; ++iPad)
m_pDevices[iPad]->SendCommandLocked(sData);
}
m_SentPanelTestModeAtTicks = now;
m_LastSentPanelTestMode = m_PanelTestMode;
for(int iPad = 0; iPad < 2; ++iPad)
m_pDevices[iPad]->SendCommandLocked(ssprintf("t %c\n", m_PanelTestMode));
}
void SMX::SMXManager::RunInHelperThread(function<void()> func)
{
m_UserCallbackThread.RunInThread(func);

@ -45,6 +45,7 @@ public:
shared_ptr<SMXDevice> GetDevice(int pad);
void SetLights(const string sLights[2]);
void ReenableAutoLights();
void SetPanelTestMode(PanelTestMode mode);
// Run a function in the user callback thread.
void RunInHelperThread(function<void()> func);
@ -76,6 +77,13 @@ private:
};
vector<PendingCommand> m_aPendingLightsCommands;
double m_fDelayLightCommandsUntil = 0;
// Panel test mode. This is separate from the sensor test mode (pressure display),
// which is handled in SMXDevice.
void UpdatePanelTestMode();
uint32_t m_SentPanelTestModeAtTicks = 0;
PanelTestMode m_PanelTestMode = PanelTestMode_Off;
PanelTestMode m_LastSentPanelTestMode = PanelTestMode_Off;
};
}

Loading…
Cancel
Save