hubsif / arduino-dali

A timer-based DALI (Digital Addressable Lighting Interface) library for Arduino
https://hubsif.github.io/arduino-dali/
GNU General Public License v3.0
26 stars 19 forks source link

dali setup short address example #2

Closed CurseStaff closed 11 months ago

CurseStaff commented 1 year ago

HI hubsif,

thank you for this awesome work,

can you share an example of driver setup code please ?

thank !

hubsif commented 1 year ago

Hi @CurseStaff,

What exactly do you mean by "an example of driver setup code"? You mean how to set the addresses of the drivers (in DALI terms: commission ballasts?)

CurseStaff commented 1 year ago

Hi @hubsif,

thank you for your quick reply,

this is indeed it, an example to configure commission ballasts

and thank you for the term by the way!

hubsif commented 1 year ago

Hi @CurseStaff,

Originally, I wanted to write more documentation and also provide a sample, but I didn't get to that yet.

Please find a minimal example with comments below. Please also have a look at the documentation here.

// DALI rx and tx pins
const byte DALI_TX_PIN = 1;
const byte DALI_RX_PIN = 0;

void setup() {
  Dali.begin(DALI_TX_PIN, DALI_RX_PIN); // start DALI
}

void loop() {
  // DALI tick (only required during commissioning)
  Dali.commission_tick();
}

//
// functions that can be called to start different kinds of commissioning
//
void commission_bus() {
  // (Re-)Commission all ballasts on the bus. overwrites existing addressing

  // Note that in DALI commissioning ballasts are selected randomly each time.
  // So, if the bus had been commissioned before, addresses can be different afterwards
  Dali.commission();
}

void commission_new() {
  // Commission ballasts on the bus that don't have an address yet. Assign addresses starting from 'startAddress' upwards.

  // Note that in this example if there were two new (addressless) ballasts and an existing ballast
  // with address 6 on the bus, you'd end up with two ballasts having the same address 6.
  // Ensuring that there is only one new ballast on the bus this can be used to e.g. replace
  // a defective ballast with address 5
  byte startAddress = 5;
  bool onlyNew = true
  Dali.commission(startAddress, true);
}

I just realized the issue with the double addressing. Perhaps I'll fix that in an upcoming version.

laihappy commented 1 year ago

Good Job! does your program support dali 2.0?

hubsif commented 11 months ago

even one year later 😄: no, it currently doesn't.