diff options
author | Uros Majstorovic <majstor@majstor.org> | 2022-05-13 12:26:19 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2022-05-13 12:26:19 +0200 |
commit | 9ccb4db8d59ec9dab33ee8617d462f21a8bb4fa8 (patch) | |
tree | a4f8ba9375a4ee82bae6ddc0cb3a35227f6f9469 /fw/fe310/eos/eve/eve_phy.c | |
parent | 45f0d9b890b086493f9bb06428c46cd802324223 (diff) |
touch controller/eve fixes
Diffstat (limited to 'fw/fe310/eos/eve/eve_phy.c')
-rw-r--r-- | fw/fe310/eos/eve/eve_phy.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/fw/fe310/eos/eve/eve_phy.c b/fw/fe310/eos/eve/eve_phy.c index 1e255fe..09a86c6 100644 --- a/fw/fe310/eos/eve/eve_phy.c +++ b/fw/fe310/eos/eve/eve_phy.c @@ -19,20 +19,27 @@ void eve_phy_acc_start(EVEPhyAcc *param, int x0, int y0, int v0x, int v0y) { param->k = 2 * v0 / param->a * EVE_RTC_FREQ; } -int eve_phy_acc_tick(EVEPhyAcc *param, int dt, int *x, int *y) { +int eve_phy_acc_tick(EVEPhyAcc *param, uint32_t dt, int *x, int *y) { int k = param->k; int x0 = param->x0; int y0 = param->y0; int v0x = param->v0x; int v0y = param->v0y; + int _dt = dt; int more = 1; + if (k == 0) { + if (x) *x = x0; + if (y) *y = y0; + return 0; + } + if ((k < 0) && (dt >= -k / 2)) { dt = -k / 2; more = 0; } - if (x) *x = x0 + (v0x * dt + v0x * dt / k * dt) / (int)(EVE_RTC_FREQ); - if (y) *y = y0 + (v0y * dt + v0y * dt / k * dt) / (int)(EVE_RTC_FREQ); + if (x) *x = x0 + (v0x * _dt + v0x * _dt / k * _dt) / EVE_RTC_FREQ; + if (y) *y = y0 + (v0y * _dt + v0y * _dt / k * _dt) / EVE_RTC_FREQ; return more; } @@ -55,7 +62,7 @@ int eve_phy_lho_start(EVEPhyLHO *param, int x0, int y0) { param->y0 = y0; } -int eve_phy_lho_tick(EVEPhyLHO *param, int dt, int *x, int *y) { +int eve_phy_lho_tick(EVEPhyLHO *param, uint32_t dt, int *x, int *y) { int ax = param->x0 - param->x; int ay = param->y0 - param->y; int more = 1; |