aboutsummaryrefslogtreecommitdiff
path: root/client/ui_dirc.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-30 17:42:35 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-30 17:42:35 +0200
commit139651d45a72d57c5147e2854647d95cb87c9e4e (patch)
treed88e78dd9fbae16334b18fb9e6cb1e07b65f0cde /client/ui_dirc.c
parent056c70e0861bd1b95007e08df86ac4c4d83f2165 (diff)
`make format`
Diffstat (limited to 'client/ui_dirc.c')
-rw-r--r--client/ui_dirc.c54
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;