uint16_t get_year_day(ds1307_time_t *tm) { uint16_t day = 0; int8_t i = BCD2BIN(tm->month); while (--i) { day += get_month_days(i, BCD2BIN(tm->year)); } day += BCD2BIN(tm->dom); return day; }
/** * tft_input_limit() - 确定一个元素输入的区间 * @name: 元素ID */ input_limit tft_input_limit(char *name) { input_limit in_lmt; if (strcmp(name, "st_y") == 0) { in_lmt.min = 2000; in_lmt.max = 2100; } else if (strcmp(name, "st_mo") == 0) { in_lmt.min = 1; in_lmt.max = 12; } else if (strcmp(name, "st_d") == 0) { in_lmt.min = 1; in_lmt.max = get_month_days(*get_value_of_kvp("st_y", 0), *get_value_of_kvp("st_mo", 0)); } else if (strcmp(name, "st_h") == 0) { in_lmt.min = 0; in_lmt.max = 23; } else if (strcmp(name, "st_mi") == 0) { in_lmt.min = 0; in_lmt.max = 59; } else if (strcmp(name, "st_s") == 0) { in_lmt.min = 0; in_lmt.max = 59; } else if (strcmp(name, "bg_y") == 0) { in_lmt.min = 2000; in_lmt.max = 2100; } else if (strcmp(name, "bg_mo") == 0) { in_lmt.min = 1; in_lmt.max = 12; } else if (strcmp(name, "bg_d") == 0) { in_lmt.min = 1; in_lmt.max = get_month_days(*get_value_of_kvp("bg_y", 0), *get_value_of_kvp("bg_mo", 0)); } else if (strcmp(name, "bg_h") == 0) { in_lmt.min = 0; in_lmt.max = 23; } else if (strcmp(name, "bg_mi") == 0) { in_lmt.min = 0; in_lmt.max = 59; } else if (strcmp(name, "ed_h") == 0) { in_lmt.min = 0; in_lmt.max = 23; } else if (strcmp(name, "ed_mi") == 0) { in_lmt.min = 0; in_lmt.max = 59; } else if (strcmp(name, "pd_d") == 0) { in_lmt.min = 1; in_lmt.max = 30; } else if (strcmp(name, "pd_h") == 0) { in_lmt.min = 0; in_lmt.max = 23; } else if (strcmp(name, "pd_mi") == 0) { in_lmt.min = 0; in_lmt.max = 59; } else if (strcmp(name, "x") == 0) { in_lmt.min = 0; in_lmt.max = 359; } else if (strcmp(name, "y") == 0) { in_lmt.min = 0; in_lmt.max = 359; } else if (strcmp(name, "cnt") == 0) { in_lmt.min = 0; in_lmt.max = 1000; } else { in_lmt.min = 0; in_lmt.max = 0; } return in_lmt; }