Example #1
0
const uint8_t *dmx_is_data_changed(void) {
	uint32_t i;
	uint8_t const *p = (uint8_t *)dmx_get_available();
	uint32_t *src = (uint32_t *)p;
	uint32_t *dst = (uint32_t *)dmx_data_previous;
	bool is_changed = false;

	if (src == NULL) {
		return NULL;
	}

	const struct _dmx_data *dmx_statistics = (struct _dmx_data *)p;

	if (dmx_statistics->statistics.slots_in_packet != dmx_slots_in_packet_previous) {
		dmx_slots_in_packet_previous = dmx_statistics->statistics.slots_in_packet;
		for (i = 0; i < DMX_DATA_BUFFER_SIZE / 4; i++) {
			*dst= *src;
			dst++;
			src++;
		}
		return p;
	}

	for (i = 0; i < DMX_DATA_BUFFER_SIZE / 4; i++) {
		if (*dst != *src) {
			*dst = *src;
			is_changed = true;
		}
		dst++;
		src++;
	}

	return (is_changed ? p : NULL);
}
Example #2
0
/**
 *
 * The function is registered in the poll table \file main.c
 */
void dmx_handle_data(void)
{
	dmx_handle_data_statistics.function_count++;

	if (dmx_get_available() == FALSE)
			return;

	dmx_available_set(FALSE);

	dmx_handle_data_statistics.dmx_available_count++;

	// const uint16_t personality_current = rdm_device_info_get_personality_current(0);	// Root device

	/*
	 * Add user code here
	 */
}
Example #3
0
/**
 *
 * This function is called from the poll table in \ref main.c
 *
 * Received DMX Packet (Label=5 \ref RECEIVED_DMX_PACKET)
 *
 * The Widget sends this message to the PC unsolicited, whenever the Widget receives a DMX or RDM packet from the DMX port,
 * and the Receive DMX on Change mode (\ref receive_dmx_on_change) is 'Send always' (\ref SEND_ALWAYS).
 */
void widget_received_dmx_packet(void) {
	if (widget_mode == MODE_RDM_SNIFFER) {
		return;
	}

	if (widget_rdm_discovery_running
			|| (DMX_PORT_DIRECTION_INP != dmx_get_port_direction())
			|| (SEND_ON_DATA_CHANGE_ONLY == receive_dmx_on_change)) {
		return;
	}

	const uint8_t *dmx_data = dmx_get_available();

	if (dmx_data == NULL) {
		return;
	}

	const uint32_t micros_now = hardware_micros();

	if (micros_now - widget_received_dmx_packet_start < widget_received_dmx_packet_period) {
		return;
	}

	widget_received_dmx_packet_start = micros_now;

	widget_received_dmx_packet_count++;

	const struct _dmx_data *dmx_statistics = (struct _dmx_data *)dmx_data;
	const uint16_t length = (uint16_t)(dmx_statistics->statistics.slots_in_packet + 1);

	monitor_line(MONITOR_LINE_LABEL, "poll:RECEIVED_DMX_PACKET");
	monitor_line(MONITOR_LINE_INFO, "Send DMX data to HOST, %d", length);
	monitor_line(MONITOR_LINE_STATUS, NULL);

	widget_usb_send_header(RECEIVED_DMX_PACKET, length + 1);
	usb_send_byte(0); 	// DMX Receive status
	widget_usb_send_data(dmx_data, length);
	widget_usb_send_footer();
}