diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-25 00:57:32 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-25 00:58:15 -0700 |
commit | 9edcd68e7ddcdc4deca8c07b5b1c3c59cef13255 (patch) | |
tree | 1a7a0069e8d51709238d991dc43f0323ec32bb9c /board.h | |
parent | 9a02c0367351c311734f42ab2afe2b377ca12908 (diff) | |
download | dartboat-9edcd68e7ddcdc4deca8c07b5b1c3c59cef13255.tar.gz dartboat-9edcd68e7ddcdc4deca8c07b5b1c3c59cef13255.tar.xz |
pregenerate segment names to avoid constant mallocs
Diffstat (limited to 'board.h')
-rw-r--r-- | board.h | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -14,6 +14,14 @@ #define TREBLE_INSIDE_WIDTH 8.0 #define SEGMENT_MAX_LEN 5 + +#define FOREACH_SECTOR(M) \ + M(1) M(2) M(3) M(4) M(5) M(6) M(7) M(8) M(9) M(10) \ + M(11) M(12) M(13) M(14) M(15) M(16) M(17) M(18) M(19) M(20) +#define GEN_SECTOR_STR(X) #X, +#define GEN_SECTOR_STR_D(X) "D" #X, +#define GEN_SECTOR_STR_T(X) "T" #X, + // distance from centre to apex of outer wire // must be ordered outwards from centre #define FOREACH_RING(M) \ @@ -26,7 +34,7 @@ WIRE_WIDTH/2) \ M(DOUBLE, DOUBLE_OUTER_EDGE - WIRE_WIDTH/2) #define GEN_RING_ENUM(X, D) R_ ## X, -#define GEN_RING_STRING(X, D) #X, +#define GEN_RING_STR(X, D) #X, #define GEN_RING_OUTER_DIST(X, D) D, enum ring { FOREACH_RING(GEN_RING_ENUM) @@ -52,7 +60,7 @@ struct pcoords { }; struct segment get_segment(struct pcoords c); -char *segment_name(struct segment seg); +const char *segment_name(struct segment seg); int segment_points(struct segment seg); bool segment_is_double(struct segment seg); struct pcoords segment_centre(struct segment seg); |