Example #1
0
/*
 * Handle an up or down button press and validate results
 */
static void up_down_handler(int8_t delta) {
  switch (current_field) {
    case F_FROM_HOUR:
    case F_TO_HOUR:
      alter_time(current_field, delta, 23, 0);
      break;
    case F_FROM_MINUTE:
    case F_TO_MINUTE:
      alter_time(current_field, 5 * delta, 55, 0);
      break;
    case F_SMART_ALARM:
      alter_time(current_field, 1, 1, 0);
      break;
    case F_DONE:
      if (values[F_DONE] == 1)
        hide_set_alarm();
      else
        vibes_short_pulse();
      break;
  }
  uint32_t from = to_mins(values[F_FROM_HOUR], values[F_FROM_MINUTE]);
  uint32_t to = to_mins(values[F_TO_HOUR], values[F_TO_MINUTE]);
  values[F_DONE] = (from <= to);
  write_values_to_fields();
}
Example #2
0
/*
 * Select button moves to next field - highlight and move
 */
static void select_single_click_handler(ClickRecognizerRef recognizer, void *context) {
  highlight_field(current_field, false);
  current_field++;
  if (is24hr && (current_field == F_FROM_AMPM || current_field == F_TO_AMPM)) {
    current_field++;
  }
  if (current_field > F_TO_AMPM) {
    hide_set_alarm();
    return;
  }
  highlight_field(current_field, true);
}