Rev 1481 | Rev 1745 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1481 | Rev 1486 | ||
|---|---|---|---|
| Line 48... | Line 48... | ||
| 48 | } |
48 | } |
| 49 | uint16_t avgValue = 0; |
49 | uint16_t avgValue = 0; |
| 50 | for (uint8_t i=0; i<NR_AVG_VALUES; i++) { |
50 | for (uint8_t i=0; i<NR_AVG_VALUES; i++) { |
| 51 | avgValue += ABS(avgValues[i]); |
51 | avgValue += ABS(avgValues[i]); |
| 52 | } |
52 | } |
| - | 53 | ||
| 53 | // TODO: keep motiondetect==1 true for at least one CAN send period, so detections are never lost |
54 | // TODO: keep motiondetect==1 true for at least one CAN send period, so detections are never lost |
| 54 | motionDetect = (avgValue >= 80); |
55 | motionDetect = (avgValue >= 80); |
| 55 | 56 | ||
| - | 57 | } |
|
| - | 58 | else if (Timer_Expired(sns_PIR_SEND_TIMER)) { |
|
| 56 | /** |
59 | /** |
| 57 | * Read brightness sensor (via internal ADC). |
60 | * Read brightness sensor (via internal ADC). |
| 58 | */ |
61 | */ |
| 59 | brightness = ADC_Get(sns_PIR_BRIGHTNESS_AD); |
62 | brightness = ADC_Get(sns_PIR_BRIGHTNESS_AD); |
| 60 | } |
63 | |
| 61 | else if (Timer_Expired(sns_PIR_SEND_TIMER)) { |
- | |
| 62 | /** |
64 | /** |
| 63 | * Time to send CAN message. |
65 | * Time to send CAN message. |
| 64 | */ |
66 | */ |
| 65 | StdCan_Msg_t txMsg; |
67 | StdCan_Msg_t txMsg; |
| 66 | StdCan_Set_class(txMsg.Header, CAN_MODULE_CLASS_SNS); |
68 | StdCan_Set_class(txMsg.Header, CAN_MODULE_CLASS_SNS); |