app: parse art-net packets
This commit is contained in:
parent
571038023c
commit
b0ab623968
|
@ -120,6 +120,8 @@ static uint8_t rgbmatrix_data[RGBMATRIX_HEIGHT / 2][RGBMATRIX_WIDTH * 2]; /**< d
|
|||
#define STRIP_W_CH 1 /**< channel used for the white channel */
|
||||
#define STRIP_AF GPIO_AF2 /**< alternate function for pin to be used as timer channel */
|
||||
|
||||
#define UNIVERSE_OFFSET 20 /**< first Art-Net universe to listen to */
|
||||
|
||||
/** set motor speed and direction
|
||||
* @param[in] speed speed (in Hz) and direction (sign)
|
||||
*/
|
||||
|
@ -1174,7 +1176,63 @@ void main(void)
|
|||
if (radio_esp8266_received_len >= 18 && 0 == memcmp((char*)radio_esp8266_received, "Art-Net", 7)) {
|
||||
const uint16_t dmx_universe = radio_esp8266_received[14] + (radio_esp8266_received[15] << 8);
|
||||
const uint16_t dmx_length = radio_esp8266_received[17] + (radio_esp8266_received[16] << 8);
|
||||
printf("Art-Net packet (uni=%u, len=%u)\n", dmx_universe, dmx_length);
|
||||
if (radio_esp8266_received_len >= 18U + dmx_length) {
|
||||
printf("Art-Net packet (uni=%u, len=%u)\n", dmx_universe, dmx_length);
|
||||
switch (dmx_universe) {
|
||||
case UNIVERSE_OFFSET + 0: // RGBW LED strip
|
||||
if (dmx_length >= 0 + 2) {
|
||||
strip_rgbw((radio_esp8266_received[18 + 0] << 8) + radio_esp8266_received[18 + 1], -1, -1, -1);
|
||||
}
|
||||
if (dmx_length >= 2 + 2) {
|
||||
strip_rgbw(-1, (radio_esp8266_received[18 + 2] << 8) + radio_esp8266_received[18 + 3], -1, -1);
|
||||
}
|
||||
if (dmx_length >= 4 + 2) {
|
||||
strip_rgbw(-1, -1, (radio_esp8266_received[18 + 4] << 8) + radio_esp8266_received[18 + 5], -1);
|
||||
}
|
||||
if (dmx_length >= 6 + 2) {
|
||||
strip_rgbw(-1, -1, -1, (radio_esp8266_received[18 + 6] << 8) + radio_esp8266_received[18 + 7]);
|
||||
}
|
||||
break;
|
||||
case UNIVERSE_OFFSET + 1: // dial position
|
||||
if (dmx_length >= 3) {
|
||||
uint32_t dial_position = radio_esp8266_received[18 + 0] * 60 * 60 + radio_esp8266_received[18 + 1] * 60 + radio_esp8266_received[18 + 2];
|
||||
command_dials(&dial_position);
|
||||
}
|
||||
break;
|
||||
case UNIVERSE_OFFSET + 2: // text front line 1
|
||||
if (dmx_length >= 5 && strlen((char*)&radio_esp8266_received[18 + 5]) + 5 < dmx_length) {
|
||||
const int16_t position = (radio_esp8266_received[18 + 3] << 8) + radio_esp8266_received[18 + 4];
|
||||
matrix_puts(false, position, 1, (char*)&radio_esp8266_received[18 + 5], FONT_KING10, radio_esp8266_received[18 + 0], radio_esp8266_received[18 + 1], radio_esp8266_received[18 + 2]);
|
||||
}
|
||||
break;
|
||||
case UNIVERSE_OFFSET + 3: // text front line 2
|
||||
if (dmx_length >= 5 && strlen((char*)&radio_esp8266_received[18 + 5]) + 5 < dmx_length) {
|
||||
const int16_t position = (radio_esp8266_received[18 + 3] << 8) + radio_esp8266_received[18 + 4];
|
||||
matrix_puts(false, position, 12, (char*)&radio_esp8266_received[18 + 5], FONT_KING10, radio_esp8266_received[18 + 0], radio_esp8266_received[18 + 1], radio_esp8266_received[18 + 2]);
|
||||
}
|
||||
break;
|
||||
case UNIVERSE_OFFSET + 4: // text front line 3
|
||||
if (dmx_length >= 5 && strlen((char*)&radio_esp8266_received[18 + 5]) + 5 < dmx_length) {
|
||||
const int16_t position = (radio_esp8266_received[18 + 3] << 8) + radio_esp8266_received[18 + 4];
|
||||
matrix_puts(false, position, 23, (char*)&radio_esp8266_received[18 + 5], FONT_KING10, radio_esp8266_received[18 + 0], radio_esp8266_received[18 + 1], radio_esp8266_received[18 + 2]);
|
||||
}
|
||||
break;
|
||||
case UNIVERSE_OFFSET + 5: // text back line 1
|
||||
if (dmx_length >= 5 && strlen((char*)&radio_esp8266_received[18 + 5]) + 5 < dmx_length) {
|
||||
const int16_t position = (radio_esp8266_received[18 + 3] << 8) + radio_esp8266_received[18 + 4];
|
||||
matrix_puts(true, position, 0, (char*)&radio_esp8266_received[18 + 5], FONT_KING8, radio_esp8266_received[18 + 0], radio_esp8266_received[18 + 1], radio_esp8266_received[18 + 2]);
|
||||
}
|
||||
break;
|
||||
case UNIVERSE_OFFSET + 6: // back front line 2
|
||||
if (dmx_length >= 5 && strlen((char*)&radio_esp8266_received[18 + 5]) + 5 < dmx_length) {
|
||||
const int16_t position = (radio_esp8266_received[18 + 3] << 8) + radio_esp8266_received[18 + 4];
|
||||
matrix_puts(true, position, 8, (char*)&radio_esp8266_received[18 + 5], FONT_KING10, radio_esp8266_received[18 + 0], radio_esp8266_received[18 + 1], radio_esp8266_received[18 + 2]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
radio_esp8266_received_len = 0; // reset flag
|
||||
action = true; // redo main loop
|
||||
|
|
Loading…
Reference in New Issue