Пример #1
0
  /** main loop. */
  public static void loop() {

    int cmd;

    Msg.loop(); // for exact msg timing first entry
    Triac.loop(); // should be also exact, but 1ms jitter is ok
    // TODO measure jitter with osci

    if (Msg.available) {
      cmd = Msg.readCmd();
      if (!handleMsg(cmd)) {
        handleRest(cmd);
        if (state == BBSys.MS_SERVICE) {
          doService(); // never return!
        }
      }
      lastMsgCnt = 0;
    } else {
      chkMsgTimeout();
    }

    if (blinkCnt == 100) {
      KflTimer.wd();
      blinkCnt = 0;
    }
    ++blinkCnt;

    int used = KflTimer.usedTime();
    if (maxTime < used) maxTime = used;
    JopSys.benchLoop();
  }
Пример #2
0
  //
  //	Service loop:
  //		local control of triacs.
  //		never return => switch power off to resume from service
  //
  private static void doService() {

    // we need this to avoid a simple goto in the CFG
    boolean exit = false;

    JopSys.wr(0x01, BBSys.IO_LED);

    for (; exit; ) { // @WCA loop=1
      Msg.loop(); // only for replay to set state
      Triac.loop();

      int val = JopSys.rd(BBSys.IO_TAST);
      if (val == BBSys.BIT_TAB) {
        Triac.runter();
      } else if (val == BBSys.BIT_TAUF) {
        Triac.rauf();
      } else {
        Triac.stop();
      }
      KflTimer.wd();
      KflTimer.waitForNextInterval();
    }
  }