Revision bbf2f5ad toolbox/main.c

View differences:

toolbox/main.c
101 101
        toolstate = TS_OFF;
102 102
        serno_zero(current_user);
103 103
      }
104
      break;
104 105

  
105 106
    case TS_REQ_DIS:
106 107
      if (!get_coil(MB_COIL_EN)) {
......
126 127
        toolstate = TS_REQ_DIS;
127 128
      } else if (serno_equal(current_user, latest_reading)) {
128 129
        toolstate = TS_ON;
129
      } else {
130
        if (led_blink_done()) {
131
          set_coil(MB_COIL_EN, 0);
132
          tool_disable();
133
          serno_zero(current_user);
134
          toolstate = TS_OFF;
135
        }
130
      } else if (led_blink_done()) {
131
        set_coil(MB_COIL_EN, 0);
132
        tool_disable();
133
        serno_zero(current_user);
134
        toolstate = TS_OFF;
136 135
      }
137 136
      break;
138 137

  
......
146 145
        toolstate = TS_REQ_DIS;
147 146
      } else if (!serno_equal(current_user, latest_reading)) {
148 147
        toolstate = TS_MISSING_ID;
149
        led_blink_start(666, 15, YELLOW);
148
        led_blink_start(500, 6, YELLOW); // TODO made 10 seconds
150 149
      }
151 150
      break;
152 151

  
......
262 261
}
263 262

  
264 263
int main() {
265
  char rfid_ticks = 0;
264
  char rfid_ticks = 0, rfid_restart = 0;
266 265

  
267 266
  time_init();
268 267
  led_init();
......
277 276

  
278 277
  rfid_start_read();
279 278
  while (1) {
280
    if (++rfid_ticks >= RFID_PERIOD/TICK_MS)
279
    if (rfid_poll()) {
280
      rfid_get_serno(latest_reading);
281
      rfid_restart = 1;
282
    }
283
    if (++rfid_ticks >= RFID_PERIOD/TICK_MS && rfid_restart)
281 284
    {
282 285
      rfid_ticks = 0;
283
      if (rfid_poll()) {
284
        rfid_get_serno(latest_reading);
285
        rfid_start_read();
286
      } else {
287
        /* TODO count # times rfid_poll returns each value and see how often we
288
         * have to wait */
289
      }
286
      rfid_restart = 0;
287
      rfid_start_read();
290 288
    }
291 289
    current = current_read();
292 290
    tool_tick();

Also available in: Unified diff