Subversion Repositories HomeAutomation

Rev

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

Rev 609 Rev 611
Line 64... Line 64...
64
    uint8_t len=0;
64
    uint8_t len=0;
65
   
65
   
66
    uint16_t txbuffer[MAX_NR_TIMES];
66
    uint16_t txbuffer[MAX_NR_TIMES];
67
   
67
   
68
    while (1) {
68
    while (1) {
69
        time = Timebase_CurrentTime();
-
 
70
        if (state == STATE_IDLE) {
69
        if (state == STATE_IDLE) {
71
        } else if (state == STATE_START_TRANSMIT) {
70
        } else if (state == STATE_START_TRANSMIT) {
72
            if (expandProtocol(txbuffer, &len, &proto) == IR_OK) {
71
            if (expandProtocol(txbuffer, &len, &proto) == IR_OK) {
73
                if (IrTransceiver_Transmit(txbuffer, len, proto.modfreq) == IR_OK) {
72
                if (IrTransceiver_Transmit(txbuffer, len, proto.modfreq) == IR_OK) {
74
                    state = STATE_TRANSMITTING;
73
                    state = STATE_TRANSMITTING;
75
                } else {
74
                } else {
76
                    state = STATE_IDLE;
75
                    state = STATE_IDLE;
77
                }
76
                }
78
            } else {
77
            } else {
79
                state = STATE_IDLE;
78
                state = STATE_IDLE;
80
            }
79
            }
81
        } else if (state == STATE_TRANSMITTING) {
80
        } else if (state == STATE_TRANSMITTING) {
82
            //polla om den är klar, om klar gå till STATE_START_PAUSE
81
            //polla om den är klar, om klar gå till STATE_START_PAUSE
83
            if (IrTransceiver_Transmit_Poll() != IR_NOT_FINISHED) {
82
            if (IrTransceiver_Transmit_Poll() != IR_NOT_FINISHED) {
84
                state = STATE_START_PAUSE;
83
                state = STATE_START_PAUSE;
85
            }
84
            }
86
        } else if (state == STATE_START_PAUSE) {
85
        } else if (state == STATE_START_PAUSE) {
Line 89... Line 88...
89
            }
88
            }
90
            timePauseStarted = Timebase_CurrentTime();
89
            timePauseStarted = Timebase_CurrentTime();
91
            state = STATE_PAUSING;
90
            state = STATE_PAUSING;
92
        } else if (state == STATE_PAUSING) {
91
        } else if (state == STATE_PAUSING) {
93
            //när timeout har gått (timebase) så gå till STATE_START_TRANSMIT
92
            //när timeout har gått (timebase) så gå till STATE_START_TRANSMIT
-
 
93
            time = Timebase_CurrentTime();
94
            if (time - timePauseStarted >= proto.timeout) {
94
            if (time - timePauseStarted >= proto.timeout) {
95
                state = STATE_START_TRANSMIT;
95
                state = STATE_START_TRANSMIT;
96
            }
96
            }
97
            if (stop == 1 && repeatcnt >= proto.repeats) {
97
            if (stop == 1 && repeatcnt >= proto.repeats) {
98
                state = STATE_STOP;
98
                state = STATE_STOP;