From ab4e1cfc8c587e4144d847bbd41307eff03130b2 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Tue, 16 Feb 2021 22:26:47 -0500 Subject: rtc timestamp, knob rand, random terminal color --- src/user/highway/vars.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/user/highway/vars.c') diff --git a/src/user/highway/vars.c b/src/user/highway/vars.c index 82062c4..ed9fa3a 100644 --- a/src/user/highway/vars.c +++ b/src/user/highway/vars.c @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -80,4 +81,24 @@ void dump_vars() { term_addf_no_ww("$%ns$\t= %ns\n", node->name.length, node->name.data, node->value.length, node->value.data); term_paint(); } +} + +static const char hex_digits[] = "0123456789abcdef"; +static char color[] = {'1', '0', '.', '.'}; + +static const struct no_null_sn color_name = { + .data = "_color", + .length = 6 +}; + +static const struct no_null_sn color_value = { + .data = color, + .length = 4 +}; + +void new_color() { + const uint8_t bg = gen_rand() % 0x30 + 0x38; + color[2] = hex_digits[bg >> 4]; + color[3] = hex_digits[bg & 0xf]; + set_var(color_name, color_value); } \ No newline at end of file -- cgit v1.2.3