コード例 #1
0
ファイル: calendar.c プロジェクト: falkobuttler/diaryface20
/*
 * Clear the event display area
 */
void clear_event() {
  set_event_display("", "", "", 0);
}
コード例 #2
0
ファイル: calendar.c プロジェクト: falkobuttler/diaryface20
/*
 * Show new details in the event display area
 */
void show_event(uint8_t num) {
  uint8_t i = num - 1;
  set_event_display(g_rot_events[i].title, g_rot_events[i].start_date, g_rot_events[i].has_location ? g_rot_events[i].location : "", num);
}
コード例 #3
0
ファイル: calendar.c プロジェクト: JamesFowler42/diaryface
/*
 * Timer handling. Includes a hold off for a period of time if there is resource contention
 */
void handle_calendar_timer(AppContextRef app_ctx, AppTimerHandle handle, uint32_t cookie) {
	
  // If we're rotating the visible event, get on with it. Slower overnight to save power
  if (cookie == ROTATE_EVENT) {
	  // Clobber the timer
	  app_timer_cancel_event(app_ctx, handle);
	  
	  // Show next event 
      show_next_event();
	  
	  // Kick off new timer
	  if (is_overnight()) 
    	app_timer_send_event(app_ctx, ROTATE_EVENT_INTERVAL_OVERNIGHT_MS, cookie);
	  else
    	app_timer_send_event(app_ctx, ROTATE_EVENT_INTERVAL_MS, cookie);
	
	  // Retire from active duty
	  return;
  }
	
  // Show the alert and let the world know
  if (cookie >= ALERT_EVENT && cookie <= (ALERT_EVENT + (MAX_EVENTS * 2))) {
	  app_timer_cancel_event(app_ctx, handle);
	  int num = cookie - ALERT_EVENT;
	  if (g_timer_rec[num].active == false)
		  return; // Already had the data for this event deleted - cannot show it.
	  g_timer_rec[num].active = false;
	  g_showing_alert = true;
      set_event_display(g_timer_rec[num].event_desc, g_timer_rec[num].relative_desc, g_timer_rec[num].location, 0);
	  set_invert_when_showing_event(true);
	  app_timer_send_event(app_ctx, 30000, RESTORE_DATE);	
	  app_timer_send_event(app_ctx, 15000, SECOND_ALERT);	
	  vibes_double_pulse();
      light_enable_interaction();
	  return;
  }

  // Let us know again
  if (cookie == SECOND_ALERT) {
      app_timer_cancel_event(app_ctx, handle);
      vibes_double_pulse();
      light_enable_interaction();
      return;
   }
      
  // Put the date back into the display area	
  if (cookie == RESTORE_DATE) {
	  app_timer_cancel_event(app_ctx, handle);
	  g_showing_alert = false;
	  show_next_event();
	  set_invert_when_showing_event(false);
	  return;
  }

  // Fire the calendar request
  if (cookie == REQUEST_CALENDAR_KEY) {
	  app_timer_cancel_event(app_ctx, handle);
	  calendar_request();
  }

}