I have set up my DALI master with 1 slave (prototyping phase) and managed to commission the slave (as far as I'm aware by testing against a direct arc level against the single short address). I am also able to get responses (query), somewhat haphazard at the moment due to the timing of the ISR probably being too strict and messing up sometimes on bits received, but at least working majority of the times.
So, assuming the above is the bare minimum to ensure that the bus, master and slave are working and able to send, receive and respond to commands. I have set up a function to set the scene level on the DTR and store this at the given scene level.
void setScene(uint8_t address, uint8_t scene, uint8_t level, _Bool isGroupAddress) {
if (isGroupAddress)
{
address |= _DALI2_GROUP_ADDRESS;
}
sendCommand(_DALI2_DTR, level, 0, 0);
_waitTilLineFree();
sendCommand(address, scene, _DALI2_STORE_THE_DTRAS_SCENE, _DALI2_FOLLOWING_COMMAND);
_waitTilLineFree();
sendCommand(address, scene, _DALI2_STORE_THE_DTRAS_SCENE, _DALI2_FOLLOWING_COMMAND);
_waitTilLineFree();
}
The_waitTilLineFree function is a helper function to effectively wait for the line to become free from any other commands that are currently being sent, i.e. when dali state is idle and then give an extra 5ms delay when state is idled.
The below is printed from another helper function which prints the tx buffer and rx buffer.
SET SCENE:
- address: [0]
- level: [64]
- scene: [1]
binary in form of 8 bit address then 8 bit command.
- |1010 0011 0100 0000| SET DTR LEVEL [64] |
- |0000 0001 0100 0001| STORE SCENE LEVEL to [1] |
- |0000 0001 0100 0001| REPEAT ^^^^ |
- |0000 0001 1011 0001| QUERY SCENE LEVEL [1] |
reply:
- |1111 1111|
I am asking to check that the above is the correct way to set the scene level. The repeat command is sent according to the wait time function so is in that minimum 100ms time frame for a repeat to happen.