/*###########################################################################
DALI Interface Demo
Monitors all messages on the DALI bus
----------------------------------------------------------------------------
Changelog:
2020-11-10 Created & tested on ATMega328 @ 8Mhz
----------------------------------------------------------------------------
Monitor.ino - copyright qqqlab.com / github.com/qqqlab
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
###########################################################################*/
#define DALI_OUTPUT_PIN 3
#define DALI_INPUT_PIN 4
#include "qqqDali_ATMega328.h"
Dali_ATMega328 dali;
uint8_t rx_out=0;
volatile uint8_t rx_in=0;
uint8_t rx_data[256];
//callback to handle received data on dali2 interface - executes in interrupt context, store data in buffer and display in loop()
void dali_receiver(Dali *d, uint8_t *data, uint8_t len) {
//push data in buffer
int16_t freebuf = (int16_t)256 + rx_in - rx_out - len - 2;
if(freebuf<=1) return; //buffer full
uint8_t j = rx_in;
rx_data[j++] = len; //push length
for(uint8_t i=0;i