-#define DATA_OUT_PIN 13
-
-typedef struct {
- byte offset;
- byte state;
-} rf_bit_t;
-
-// offset is number of alphas (0.08ms)
-
-const rf_bit_t zero_bit[] = { { 4, 1 },
- { 16, 0 },
- { 20, 1 },
- { 32, 0 },
- { 0, 0 } };
-
-const rf_bit_t one_bit[] = { { 12, 1 },
- { 16, 0 },
- { 28, 1 },
- { 32, 0 },
- { 0, 0 } };
-
-const rf_bit_t float_bit[] = { { 4, 1 },
- { 16, 0 },
- { 28, 1 },
- { 32, 0 },
- { 0, 0 } };
-
-const rf_bit_t sync_bit[] = { { 4, 1 },
- { 128, 0 },
- { 0, 0 } };
-
-typedef enum { ZERO = 0, ONE , FLOAT , SYNC } adbit_t;
-typedef byte ad_bit_t;
-#define WORD_LEN 13
-typedef ad_bit_t word_t[WORD_LEN];
-
-const rf_bit_t* bit_defs[] = { zero_bit, one_bit, float_bit, sync_bit };
-
-byte alpha_cnt = 0;
-byte bit_cnt = 0;
-byte chunk_cnt = 0;
-byte word_cnt = 0;
-const ad_bit_t* current_word;
-byte volatile frame_finished = 1;
-
-#define FRAME_LEN 8
-
-#define A1_ON 0
-#define A1_OFF 1
-#define A2_ON 2
-#define A2_OFF 3
-
-#define B1_ON 4
-#define B1_OFF 5
-#define B2_ON 6
-#define B2_OFF 7
-
-#define C1_ON 8
-#define C1_OFF 9
-#define C2_ON 10
-#define C2_OFF 11
-
-#define D1_ON 12
-#define D1_OFF 13
-#define D2_ON 14
-#define D2_OFF 15
-
-const word_t words[] = {
-{ ZERO, ZERO, FLOAT, FLOAT, ZERO, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC }, // A1_ON
-{ ZERO, ZERO, FLOAT, FLOAT, ZERO, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, SYNC }, // A1_OFF
-{ ZERO, ZERO, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC }, // A2_ON
-{ ZERO, ZERO, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, SYNC }, // A2_OFF
-
-{ FLOAT, ZERO, FLOAT, FLOAT, ZERO, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC }, // B1_ON
-{ FLOAT, ZERO, FLOAT, FLOAT, ZERO, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, SYNC }, // B1_OFF
-{ FLOAT, ZERO, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC }, // B2_ON
-{ FLOAT, ZERO, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, SYNC }, // B2_OFF
-
-{ ZERO, FLOAT, FLOAT, FLOAT, ZERO, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC }, // C1_ON
-{ ZERO, FLOAT, FLOAT, FLOAT, ZERO, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, SYNC }, // C1_OFF
-{ ZERO, FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC }, // C2_ON
-{ ZERO, FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, SYNC }, // C2_OFF
-
-{ FLOAT, FLOAT, FLOAT, FLOAT, ZERO, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC }, // D1_ON
-{ FLOAT, FLOAT, FLOAT, FLOAT, ZERO, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, SYNC }, // D1_OFF
-{ FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC }, // D2_ON
-{ FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, SYNC } // D2_OFF
-};
+#define RF_DATA_OUT_PIN 13
+#define IR_MOVEMENT_PIN 9
+#define IR_MOVEMENT_PIN2 12
+#define ONE_WIRE_PIN 8
+#define PANIC_BUTTON_PIN 7
+#define PANICLED_PWM_PIN 6
+#define BLUELED_PWM_PIN 11
+#define PHOTO_ANALOGPIN 0
+//movement is reported if during IR_SAMPLE_DURATION at least IR_TRESHOLD ir signals are detectd
+#define IR_SAMPLE_DURATION 6000
+#define IR_TRESHOLD 5900
+//duration PanicButton needs to be pressed before status change occurs (i.e. for two PanicButton Reports, the buttons needs to be pressed 1000 cycles, releases 1000 cycles and again pressed 1000 cycles)
+#define PB_TRESHOLD 1000
+#define PHOTO_SAMPLE_INTERVAL 4000
+#define IRREMOTE_SEND_PIN 3 //hardcoded in library
+//WARNING IRremote Lib uses TCCR2
+
+OneWire onewire(ONE_WIRE_PIN);
+DallasTemperature dallas_sensors(&onewire);
+DeviceAddress onShieldTemp = { 0x10, 0xE7, 0x77, 0xD3, 0x01, 0x08, 0x00, 0x3F };
+IRsend irsend;
+#define TEMPC_OFFSET_ARDUINO_GENEREATED_HEAT