Commit ec98a565fed316099f6e68cf9b7f484bf4f0e356

Authored by qqqlab
Committed by GitHub
1 parent f254c10b

Delete Monitor.ino

Showing 1 changed file with 0 additions and 77 deletions
Examples/Monitor/Monitor.ino deleted
1   -/*###########################################################################
2   -DALI Interface Demo
3   -
4   -Monitors all messages on the DALI bus
5   -
6   -----------------------------------------------------------------------------
7   -Changelog:
8   -2020-11-10 Created & tested on ATMega328 @ 8Mhz
9   -----------------------------------------------------------------------------
10   - Monitor.ino - copyright qqqlab.com / github.com/qqqlab
11   -
12   - This program is free software: you can redistribute it and/or modify
13   - it under the terms of the GNU General Public License as published by
14   - the Free Software Foundation, either version 3 of the License, or
15   - (at your option) any later version.
16   -
17   - This program is distributed in the hope that it will be useful,
18   - but WITHOUT ANY WARRANTY; without even the implied warranty of
19   - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20   - GNU General Public License for more details.
21   -
22   - You should have received a copy of the GNU General Public License
23   - along with this program. If not, see <http://www.gnu.org/licenses/>.
24   -###########################################################################*/
25   -
26   -#define DALI_OUTPUT_PIN 3
27   -#define DALI_INPUT_PIN 4
28   -
29   -#include "qqqDali_ATMega328.h"
30   -
31   -Dali_ATMega328 dali;
32   -
33   -uint8_t rx_out=0;
34   -volatile uint8_t rx_in=0;
35   -uint8_t rx_data[256];
36   -
37   -//callback to handle received data on dali2 interface - executes in interrupt context, store data in buffer and display in loop()
38   -void dali_receiver(Dali *d, uint8_t *data, uint8_t len) {
39   - //push data in buffer
40   - int16_t freebuf = (int16_t)256 + rx_in - rx_out - len - 2;
41   - if(freebuf<=1) return; //buffer full
42   - uint8_t j = rx_in;
43   - rx_data[j++] = len; //push length
44   - for(uint8_t i=0;i<len;i++) rx_data[j++]=data[i]; //push data
45   - rx_in = j; //increment in pointer upon completion
46   -}
47   -
48   -
49   -void setup() {
50   - Serial.begin(115200);
51   - Serial.println("DALI Monitor Demo");
52   -
53   - //start the DALI interfaces
54   - //arguments: tx_pin, rx_pin (negative values disable transmitter / receiver)
55   - //Note: the receiver pins should be on different PCINT groups, e.g one
56   - //receiver on pin0-7 (PCINT2) one on pin8-13 (PCINT0) and one on pin14-19 (PCINT1)
57   - dali.begin(DALI_OUTPUT_PIN, DALI_INPUT_PIN);
58   -
59   - //attach a received data handler
60   - dali.EventHandlerReceivedData = dali_receiver;
61   -}
62   -
63   -#define MIN_LEVEL 100 //most LED Drivers do not get much lower than this
64   -int16_t level = 254; //254 is max level, 1 is min level (if driver supports it), 0 is off
65   -int8_t level_step = 4;
66   -
67   -void loop() {
68   - if(rx_out!=rx_in) {
69   - //Serial.print("RX:");
70   - uint8_t len = rx_data[rx_out++];
71   - for(uint8_t i=0;i<len;i++) {
72   - Serial.print(rx_data[rx_out++],HEX);
73   - Serial.print(' ');
74   - }
75   - Serial.println();
76   - }
77   -}