Rev 2204 | Rev 2233 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2204 | Rev 2223 | ||
|---|---|---|---|
| Line 1128... | Line 1128... | ||
| 1128 | * IR_OK if data parsed successfully, one of several errormessages if not |
1128 | * IR_OK if data parsed successfully, one of several errormessages if not |
| 1129 | */ |
1129 | */ |
| 1130 | int8_t parseNexa1(const uint16_t *buf, uint8_t len, uint8_t index, Ir_Protocol_Data_t *proto) { |
1130 | int8_t parseNexa1(const uint16_t *buf, uint8_t len, uint8_t index, Ir_Protocol_Data_t *proto) { |
| 1131 | /* parse buf[], max is len */ |
1131 | /* parse buf[], max is len */ |
| 1132 | 1132 | ||
| - | 1133 | uint8_t i; |
|
| 1133 | /* check if we have correct amount of data */ |
1134 | /* check if we have correct amount of data */ |
| 1134 | if (len |
1135 | if (len < 50) { |
| 1135 | return IR_NOT_CORRECT_DATA; |
1136 | return IR_NOT_CORRECT_DATA; |
| 1136 | } |
1137 | } |
| - | 1138 | #if IR_RX_CONTINUOUS_MODE==0 |
|
| - | 1139 | i = 0; |
|
| - | 1140 | #else |
|
| - | 1141 | i=index-50; |
|
| - | 1142 | if (i>index) |
|
| - | 1143 | i+=MAX_NR_TIMES; |
|
| - | 1144 | #endif |
|
| 1137 | if (buf[ |
1145 | if (buf[i] < IR_NEXA1_START - IR_NEXA1_START/IR_NEXA1_TOL_DIV || buf[i] > IR_NEXA1_START + IR_NEXA1_START/IR_NEXA1_TOL_DIV) { //check start bit |
| 1138 | return IR_NOT_CORRECT_DATA; |
1146 | return IR_NOT_CORRECT_DATA; |
| 1139 | } |
1147 | } |
| 1140 | 1148 | ||
| 1141 | uint32_t rawbitsTemp = 0; |
1149 | uint32_t rawbitsTemp = 0; |
| 1142 | uint8_t bitCounter = 0; |
1150 | uint8_t bitCounter = 0; |
| 1143 | 1151 | ||
| 1144 | for ( |
1152 | for (i = 1; i < 48; i+=4) |
| - | 1153 | { |
|
| - | 1154 | uint8_t i2; |
|
| - | 1155 | #if IR_RX_CONTINUOUS_MODE==0 |
|
| - | 1156 | i2 = i; |
|
| - | 1157 | #else |
|
| - | 1158 | i2=index-(50-i); |
|
| - | 1159 | if (i2>index) |
|
| - | 1160 | i2+=MAX_NR_TIMES; |
|
| - | 1161 | #endif |
|
| 1145 | /* Check if '0' bit */ |
1162 | /* Check if '0' bit */ |
| 1146 | if ( |
1163 | if ( |
| 1147 | (buf[ |
1164 | (buf[i2+0] > IR_NEXA1_SHORT - IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) && (buf[i2+0] < IR_NEXA1_SHORT + IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) && |
| 1148 | (buf[ |
1165 | (buf[i2+1] > IR_NEXA1_LONG - IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) && (buf[i2+1] < IR_NEXA1_LONG + IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) && |
| 1149 | (buf[ |
1166 | (buf[i2+2] > IR_NEXA1_SHORT - IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) && (buf[i2+2] < IR_NEXA1_SHORT + IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) && |
| 1150 | (buf[ |
1167 | (buf[i2+3] > IR_NEXA1_LONG - IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) && (buf[i2+3] < IR_NEXA1_LONG + IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) ) |
| 1151 | { |
1168 | { |
| 1152 | /* write a one */ |
1169 | /* write a one */ |
| 1153 | rawbitsTemp |= (1UL)<<(bitCounter++); |
1170 | rawbitsTemp |= (1UL)<<(bitCounter++); |
| 1154 | } |
1171 | } |
| 1155 | /* Check if 'X' bit */ |
1172 | /* Check if 'X' bit */ |
| 1156 | else if ( |
1173 | else if ( |
| 1157 | (buf[ |
1174 | (buf[i2+0] > IR_NEXA1_SHORT - IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) && (buf[i2+0] < IR_NEXA1_SHORT + IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) && |
| 1158 | (buf[ |
1175 | (buf[i2+1] > IR_NEXA1_LONG - IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) && (buf[i2+1] < IR_NEXA1_LONG + IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) && |
| 1159 | (buf[ |
1176 | (buf[i2+2] > IR_NEXA1_LONG - IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) && (buf[i2+2] < IR_NEXA1_LONG + IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) && |
| 1160 | (buf[ |
1177 | (buf[i2+3] > IR_NEXA1_SHORT - IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) && (buf[i2+3] < IR_NEXA1_SHORT + IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) ) |
| 1161 | { |
1178 | { |
| 1162 | /* do nothing, a zero is already in rawbits */ |
1179 | /* do nothing, a zero is already in rawbits */ |
| 1163 | bitCounter++; |
1180 | bitCounter++; |
| - | 1181 | } |
|
| - | 1182 | else |
|
| - | 1183 | { |
|
| - | 1184 | return IR_NOT_CORRECT_DATA; |
|
| 1164 | } |
1185 | } |
| 1165 | } |
1186 | } |
| 1166 | 1187 | ||
| 1167 | if (rawbitsTemp==0) |
1188 | if (rawbitsTemp==0) |
| 1168 | { |
1189 | { |