|
@@ -0,0 +1,66 @@
|
|
|
+
|
|
|
+#include <stdio.h>
|
|
|
+#include <stdint.h>
|
|
|
+
|
|
|
+#define BITS_PER_SUBCOLOR 8
|
|
|
+#define BITS_PER_COLOR (BITS_PER_SUBCOLOR*3)
|
|
|
+
|
|
|
+// uncomment this line to reverse bit order
|
|
|
+//#define BIT_ORDER_REVERSE
|
|
|
+
|
|
|
+// Set only one color
|
|
|
+void gen_cmd_setc(uint8_t *buf, char c)
|
|
|
+{
|
|
|
+ uint8_t b = 1;
|
|
|
+
|
|
|
+#ifdef BIT_ORDER_REVERSE
|
|
|
+ uint8_t *p = buf;
|
|
|
+#else
|
|
|
+ uint8_t *p = &buf[BITS_PER_SUBCOLOR-1];
|
|
|
+#endif
|
|
|
+
|
|
|
+ while (b) {
|
|
|
+ *p = c&b ? 14 : 8;
|
|
|
+
|
|
|
+#ifdef BIT_ORDER_REVERSE
|
|
|
+ p++;
|
|
|
+#else
|
|
|
+ p--;
|
|
|
+#endif
|
|
|
+
|
|
|
+ b <<= 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void gen_cmd_setrgb(uint8_t *buf, char r, char g, char b)
|
|
|
+{
|
|
|
+ gen_cmd_setc( buf, r);
|
|
|
+ gen_cmd_setc(&buf[ BITS_PER_SUBCOLOR], g);
|
|
|
+ gen_cmd_setc(&buf[2*BITS_PER_SUBCOLOR], b);
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+int main()
|
|
|
+{
|
|
|
+ uint8_t cmd[BITS_PER_COLOR];
|
|
|
+
|
|
|
+ gen_cmd_setrgb(cmd, 255, 1, 128);
|
|
|
+
|
|
|
+ /*
|
|
|
+ int r = blahblah_Transmit(&someWhere, &cmd, BITS_PER_COLOR);
|
|
|
+ if (r != HAL_OK) {
|
|
|
+ blink_alaRRM_leds();
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ int i=0;
|
|
|
+ while (i < BITS_PER_COLOR)
|
|
|
+ printf("% 3i", cmd[i++]);
|
|
|
+ printf("\n");
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|