diff options
Diffstat (limited to 'client/ui_dirc.c')
-rw-r--r-- | client/ui_dirc.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/client/ui_dirc.c b/client/ui_dirc.c index 61abaf4..118a3ea 100644 --- a/client/ui_dirc.c +++ b/client/ui_dirc.c @@ -4,49 +4,49 @@ void w2_ui_bar_graph(unsigned int percent) { unsigned int width = g_w2_ui_width - 7; char bar[width]; - for(unsigned int i = 0; i < width - 2; i++) { - bar[i+1] = i > (width - 2) * percent / 100 ? ' ' : '*'; + for (unsigned int i = 0; i < width - 2; i++) { + bar[i + 1] = i > (width - 2) * percent / 100 ? ' ' : '*'; } - bar[0] = '|'; + bar[0] = '|'; bar[width - 1] = '|'; mvaddnstr(4, 7, bar, width); } -#define W2_DIRC_MOD ((double) 0.95) -#define W2_DIRC_ADD ((double) 13.0) -#define W2_DIRC_PAD ((double) 1.10) -#define W2_DIRC_SPL ((unsigned int) 20) +#define W2_DIRC_MOD ((double)0.95) +#define W2_DIRC_ADD ((double)13.0) +#define W2_DIRC_PAD ((double)1.10) +#define W2_DIRC_SPL ((unsigned int)20) -int w2_avg(int* samples, unsigned int sample_count) { +int w2_avg(int *samples, unsigned int sample_count) { double total = 0; for (int i = 0; i < sample_count; i++) { - total += (double) samples[i] / (double) sample_count; + total += (double)samples[i] / (double)sample_count; } - return (int) total; + return (int)total; } -#define W2_DIRC_MOTOR_DRIVER(name) \ -int w2_dirc_motor_##name(unsigned int forward, unsigned int backward) {\ - static unsigned int idx = 0;\ - \ - static double drive = 0.f;\ - static int drive_avg[W2_DIRC_SPL] = {0};\ - \ - drive *= W2_DIRC_MOD;\ - drive += W2_DIRC_ADD * forward + -W2_DIRC_ADD * backward;\ - drive = W2_RANGE(-254, drive, 255);\ - \ - idx = (idx + 1) % W2_DIRC_SPL;\ - drive_avg[idx] = (int) W2_RANGE(-254, drive * W2_DIRC_PAD, 255);\ - \ - return w2_avg(drive_avg, W2_DIRC_SPL);\ -} +#define W2_DIRC_MOTOR_DRIVER(name) \ + int w2_dirc_motor_##name(unsigned int forward, unsigned int backward) { \ + static unsigned int idx = 0; \ + \ + static double drive = 0.f; \ + static int drive_avg[W2_DIRC_SPL] = {0}; \ + \ + drive *= W2_DIRC_MOD; \ + drive += W2_DIRC_ADD * forward + -W2_DIRC_ADD * backward; \ + drive = W2_RANGE(-254, drive, 255); \ + \ + idx = (idx + 1) % W2_DIRC_SPL; \ + drive_avg[idx] = (int)W2_RANGE(-254, drive * W2_DIRC_PAD, 255); \ + \ + return w2_avg(drive_avg, W2_DIRC_SPL); \ + } W2_DIRC_MOTOR_DRIVER(l); W2_DIRC_MOTOR_DRIVER(r); void w2_ui_dirc() { - int ch = 0; + int ch = 0; unsigned int lb = 0; unsigned int lf = 0; unsigned int rb = 0; |