void setup() { pinMode(PIN_DIAGNOSTIC_LED, OUTPUT); Serial.begin(9600); debug(F("initializing LED Strip\n")); strip.begin(); strip.setBrightness(0xff); strip.show(); Color sunset(0x80, 0x20, 0x20), morning(0xa0, 0x5e, 0x50), noon(0xff, 0xff, 0xff), afternoon(0xa0, 0x5e, 0x50), night(0x10, 0x15, 0x20); // switch on at 6 (use an external timer for that) fade(Color::OFF, sunset, minutes_to_ms(45)); fade(sunset, morning, minutes_to_ms(30)); fade(morning, noon, minutes_to_ms(45 + 4 * 60)); fade(noon, noon, minutes_to_ms(4 * 60)); fade(noon, afternoon, minutes_to_ms(2 * 60)); fade(afternoon, sunset, minutes_to_ms(45)); fade(sunset, night, minutes_to_ms( 30)); fade(night, Color::OFF, minutes_to_ms(30)); }
static Boolean _print_day(Calendar *c, int num_page, void *xp, Tick first_date, Props *p, Boolean first) { char buf[100]; int n, i, j, timeslots, num_appts, pages; int max = 0; int daybegin = get_int_prop(p, CP_DAYBEGIN); int dayend = get_int_prop(p, CP_DAYEND); OrderingType ord_t = get_int_prop(p, CP_DATEORDERING); Boolean more, done = False, all_done = True; char *location; CSA_return_code stat; CSA_entry_handle *list; CSA_attribute *range_attrs; CSA_enum *ops; CSA_uint32 a_total; time_t start, stop; int lines_per_page; static Tick tick = 0; static int total_pages = 0; /* * Need to find the max number of timeslots which will be shown * in one column, for later calculation of box height. */ if ((!morning(daybegin)) || dayend <= 12) timeslots = dayend - daybegin; else timeslots = ((12-daybegin) > (dayend-12)) ? (12-daybegin) : (dayend-12); x_init_printer(xp, PORTRAIT); x_init_day(xp, timeslots); lines_per_page = x_get_day_lines_per_page(xp); if (first) tick = first_date; if (num_page > 1) tick = prevday(tick); else total_pages = (lines_per_page > 0) ? count_day_pages(c, lines_per_page, tick) : 1; format_date(tick, ord_t, buf, 1, 0, 0); x_print_header(xp, buf, num_page, total_pages); x_day_header(xp); for (i=daybegin; i < dayend; i++) { start = (time_t) lower_bound(i, tick); stop = (time_t) next_nhours(start+1, 1) - 1; setup_range(&range_attrs, &ops, &j, start, stop, CSA_TYPE_EVENT, NULL, B_FALSE, c->general->version); csa_list_entries(c->cal_handle, j, range_attrs, ops, &a_total, &list, NULL); free_range(&range_attrs, &ops, j); num_appts = count_multi_appts(list, a_total, c); if ((lines_per_page > 0) && (num_appts > (lines_per_page * num_page))) more = True; else more = False; x_day_timeslots (xp, i, more); if (lines_per_page > 0) done = x_print_multi_appts (xp, list, a_total, num_page, dayGlance); else done = True; if (!done) all_done = False; csa_free(list); } x_finish_printer(xp); tick = nextday(tick); return(all_done); }