Fraise  2.1
FRAmework for Interfacing Software and Electronics
DMX master module

Example :

config.h :

#ifndef _CONFIG_H_
#define _CONFIG_H_
//DMX config:
#define DMX_UART_NUM AUXSERIAL_NUM
#define DMX_UART_PIN AUXSERIAL_TX // K11 on Versa
#define DMX_NBCHAN 256
#endif // _CONFIG_H_

main.c :

/*********************************************************************
* DMX master example for Versa2
* Output DMX frames to AUXSERIAL_TX (K11 for Versa)
*********************************************************************/
#define BOARD Versa2
#include <fruit.h>
#include <dmx.h>
//----------- Setup ----------------
void setup(void) {
DMXInit(); // init DMX master module
}
// ---------- Main loop ------------
void loop() {
fraiseService();// listen to Fraise events
DMXService(); // DXM management routine
}
// ---------- Receiving ------------
void fraiseReceive() // receive raw bytes
{
int i;
unsigned char c=fraiseGetChar(); // get first byte
switch(c) {
PARAM_INT(30,i); DMXSet(i, fraiseGetChar()); break; // if first byte is 30 then get DMX channel (int) and value (char).
}
}

Settings to put in config.h

You must define the serial port :

#define DMX_UART_NUM [1/2]
#define DMX_UART_PIN [pin]
#define DMX_NBCHAN
 DMX_NBCHAN default is 128, maybe overloaded up to 256 (TODO:512 but memory issue at compile time when tested).
 

Initialization

void DMXInit ()
 Init the module in setup()
 

Main loop functions

void DMXService ()
 Module service routine, to be called by the main loop().
 

Utilities

unsigned int DMXframeCount
 
void DMXSet (unsigned int channel, unsigned char value)
 Set value of a DMX channel. More...
 

Function Documentation

◆ DMXSet()

void DMXSet ( unsigned int  channel,
unsigned char  value 
)

Set value of a DMX channel.

Parameters
channelDMX channel (starting from 1)
valueNew value for this channel (0-255)
DMXService
void DMXService()
Module service routine, to be called by the main loop().
PARAM_INT
#define PARAM_INT(n, p)
in case n, assign next 16 bit integer in the message to p
Definition: fraisedevice.h:123
loop
void loop()
User defined forever loop.
fruitInit
void fruitInit(void)
Init fruit module at setup().
DMXInit
void DMXInit()
Init the module in setup()
dmx.h
DMXSet
void DMXSet(unsigned int channel, unsigned char value)
Set value of a DMX channel.
fruit.h
fraiseService
void fraiseService(void)
Fraise device service routine.
fraiseReceive
void fraiseReceive()
Raw message to this device.
setup
void setup()
User defined initialization.
fraiseGetChar
unsigned char fraiseGetChar()
Get next char from receive buffer.