aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoe <rbo@gmx.us>2025-09-21 01:21:14 +0200
committerjoe <rbo@gmx.us>2025-09-21 01:21:14 +0200
commit5e5d41cffd035d73ef818d7ea1f4b191f3f008a6 (patch)
tree6a6e8dab8d66a3d8bdf30fbb571146d922cb3939
parentbetter license (diff)
downloadhalfcab-5e5d41cffd035d73ef818d7ea1f4b191f3f008a6.tar.gz
halfcab-5e5d41cffd035d73ef818d7ea1f4b191f3f008a6.tar.bz2
halfcab-5e5d41cffd035d73ef818d7ea1f4b191f3f008a6.tar.xz
halfcab-5e5d41cffd035d73ef818d7ea1f4b191f3f008a6.tar.zst
halfcab-5e5d41cffd035d73ef818d7ea1f4b191f3f008a6.zip
send colors
Diffstat (limited to '')
-rw-r--r--Makefile2
-rw-r--r--src/c_defines.h6
-rw-r--r--src/c_halfcab.c17
-rw-r--r--src/esp/halfcab/halfcab.ino22
4 files changed, 31 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 8746616..761ea4c 100644
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,7 @@ INC_NAME = c_defines
SRCS = $(addprefix ${SRC_DIR}, $(addsuffix .c, ${SRC_NAME}))
INCS = $(addprefix ${SRC_DIR}, $(addsuffix .h, ${SRC_NAME}))
INCS += $(addprefix ${SRC_DIR}, $(addsuffix .h, ${INC_NAME}))
-OBJS = $(patsubst ${SRC_DIR}%.c, ${OBJ_DIR}%.c.o, ${SRCS})
+OBJS = $(patsubst ${SRC_DIR}%.c, ${OBJ_DIR}%.c.o, ${SRCS})
ARDUINO = arduino-cli
CC = cc
diff --git a/src/c_defines.h b/src/c_defines.h
index 608a057..2b82bf6 100644
--- a/src/c_defines.h
+++ b/src/c_defines.h
@@ -65,10 +65,4 @@
#define BLUE CRGB(0, 0, 255)
#define GRUV CRGB(255, 80, 0)
-enum colors_e {
- R,
- G,
- B
-};
-
#endif /* __C_DEFINES_H__ */
diff --git a/src/c_halfcab.c b/src/c_halfcab.c
index cab333c..d67b779 100644
--- a/src/c_halfcab.c
+++ b/src/c_halfcab.c
@@ -66,6 +66,7 @@ param_esp_com
{
struct termios tty;
+ bzero(&tty, sizeof(tty));
if (tcgetattr(fd, &tty) != 0) {
dprintf(
STDERR_FILENO,
@@ -85,7 +86,7 @@ param_esp_com
tty.c_cc[VMIN] = 1; /* read doesn't block */
tty.c_cc[VTIME] = 5; /* 0.5 seconds read timeout */
tty.c_iflag &= ~(IXON | IXOFF | IXANY); /* shut off xon/xoff ctrl */
- tty.c_cflag |= (CLOCAL | CREAD);/* ignore modem controls, enable reading */
+ tty.c_cflag |= (CLOCAL | CREAD); /* ignore modem controls, enable reading */
tty.c_cflag &= ~(PARENB | PARODD); /* no parity */
tty.c_cflag &= ~CSTOPB; /* 1 stop bit */
tty.c_cflag &= ~CRTSCTS; /* no hardware flow control */
@@ -128,10 +129,9 @@ main
{
const char* prog_name = argv[0];
int fd;
- const unsigned char com = 0xff;
+ unsigned char com[4];
+ unsigned char i;
/* const unsigned char data[2] = { 0xfe, 0x00 }; */
- /* unsigned char rgb[3];
- unsigned char i; */
fd = open_esp(prog_name);
if (fd < 0) {
@@ -142,13 +142,16 @@ main
return (EXIT_FAILURE);
}
if (argc < 4) {
+ com[0] = 0xfe;
write(fd, &com, 1 * sizeof(unsigned char));
} else {
- /* i = 1;
+ com[0] = 0xff;
+ i = 1;
while (i < 4) {
- rgb[i] = atoi(argv[i]);
+ com[i] = atoi(argv[i]);
i++;
- } */
+ }
+ write(fd, &com, 4 * sizeof(unsigned char));
}
close(fd);
return (EXIT_SUCCESS);
diff --git a/src/esp/halfcab/halfcab.ino b/src/esp/halfcab/halfcab.ino
index c8935f5..57723d6 100644
--- a/src/esp/halfcab/halfcab.ino
+++ b/src/esp/halfcab/halfcab.ino
@@ -88,7 +88,25 @@ blink(void)
void
plain(void)
{
- fill(GRUV);
+ CRGB color;
+ byte r;
+ byte g;
+ byte b;
+
+ color = BLACK;
+ while (Serial.available() <= 0) {
+ /* empty */
+ }
+ color.r = Serial.read();
+ while (Serial.available() <= 0) {
+ /* empty */
+ }
+ color.g = Serial.read();
+ while (Serial.available() <= 0) {
+ /* empty */
+ }
+ color.b = Serial.read();
+ fill(color);
}
void
@@ -119,7 +137,7 @@ loop(void)
} else {
i = 0;
while (i < NUM_LEDS) {
- leds[i] = GREEN;
+ leds[i] = RED;
i++;
}
FastLED.show();