Esempio n. 1
0
/*
 * Toggle weekend mode
 */
void toggle_weekend_mode() {
  if (!get_config_data()->smart) {
    show_notice(RESOURCE_ID_NOTICE_NEED_SMART_ALARM);
    return;
  }
  // Toggle weekend
  if (get_config_data()->weekend_until > 0) {
    // Turn off weekend
    get_config_data()->weekend_until = 0;
    set_smart_status();
  } else {
    // Turn on weekend
    get_config_data()->weekend_until = time(NULL) + WEEKEND_PERIOD;
    set_smart_status();
  }
}
Esempio n. 2
0
/*
 * Bed time with the alarm turned off
 */
static void reset_with_alarm_off() {
  if (get_config_data()->smart) {
    get_config_data()->smart = false;
    trigger_config_save();
    set_smart_status();
  }
  reset_sleep_period();
}
Esempio n. 3
0
/*
 * Initialise comms and accelerometer
 */
EXTFN void init_morpheuz() {

  open_comms();

  // Accelerometer
  accel_data_service_subscribe(25, accel_data_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);

  // Set the smart status
  set_smart_status();
}
Esempio n. 4
0
/*
 * Drop values back into the rest of the system
 */
static void return_values() {
  get_config_data()->smart = true;
  get_config_data()->fromhr = hour_from_fields(values[F_FROM_HOUR],values[F_FROM_AMPM]);
  get_config_data()->frommin = values[F_FROM_MINUTE];
  get_config_data()->tohr = hour_from_fields(values[F_TO_HOUR],values[F_TO_AMPM]);
  get_config_data()->tomin = values[F_TO_MINUTE];
  get_config_data()->from = to_mins(get_config_data()->fromhr, get_config_data()->frommin);
  get_config_data()->to = to_mins(get_config_data()->tohr, get_config_data()->tomin);
  resend_all_data(true); // Force resend - we've fiddled with the times
  trigger_config_save();
  set_smart_status();
}
Esempio n. 5
0
/*
 * Do menu action after shutting the menu and allowing time for the animations to complete
 */
static void do_menu_action(void *data) {
  get_config_data()->fromhr = preset_data.fromhr[selected_row];
  get_config_data()->frommin = preset_data.frommin[selected_row];
  get_config_data()->tohr = preset_data.tohr[selected_row];
  get_config_data()->tomin = preset_data.tomin[selected_row];
  get_config_data()->from = preset_data.from[selected_row];
  get_config_data()->to = preset_data.to[selected_row];    
  get_config_data()->smart = true;
  resend_all_data(true); // Force resend - we've fiddled with the times
  trigger_config_save();
  set_smart_status();
}
Esempio n. 6
0
/*
 * Initialise comms and accelerometer
 */
void init_morpheuz(Window *window) {

  init_alarm();

  open_comms();

  // Accelerometer
  accel_data_service_subscribe(25, accel_data_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);

  // Set click provider
  window_set_click_config_provider(window, (ClickConfigProvider) click_config_provider);

  // Set the smart status
  set_smart_status();
}
Esempio n. 7
0
/*
 * Do menu action after shutting the menu and allowing time for the animations to complete
 */
static void do_menu_action(void *data) {
  uint8_t no = menu_def[selected_row].no;
  if (menu_def[selected_row].set) {
    preset_data.fromhr[no] = get_config_data()->fromhr;
    preset_data.frommin[no] = get_config_data()->frommin;
    preset_data.tohr[no] = get_config_data()->tohr;
    preset_data.tomin[no] = get_config_data()->tomin;
    preset_data.from[no] = get_config_data()->from;
    preset_data.to[no] = get_config_data()->to;
    save_preset_data();
  } else {
    get_config_data()->fromhr = preset_data.fromhr[no];
    get_config_data()->frommin = preset_data.frommin[no];
    get_config_data()->tohr = preset_data.tohr[no];
    get_config_data()->tomin = preset_data.tomin[no];
    get_config_data()->from = preset_data.from[no];
    get_config_data()->to = preset_data.to[no];    
    get_config_data()->smart = true;
    resend_all_data(true); // Force resend - we've fiddled with the times
    trigger_config_save();
    set_smart_status();
  }
}
Esempio n. 8
0
/*
 * Reset the weekend time
 */
static void validate_weekend() {
  if (get_config_data()->weekend_until > 0 && get_config_data()->weekend_until < time(NULL)) {
    get_config_data()->weekend_until = 0;
    set_smart_status();
  }
}
Esempio n. 9
0
/*
 * Toggle the smart alarm
 */
static void toggle_alarm() {
  get_config_data()->smart = !get_config_data()->smart;
  resend_all_data(true); // Force resend - we've fiddled with the times
  trigger_config_save();
  set_smart_status();
}