Subversion Repositories HomeAutomation

Rev

Rev 528 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 528 Rev 549
Line 62... Line 62...
62
    uint8_t ir_protocol, ir_address, ir_command;
62
    uint8_t ir_protocol, ir_address, ir_command;
63
    uint16_t ir_timeout;
63
    uint16_t ir_timeout;
64
    uint8_t state = STATE_IDLE;
64
    uint8_t state = STATE_IDLE;
65
 
65
 
66
    while (1) {
66
    while (1) {
67
        #if 0
-
 
68
        time = Timebase_CurrentTime();
-
 
69
        if (state == STATE_IDLE) {
-
 
70
            if (IrReceive_CheckIR(&ir_protocol, &ir_address, &ir_command, &ir_timeout) == IR_OK) {
-
 
71
                txMsg.Data.bytes[0] = 0x00;
-
 
72
                txMsg.Data.bytes[1] = ir_protocol;
-
 
73
                txMsg.Data.bytes[2] = ir_address;
-
 
74
                txMsg.Data.bytes[3] = ir_command;
-
 
75
                txMsg.DataLength = 4;
-
 
76
                txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_IR << CAN_SHIFT_SNS_TYPE) | (IR_ID_DATA<<CAN_SHIFT_SNS_ID) | (NODE_ID << CAN_SHIFT_SNS_SID));
-
 
77
                BIOS_CanSend(&txMsg);
-
 
78
                irTimeoutTime = Timebase_CurrentTime();
-
 
79
                state = STATE_IR_REPEAT;
-
 
80
            }
-
 
81
        } else if (state == STATE_IR_REPEAT) {
-
 
82
            //kolla efter ny ir, om ingen ny ir och timeout så sätt state till IDLE
-
 
83
            if (time - irTimeoutTime >= ir_timeout) {      
-
 
84
                state = STATE_IDLE;
-
 
85
                txMsg.Data.bytes[0] = 0x0f;
-
 
86
                BIOS_CanSend(&txMsg);
-
 
87
            }
-
 
88
            if (IrReceive_CheckIdle() == IR_OK) {
-
 
89
                irTimeoutTime = Timebase_CurrentTime();
-
 
90
            }
-
 
91
        }
-
 
92
        #endif
-
 
93
       
-
 
94
        #if 1
-
 
95
        time = Timebase_CurrentTime();
67
        time = Timebase_CurrentTime();
96
       
68
       
97
        if (state == STATE_IDLE) {
69
        if (state == STATE_IDLE) {
98
            /* test for irdata */
70
            /* test for irdata */
99
            uint8_t returnval = IrReceive_CheckIR(&ir_protocol, &ir_address, &ir_command, &ir_timeout);
71
            uint8_t returnval = IrReceive_CheckIR(&ir_protocol, &ir_address, &ir_command, &ir_timeout);
100
            if (returnval == IR_OK) {
72
            if (returnval == IR_OK) {
101
                /* a protocol was found for irdata, send on can */
73
                /* a protocol was found for irdata, send on can */
102
                txMsg.Data.bytes[0] = 0x00;
74
                txMsg.Data.bytes[0] = IR_BUTTON_DOWN;
103
                txMsg.Data.bytes[1] = ir_protocol;
75
                txMsg.Data.bytes[1] = ir_protocol;
104
                txMsg.Data.bytes[2] = ir_address;
76
                txMsg.Data.bytes[2] = ir_address;
105
                txMsg.Data.bytes[3] = ir_command;
77
                txMsg.Data.bytes[3] = ir_command;
106
                txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_IR << CAN_SHIFT_SNS_TYPE) | (IR_ID_DATA<<CAN_SHIFT_SNS_ID) | (NODE_ID << CAN_SHIFT_SNS_SID));
78
                txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_IR << CAN_SHIFT_SNS_TYPE) | (IR_ID_DATA<<CAN_SHIFT_SNS_ID) | (NODE_ID << CAN_SHIFT_SNS_SID));
107
                txMsg.DataLength = 4;
79
                txMsg.DataLength = 4;
Line 162... Line 134...
162
            /* check for new ir-data, if no new data during the timout-time then set state to IDLE */
134
            /* check for new ir-data, if no new data during the timout-time then set state to IDLE */
163
            if (time - irTimeoutTime >= ir_timeout) {      
135
            if (time - irTimeoutTime >= ir_timeout) {      
164
                state = STATE_IDLE;
136
                state = STATE_IDLE;
165
                /* if the protocol was known then send a release-message */
137
                /* if the protocol was known then send a release-message */
166
                if (ir_protocol != IR_PROTO_UNKNOWN) {
138
                if (ir_protocol != IR_PROTO_UNKNOWN) {
167
                    txMsg.Data.bytes[0] = 0x0f;
139
                    txMsg.Data.bytes[0] = IR_BUTTON_UP;
168
                    BIOS_CanSend(&txMsg);
140
                    BIOS_CanSend(&txMsg);
169
                }
141
                }
170
            }
142
            }
171
            if (IrReceive_CheckIdle() == IR_OK) {
143
            if (IrReceive_CheckIdle() == IR_OK) {
172
                irTimeoutTime = Timebase_CurrentTime();
144
                irTimeoutTime = Timebase_CurrentTime();
173
            }
145
            }
174
        }
146
        }
175
           
-
 
176
        #endif
-
 
177
 
147
 
178
       
148
       
179
        if (rxMsgFull) {
149
        if (rxMsgFull) {
180
            /* No message reception functionality implemented */
150
            /* No message reception functionality implemented */
181
           
151