  * https://github.com/marduino/arduino/wiki
  * 
  * https://github.com/arduino/ArduinoCore-samd/blob/master/cores/arduino/main.cpp
- */
+ * 
+ * Be aware that, in Uno and other ATMega based boards, long or unsigned long is 32bits
+ */
+
+/* define to enable reverted receive, the first bit start from highest,
+ * or else, start from bit0 until the highest bit
+ */
+//#define __IRREMOTE_RECEIVE_REVERT__
 
 /* a start high pulse in micro-seconds indicates start transferring a set of bits */
 #define IR_REMOTE_START_TIMING_MIN    3800
-#define IR_REMOTE_START_TIMING_MAX    4700
+#define IR_REMOTE_START_TIMING_MAX    4800
+
+/* continue pulse flag in micro-seconds */
+#define IR_REMOTE_CONTINUE_TIMING_MIN  18000
+#define IR_REMOTE_CONTINUE_TIMING_MAX  22000
 
 /* a 'one' timing means to set a bit to 1, indicated by 1200micro-seconds high pulse */
 #define IR_REMOTE_ONE_TIMING_MIN      900
 #define IR_REMOTE_ONE_TIMING_MAX      1800
 
 /* a 'zero' timing means to set a bit to 0, indicated by 600micro-seconds high pulse */
-#define IR_REMOTE_ZERO_TIMING_MIN     300
+#define IR_REMOTE_ZERO_TIMING_MIN     250
 #define IR_REMOTE_ZERO_TIMING_MAX     700
 
 /* measurement time out, in case timeout, reset all status */

  if (irDataIdx >= IR_REMOTE_DATA_WIDTH)
  {
    Serial.print(irDataIdx);
    Serial.print("data:");
    Serial.println(irData, HEX);
  }
  /* must reset to receive next pulse */
  pulseStartTiming = 0;
}

  dataStartTiming = 0;
  isDataValid = 0;
  irData = 0;
  irDataIdx = 0;
  irDataLongCode = 0; 
}

bool IRIsPulseValid(unsigned int dur)
