summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-29 17:01:19 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-29 17:01:19 +0200
commit1c7c0bd747c839fb1e449e98cec942894821addf (patch)
tree01ac940d42dcfc767afa191efd7ecbd0ab73dcc5
parent59802547c336d61aa7e950414a3f44180e211974 (diff)
`make format`
-rw-r--r--client/commands.c19
-rw-r--r--client/commands.h7
-rw-r--r--client/errcatch.c1
-rw-r--r--client/main.c4
-rw-r--r--client/main.h1
-rw-r--r--client/serial.c29
-rw-r--r--client/setup.c8
-rw-r--r--client/setup.h2
-rw-r--r--client/time.h4
-rw-r--r--client/time_linux.c4
-rw-r--r--client/ui.c9
-rw-r--r--client/ui.h5
-rw-r--r--shared/errcatch.c3
-rw-r--r--shared/errcatch.h3
-rw-r--r--shared/serial_parse.c3
15 files changed, 36 insertions, 66 deletions
diff --git a/client/commands.c b/client/commands.c
index 67025f4..1ab79fb 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -1,10 +1,10 @@
#include <stdlib.h>
-#include "commands.h"
-#include "time.h"
-#include "main.h"
#include "../shared/bin.h"
#include "../shared/protocol.h"
+#include "commands.h"
+#include "main.h"
+#include "time.h"
void w2_send_bin(w2_s_bin *data) {
w2_serial_write("\xff", 1);
@@ -14,27 +14,26 @@ void w2_send_bin(w2_s_bin *data) {
}
}
-w2_s_bin* w2_send_info() {
+w2_s_bin *w2_send_info() {
size_t msg_size = sizeof(w2_s_cmd_info_rx);
w2_s_cmd_info_rx *msg = malloc(msg_size);
msg->opcode = W2_CMD_INFO | W2_CMDDIR_RX;
- w2_s_bin *msg_bin = w2_bin_s_alloc(msg_size, (uint8_t *)msg);
+ w2_s_bin *msg_bin = w2_bin_s_alloc(msg_size, (uint8_t *)msg);
w2_send_bin(msg_bin);
free(msg);
free(msg_bin);
}
-w2_s_bin* w2_send_ping() {
- g_w2_state.ping_id = (uint8_t) rand();
+w2_s_bin *w2_send_ping() {
+ g_w2_state.ping_id = (uint8_t)rand();
size_t msg_size = sizeof(w2_s_cmd_ping_rx);
w2_s_cmd_ping_rx *msg = malloc(msg_size);
msg->opcode = W2_CMD_PING | W2_CMDDIR_RX;
- msg->id = g_w2_state.ping_id;
- w2_s_bin *msg_bin = w2_bin_s_alloc(msg_size, (uint8_t *)msg);
+ msg->id = g_w2_state.ping_id;
+ w2_s_bin *msg_bin = w2_bin_s_alloc(msg_size, (uint8_t *)msg);
w2_send_bin(msg_bin);
free(msg);
free(msg_bin);
w2_timer_start(W2_TIMER_PING);
}
-
diff --git a/client/commands.h b/client/commands.h
index aa4b964..949360e 100644
--- a/client/commands.h
+++ b/client/commands.h
@@ -1,8 +1,7 @@
#pragma once
-#include "serial.h"
#include "../shared/bin.h"
+#include "serial.h"
-w2_s_bin* w2_send_info();
-w2_s_bin* w2_send_ping();
-
+w2_s_bin *w2_send_info();
+w2_s_bin *w2_send_ping();
diff --git a/client/errcatch.c b/client/errcatch.c
index e8d696a..5e39b00 100644
--- a/client/errcatch.c
+++ b/client/errcatch.c
@@ -16,4 +16,3 @@ void w2_errcatch_handle_error(w2_s_error *error) {
return;
}
-
diff --git a/client/main.c b/client/main.c
index 530af2a..8fe6d8e 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1,7 +1,7 @@
-#include "setup.h"
-#include "../shared/errcatch.h"
#include "main.h"
+#include "../shared/errcatch.h"
#include "serial.h"
+#include "setup.h"
#include "ui.h"
w2_s_client_state g_w2_state;
diff --git a/client/main.h b/client/main.h
index f81e8ce..462da73 100644
--- a/client/main.h
+++ b/client/main.h
@@ -10,4 +10,3 @@ typedef struct {
} w2_s_client_state;
extern w2_s_client_state g_w2_state;
-
diff --git a/client/serial.c b/client/serial.c
index ec523cc..0d0bca7 100644
--- a/client/serial.c
+++ b/client/serial.c
@@ -1,8 +1,8 @@
#include "serial.h"
-#include "time.h"
-#include "main.h"
#include "../shared/protocol.h"
#include "../shared/serial_parse.h"
+#include "main.h"
+#include "time.h"
void w2_serial_main() {
int temp;
@@ -14,24 +14,12 @@ void w2_cmd_ping_tx(w2_s_bin *data) {
g_w2_state.ping = w2_timer_end(W2_TIMER_PING);
printf("ping measured, %ims\n", g_w2_state.ping);
}
-void w2_cmd_expt_tx(w2_s_bin *data) {
- printf("w2_cmd_expt_tx()\n");
-}
-void w2_cmd_mode_tx(w2_s_bin *data) {
- printf("w2_cmd_mode_tx()\n");
-}
-void w2_cmd_cord_tx(w2_s_bin *data) {
- printf("w2_cmd_cord_tx()\n");
-}
-void w2_cmd_bomd_tx(w2_s_bin *data) {
- printf("w2_cmd_bomd_tx()\n");
-}
-void w2_cmd_sens_tx(w2_s_bin *data) {
- printf("w2_cmd_sens_tx()\n");
-}
-void w2_cmd_info_tx(w2_s_bin *data) {
- printf("w2_cmd_info_tx()\n");
-}
+void w2_cmd_expt_tx(w2_s_bin *data) { printf("w2_cmd_expt_tx()\n"); }
+void w2_cmd_mode_tx(w2_s_bin *data) { printf("w2_cmd_mode_tx()\n"); }
+void w2_cmd_cord_tx(w2_s_bin *data) { printf("w2_cmd_cord_tx()\n"); }
+void w2_cmd_bomd_tx(w2_s_bin *data) { printf("w2_cmd_bomd_tx()\n"); }
+void w2_cmd_sens_tx(w2_s_bin *data) { printf("w2_cmd_sens_tx()\n"); }
+void w2_cmd_info_tx(w2_s_bin *data) { printf("w2_cmd_info_tx()\n"); }
void w2_cmd_ping_rx(w2_s_bin *data) { return; }
void w2_cmd_mode_rx(w2_s_bin *data) { return; }
@@ -46,4 +34,3 @@ void w2_cmd_info_rx(w2_s_bin *data) { return; }
void w2_cmd_disp_rx(w2_s_bin *data) { return; }
void w2_cmd_play_rx(w2_s_bin *data) { return; }
void w2_cmd_cled_rx(w2_s_bin *data) { return; }
-
diff --git a/client/setup.c b/client/setup.c
index 35b761c..2e8cce7 100644
--- a/client/setup.c
+++ b/client/setup.c
@@ -1,18 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
-#include "serial.h"
-#include "setup.h"
-#include "commands.h"
#include "../shared/bin.h"
#include "../shared/protocol.h"
+#include "commands.h"
+#include "serial.h"
+#include "setup.h"
// pointers for endianness check
static const uint16_t _test = 1;
static const uint8_t *_ptest = (uint8_t *)&_test;
uint8_t g_w2_endianness;
-void w2_client_setup(int argc, char** argv) {
+void w2_client_setup(int argc, char **argv) {
if (argc < 2) {
printf("usage: %s <serial port>\n", argv[0]);
exit(1);
diff --git a/client/setup.h b/client/setup.h
index 4b4a040..bcad11e 100644
--- a/client/setup.h
+++ b/client/setup.h
@@ -1,3 +1,3 @@
#pragma once
-void w2_client_setup(int argc, char** argv);
+void w2_client_setup(int argc, char **argv);
diff --git a/client/time.h b/client/time.h
index 75b1f70..253451d 100644
--- a/client/time.h
+++ b/client/time.h
@@ -3,9 +3,7 @@
/** amount of parallel timers */
#define W2_CLIENT_TIMER_COUNT (4)
extern unsigned long g_w2_client_timers[W2_CLIENT_TIMER_COUNT];
-typedef enum {
- W2_TIMER_PING = 0
-} w2_e_client_timers;
+typedef enum { W2_TIMER_PING = 0 } w2_e_client_timers;
void w2_timer_start(w2_e_client_timers label);
unsigned long w2_timer_end(w2_e_client_timers label);
diff --git a/client/time_linux.c b/client/time_linux.c
index 5b72838..f6d50d8 100644
--- a/client/time_linux.c
+++ b/client/time_linux.c
@@ -10,9 +10,7 @@ unsigned long w2_get_time() {
return ((now.tv_sec * 1000) + (now.tv_nsec / 1000000));
}
-void w2_timer_start(w2_e_client_timers label) {
- g_w2_client_timers[label] = w2_get_time();
-}
+void w2_timer_start(w2_e_client_timers label) { g_w2_client_timers[label] = w2_get_time(); }
unsigned long w2_timer_end(w2_e_client_timers label) {
return w2_get_time() - g_w2_client_timers[label];
diff --git a/client/ui.c b/client/ui.c
index 4a8e64d..239065c 100644
--- a/client/ui.c
+++ b/client/ui.c
@@ -9,11 +9,6 @@ void w2_ui_update() {
// measure terminal width and height
}
-void w2_ui_paint() {
+void w2_ui_paint() { w2_ui_paint_statusbar(); }
- w2_ui_paint_statusbar();
-}
-
-void w2_ui_paint_statusbar() {
-
-}
+void w2_ui_paint_statusbar() {}
diff --git a/client/ui.h b/client/ui.h
index 433d610..afb0817 100644
--- a/client/ui.h
+++ b/client/ui.h
@@ -48,11 +48,10 @@ void w2_ui_set_fg(w2_e_colors color);
void w2_ui_set_bg(w2_e_colors color);
/** align `text` `align` with `text` buffer length `length` */
-void w2_ui_align(char* text, w2_e_alignment align, unsigned int length);
+void w2_ui_align(char *text, w2_e_alignment align, unsigned int length);
/**
* trim spaces from `top` and overlay on top of `bottom`
* both strings should be at least `length` long
*/
-void w2_ui_overlay(char* bottom, char* top, unsigned int length);
-
+void w2_ui_overlay(char *bottom, char *top, unsigned int length);
diff --git a/shared/errcatch.c b/shared/errcatch.c
index ff7fc93..76af10a 100644
--- a/shared/errcatch.c
+++ b/shared/errcatch.c
@@ -6,7 +6,7 @@
w2_s_error *g_w2_error_buffer[W2_ERROR_BUFFER_SIZE] = {};
uint8_t g_w2_error_index = 0;
uint8_t g_w2_error_offset = 0;
-bool g_w2_error_buffer_full = 0;
+bool g_w2_error_buffer_full = 0;
bool g_w2_error_uncaught = 0;
void w2_errcatch_main() {
@@ -43,4 +43,3 @@ void w2_errcatch_throw_msg(w2_e_errorcode code, uint16_t length, const char *mes
if (g_w2_error_buffer_full) return;
g_w2_error_index = next_index;
}
-
diff --git a/shared/errcatch.h b/shared/errcatch.h
index 9b14cc2..7f298c1 100644
--- a/shared/errcatch.h
+++ b/shared/errcatch.h
@@ -4,8 +4,8 @@
#include <stdint.h>
-#include "consts.h"
#include "bool.h"
+#include "consts.h"
#define W2_E_TYPE_MASK (0b11 << 6)
@@ -95,4 +95,3 @@ void w2_errcatch_throw_msg(w2_e_errorcode code, uint16_t length, const char *mes
* TODO: doesn't handle null pointers from malloc
*/
w2_s_error *w2_alloc_error(w2_e_errorcode code, uint16_t length, const char *message);
-
diff --git a/shared/serial_parse.c b/shared/serial_parse.c
index 49f4cbf..54b9ab5 100644
--- a/shared/serial_parse.c
+++ b/shared/serial_parse.c
@@ -1,8 +1,8 @@
#include <string.h>
#include "consts.h"
-#include "serial_parse.h"
#include "errcatch.h"
+#include "serial_parse.h"
#ifdef W2_SIM
#include "../robot/orangutan_shim.h"
#endif
@@ -58,4 +58,3 @@ void w2_cmd_handler(uint8_t data[W2_SERIAL_READ_BUFFER_SIZE], uint8_t data_lengt
free(copy);
}
-