/* ---------------------------------------------------------------------------- * send an ArtDmx packet */ void artnet_sendDmxPacket(void) { static unsigned char sequence = 1; /* prepare artnet Dmx packet */ struct artnet_dmx *msg = (struct artnet_dmx *) &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN]; memset(msg, 0, sizeof(struct artnet_dmx)); strncpy_P((char *) msg->id, artnet_ID, 8); msg->opcode = OP_OUTPUT; msg->versionH = 0; msg->version = PROTOCOL_VERSION; msg->sequence = sequence++; if (sequence == 0) sequence = 1; msg->physical = 1; msg->universe = ((artnet_subNet << 4) | artnet_inputUniverse); msg->lengthHi = HI8(DMX_STORAGE_CHANNELS); msg->length = LO8(DMX_STORAGE_CHANNELS); for (uint8_t i = 0; i < DMX_STORAGE_CHANNELS; i++) msg->dataStart[i] = get_dmx_channel_slot(artnet_inputUniverse, i, artnet_conn_id); /* send packet to artnet_outputTarget */ artnet_send(&artnet_outputTarget, sizeof(struct artnet_dmx) + DMX_STORAGE_CHANNELS); }
void stella_process(void) { #ifdef DMX_STORAGE_SUPPORT if (get_dmx_slot_state(STELLA_UNIVERSE, stella_dmx_conn_id) == DMX_NEWVALUES) { uint8_t mode = get_dmx_channel_slot(STELLA_UNIVERSE, STELLA_UNIVERSE_OFFSET, stella_dmx_conn_id); for (uint8_t i = 0; i < STELLA_CHANNELS; i++) { stella_setValue(mode, i, get_dmx_channel_slot(STELLA_UNIVERSE, STELLA_UNIVERSE_OFFSET + i + 1, stella_dmx_conn_id)); } } #endif /* the main loop is too fast, slow down */ if (stella_fade_counter == 0) { uint8_t i; /* Fade channels. stella_fade_counter is 0 currently. Set to 1 * if fading changed a channel brigthness value */ for (i = 0; i < STELLA_CHANNELS; ++i) { if (stella_brightness[i] == stella_fade[i]) continue; stella_fade_funcs[stella_fade_func].p(i); stella_fade_counter = 1; } if (stella_fade_counter) stella_sync = UPDATE_VALUES; /* reset counter */ stella_fade_counter = stella_fade_step; } /* sort if new values are available */ if (stella_sync == UPDATE_VALUES) stella_sort(); }
void starburst_update() { #ifdef STARBURST_PCA9685 if(get_dmx_universe_state(STARBURST_PCA9685_UNIVERSE,pca9685_dmx_conn_id) == DMX_NEWVALUES) { /*Update values if they are really newer*/ uint8_t tmp=0; for(uint8_t i=0;i<STARBURST_PCA9685_CHANNELS*2;i+=2) { tmp=get_dmx_channel_slot(STARBURST_PCA9685_UNIVERSE,i+STARBURST_PCA9685_OFFSET,pca9685_dmx_conn_id); pca9685_channels[i/2].mode=tmp; tmp=get_dmx_channel_slot(STARBURST_PCA9685_UNIVERSE,i+1+STARBURST_PCA9685_OFFSET,pca9685_dmx_conn_id); if(pca9685_channels[i/2].target != tmp) { /*Update the new target*/ pca9685_channels[i/2].target=tmp; } } } #endif }
void ws2801_main(void) { if ((get_dmx_slot_state(WS2801_UNIVERSE, dmx_conn_id) == DMX_NEWVALUES)&&(ws2801 == 1)) { uint8_t tmp = 0; for(uint8_t i = 0; i < WS2801_CHANNELS; i++) { tmp = get_dmx_channel_slot(WS2801_UNIVERSE, i + WS2801_OFFSET, dmx_conn_id); ws2801_writeByte((uint8_t)tmp); } ws2801_showPixel(); } }
void starburst_process() { if(pca9685_dmx_connected == FALSE) return; starburst_update(); #ifdef STARBURST_PCA9685 for(uint8_t i=0;i<STARBURST_PCA9685_CHANNELS;i++) { /*TODO: Implement a different mode setting scheme: 0: Set without fade 1-9: Fade speed (slow -> fast) */ switch(pca9685_channels[i].mode) { case(STARBURST_MODE_NORMAL): { if(pca9685_channels[i].value != pca9685_channels[i].target) { pca9685_channels[i].value=pca9685_channels[i].target; pca9685_channels[i].update=STARBURST_UPDATE; update=STARBURST_UPDATE; } else pca9685_channels[i].update=STARBURST_NOUPDATE; break; } case(STARBURST_MODE_FADE): { if(pca9685_channels[i].value > pca9685_channels[i].target) { pca9685_channels[i].value--; pca9685_channels[i].update=STARBURST_UPDATE; update=STARBURST_UPDATE; } else if(pca9685_channels[i].value < pca9685_channels[i].target) { pca9685_channels[i].value++; pca9685_channels[i].update=STARBURST_UPDATE; update=STARBURST_UPDATE; } else pca9685_channels[i].update=STARBURST_NOUPDATE; break; } } } #ifdef STARBURST_PCA9685_STROBO /*Hardware stroboscope support: Control all channels of a PCA9685 using the output enable. Value range: 1-25 (results in 1hz - 25hz) */ static uint8_t pca9685_strobo_counter = 0; uint8_t pca9685_strobo = 2*get_dmx_channel_slot(STARBURST_PCA9685_UNIVERSE,STARBURST_PCA9685_CHANNELS*2+STARBURST_PCA9685_OFFSET,pca9685_dmx_conn_id); if(pca9685_strobo > 0 && pca9685_strobo <= 50) { if(pca9685_strobo_counter >= 50/pca9685_strobo) { i2c_pca9685_output_enable(TOGGLE); pca9685_strobo_counter=0; } if(pca9685_strobo_counter<50) pca9685_strobo_counter++; else pca9685_strobo_counter=0; } else i2c_pca9685_output_enable(ON); #endif #endif }