2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 21:47:42 +00:00

Ensure rumble pre-pulse

This commit is contained in:
Jack Andersen
2018-01-26 09:46:35 -10:00
parent 13a31be23b
commit 6f7cd14836
3 changed files with 54 additions and 24 deletions

View File

@@ -15,8 +15,26 @@ CRumbleGenerator::~CRumbleGenerator()
HardStopAll();
}
#define PWM_MONITOR 0
#if PWM_MONITOR
static bool b_tp = false;
static std::chrono::steady_clock::time_point s_tp;
#endif
void CRumbleGenerator::Update(float dt)
{
#if PWM_MONITOR
std::chrono::milliseconds::rep ms = 0;
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
if (!b_tp)
{
b_tp = true;
s_tp = now;
}
else
ms = std::chrono::duration_cast<std::chrono::milliseconds>(now - s_tp).count();
#endif
if (!xf0_24_disabled)
{
bool updated = false;
@@ -29,6 +47,10 @@ void CRumbleGenerator::Update(float dt)
xd0_onTime[i] = 0.f;
if (xe0_commandArray[i] != EMotorState::Stop)
{
#if PWM_MONITOR
s_tp = now;
printf("%lldms ON\n", ms);
#endif
xe0_commandArray[i] = EMotorState::Stop;
updated = true;
}
@@ -41,6 +63,10 @@ void CRumbleGenerator::Update(float dt)
xc0_periodTime[i] = 0.f;
if (xe0_commandArray[i] != EMotorState::Rumble)
{
#if PWM_MONITOR
s_tp = now;
printf("%lldms Off\n", ms);
#endif
xe0_commandArray[i] = EMotorState::Rumble;
updated = true;
}
@@ -53,6 +79,10 @@ void CRumbleGenerator::Update(float dt)
xd0_onTime[i] = 0.f;
if (xe0_commandArray[i] != EMotorState::Stop)
{
#if PWM_MONITOR
s_tp = now;
printf("%lldms ON\n", ms);
#endif
xe0_commandArray[i] = EMotorState::Stop;
updated = true;
}