mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2026-04-09 03:11:29 +00:00
feat(dmx): implement DMX initialization and sending functionality
This commit is contained in:
parent
a2d51540b7
commit
5370e48d07
6 changed files with 91 additions and 2 deletions
|
|
@ -0,0 +1,43 @@
|
|||
#define LOG_TAG "DMX"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dmx.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "logger.h"
|
||||
|
||||
static void dmx_sender_task(void *pv_parameters) {
|
||||
dmx_port_t port = (dmx_port_t)(intptr_t)pv_parameters;
|
||||
TickType_t last_wake_time = xTaskGetTickCount();
|
||||
|
||||
while (1) {
|
||||
send_dmx(port);
|
||||
vTaskDelayUntil(&last_wake_time, pdMS_TO_TICKS(1000));
|
||||
}
|
||||
}
|
||||
|
||||
void init_dmx(dmx_port_t port, int pin_tx, int pin_rx) {
|
||||
LOGI("Initializing DMX port %d on pin %d (TX) and %d (RX)", port, pin_tx,
|
||||
pin_rx);
|
||||
|
||||
dmx_config_t config = DMX_CONFIG_DEFAULT;
|
||||
dmx_personality_t personalities[] = {};
|
||||
dmx_driver_install(port, &config, personalities, 0);
|
||||
|
||||
dmx_set_pin(port, pin_tx, pin_rx, DMX_PIN_NO_CHANGE); // RTS pin is not used
|
||||
|
||||
BaseType_t task_created = xTaskCreate(dmx_sender_task, "dmx_sender", 2048,
|
||||
(void *)(intptr_t)port, 5, NULL);
|
||||
if (task_created != pdPASS) {
|
||||
LOGE("Failed to create DMX sender task for port %d", port);
|
||||
}
|
||||
}
|
||||
|
||||
void send_dmx(dmx_port_t port) {
|
||||
LOGD("Sending DMX data on port %d", port);
|
||||
|
||||
uint8_t dmx_data[DMX_PACKET_SIZE] = {DMX_SC, 0, 0, 0, 255, 100, 0, 100, 0};
|
||||
dmx_write(port, dmx_data, DMX_PACKET_SIZE);
|
||||
dmx_send(port);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue