Subversion Repositories HomeAutomation

Rev

Rev 1843 | Rev 1848 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1843 Rev 1846
Line 126... Line 126...
126
    msg.Length = 5;
126
    msg.Length = 5;
127
    msg.Header.Command = CAN_MODULE_CMD_IRTRANSCEIVE_IRPRONTOTIMING;
127
    msg.Header.Command = CAN_MODULE_CMD_IRTRANSCEIVE_IRPRONTOTIMING;
128
    uint32_t currentTime=Timer_GetTicks();
128
    uint32_t currentTime=Timer_GetTicks();
129
    if ((currentTime < sns_irTransceive_LastPronto+sns_irTransceive_MAXTIMING) && (sns_irTransceive_LastPronto != 0))
129
    if ((currentTime < sns_irTransceive_LastPronto+sns_irTransceive_MAXTIMING) && (sns_irTransceive_LastPronto != 0))
130
    {
130
    {
131
        msg.Data[0] = 0xff;
131
        msg.Data[0] = ((channel<<4)|0xf);
132
        msg.Data[1] = 0x10;
132
        msg.Data[1] = 0x10;
133
        msg.Data[2] = (((currentTime-sns_irTransceive_LastPronto)*1000)>>16)&0xff;
133
        msg.Data[2] = (((currentTime-sns_irTransceive_LastPronto)*1000)>>16)&0xff;
134
        msg.Data[3] = (((currentTime-sns_irTransceive_LastPronto)*1000)>>8)&0xff;
134
        msg.Data[3] = (((currentTime-sns_irTransceive_LastPronto)*1000)>>8)&0xff;
135
        msg.Data[4] = ((currentTime-sns_irTransceive_LastPronto)*1000)&0xff;
135
        msg.Data[4] = ((currentTime-sns_irTransceive_LastPronto)*1000)&0xff;
136
        while (StdCan_Put(&msg) != StdCan_Ret_OK) {}
136
        while (StdCan_Put(&msg) != StdCan_Ret_OK) {}
Line 1001... Line 1001...
1001
 
1001
 
1002
        // last byte determines nr of repeats. 0xFF means INF, 0 means no repeats
1002
        // last byte determines nr of repeats. 0xFF means INF, 0 means no repeats
1003
        irTxChannel[activeChannel].proto.repeats = rxMsg->Data[rxMsg->Length - 1];
1003
        irTxChannel[activeChannel].proto.repeats = rxMsg->Data[rxMsg->Length - 1];
1004
        irTxChannel[activeChannel].proto.timeout = 1; // TODO: timer is buggy and doesn't support timeout 0, so we're forced to use 1ms extra between repeats
1004
        irTxChannel[activeChannel].proto.timeout = 1; // TODO: timer is buggy and doesn't support timeout 0, so we're forced to use 1ms extra between repeats
1005
 
1005
 
1006
        // convert pronto data to µs
1006
        // convert pronto data to us
1007
        // TODO: calculate value
1007
        // TODO: calculate value
1008
        for (uint16_t i=0; i < irTxChannel[activeChannel].txlen; i++) {
1008
        for (uint16_t i=0; i < irTxChannel[activeChannel].txlen; i++) {
1009
            uint32_t newVal = ((uint32_t)irTxChannel[activeChannel].txbuf[i]) * 27;
1009
            uint32_t newVal = ((uint32_t)irTxChannel[activeChannel].txbuf[i]) * 27;
1010
            if (newVal > 0xFFFF) {
1010
            if (newVal > 0xFFFF) {
1011
                newVal = 0xFFFF;
1011
                newVal = 0xFFFF;