void app_ter_btn_alm(intptr_t exinf) { static bool_t wait_for_press = true; static SYSTIM time; if (global_brick_info.button_pressed[BRICK_BUTTON_BACK]) { if (wait_for_press) { time = _kernel_current_time; wait_for_press = false; } else { if (_kernel_current_time - time >= 1000) { // Pressed for 1 second isig_sem(APP_TER_SEM); // Terminate application wait_for_press = true; // Reset this cyclic handler istp_alm(APP_TER_BTN_ALM); return; // Return to stop this alarm handler } } } else { wait_for_press = true; } ista_alm(APP_TER_BTN_ALM, 10); }
static mrb_value mrb_ssp_alarm_ista(mrb_state *mrb, mrb_value self) { ER retval; mrb_int tout; mrb_value id = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@alarm_id")); mrb_int id_num = mrb_fixnum(id); mrb_get_args(mrb, "i", &tout); #if MRB_DEBUG1 printf("ssp_alarm_ista tout = %d\n",tout); #endif t_unlock_cpu(); retval = ista_alm(id_num,tout); t_lock_cpu(); if (retval == E_OK) { return(mrb_false_value()); } return(mrb_true_value()); }