I didn't understand the hint with the Prescaler.
So I tried to follow the hints with the delay between my splitted raw data variables.
Each of this variables has a length < 150. So it shouldn't violate the range of 300 bytes.
Each variable ends with an mark and I used the required following space as the value for the delay.
But the output is not like it should be.
Sending the first part only (raw_command_1) everything looks nice.
But when adding the two other parts I get a very strange output.
Code: Select all
#include <IRController.h>
#include <EEPROM.h>
#define LED_PIN 13
// Input for the local On/Off button
#define SWITCH_LOCAL 12
// value to make a dlay of 30 seconds between the reports
#define WAIT_SPAN 300
IRTransmitterParams ir_transmitter(byte(IR_TRANSMITTER_OUTPUT_PIN6),
IR_FLAGS_OUTPUT_HIGHDRIVE,
IR_MS_PRESCALLER_4MHZ,
IR_CARRIER_PRESCALLER_8MHZ);
byte currentLEDValue; // Last saved LED value
int waitCounter; // counter to make a delay of approx. 30 seconds
//1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
word raw_command_1[] = {0x95, 0xD34, 0x6D6, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E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0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E};
word repeater[] = {0x02, 0x1BB, 0x42CC};
void setup() {
// put your setup code here, to run once:
pinMode(LED_PIN, OUTPUT);
pinMode(SWITCH_LOCAL,INPUT_PULLUP);
pinMode(6, OUTPUT);
ir_transmitter.setupVendor(IR_VENDOR_UNKNOWN);
IR.begin(&ir_transmitter);
digitalWrite(6, LOW);
Serial.begin();
Serial.println("start");
EEPROM.get(0,¤tLEDValue,1);
setSWBIN(currentLEDValue);
}
void loop() {
// put your main code here, to run repeatedly:
waitCounter = 0;
// send every 30 second only
// we don't use "delay(..), because we have to scan the local button continously
Serial.println("Loop...");
do
{
// read the input
byte result = digitalRead(SWITCH_LOCAL);
if (result == 1)
{
// toggle the state On/Off
if (currentLEDValue == 0)
{
setSWBIN(255);
}
else
{
setSWBIN(0);
}
// zunoSendReport(2); // remark: if the button is pushed frequently, there will be more reports than one each 30 seconds!
// wait until the button is released to prevent cyclic toogle of the state if the button is pushed continously
while (result == 1)
{
result = digitalRead(SWITCH_LOCAL);
}
}
delay(100);
waitCounter++;
}
while (waitCounter < WAIT_SPAN);
}
// methode to update the state of the device
void setSWBIN(byte value) {
// value is a variable, holding a "new value"
// which came from the controller or other Z-Wave device
if (value > 0) { // if greater then zero
digitalWrite (LED_PIN, HIGH); //turn the LED on (HIGH is the voltage level)
} else { // if equals zero
digitalWrite(LED_PIN, LOW); //turn the LED off by making the voltage LOW
}
// we'll save our value for the situation, when the controller will ask us about it
if (currentLEDValue != value)
{
currentLEDValue = value;
EEPROM.put(0,¤tLEDValue,1);
//Anstelle der Ansteuerung einer LED wird später IR zur Steuerung des Klimagerätes verwendet
if (currentLEDValue == 0)
{
//Serial.println("Send Command ON");
// sendRAWCommand(raw_command_ON);
sendRAWCommand();
}
else
{
//Serial.println(" Send Command ON");
// sendRAWCommand(raw_command_ON);
sendRAWCommand();
}
}
}
void sendRAWCommand() {
// Serial.println("Send Command...");
IR.send_raw16(raw_command_1);
delayMicroseconds(420);
IR.send_raw16(raw_command_2);
delayMicroseconds(1236);
IR.send_raw16(raw_command_3);