void set_year(){ cli(); btn_drehenc_pushed = false; sei(); while(!btn_drehenc_pushed){ if(rotary != 0){ year += rotary; cli(); rotary = 0; sei(); if (year < 0) { year = 9999; } if(year > 9999){ year -= 10000; } for(int x = 0; x<128; x++){ for(int y = 30; y<40; y++) reset_pixel(x,y); } for(int x = 0; x<90; x++){ for(int y = YPOS_YEAR; y<YPOS_YEAR + 17; y++){ reset_pixel(x,y); } } print_year(); print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinOffenSymb, get_yearXPos() + get_yearWidth() / 2 - 4, YPOS_YEAR - 10); update_LCD(); } goodNight(); check_light(); } goodNight(); check_light(); }
int main( void ) { printf(" Leap year:\n"); print_year(leap); printf("\n"); test( day_init("February", 24) ); test( day_init("August", 9) ); test( day_init("December", 30) ); return 0; }
static void cal(int32_t month, int32_t year, UBool useLongNames, UErrorCode *status) { UCalendar *c; UChar *days [DAY_COUNT]; UChar *months [MONTH_COUNT]; int32_t fdow; if(U_FAILURE(*status)) return; /* Create a new calendar */ c = ucal_open(0, -1, uloc_getDefault(), UCAL_TRADITIONAL, status); /* Determine if we are printing a calendar for one month or for a year */ /* Print an entire year */ if(month == -1 && year != -1) { /* Set the year */ ucal_set(c, UCAL_YEAR, year); /* Determine the first day of the week */ fdow = ucal_getAttribute(c, UCAL_FIRST_DAY_OF_WEEK); /* Print the calendar for the year */ print_year(c, days, months, useLongNames, fdow, status); } /* Print only one month */ else { /* Set the month and the year, if specified */ if(month != -1) ucal_set(c, UCAL_MONTH, month); if(year != -1) ucal_set(c, UCAL_YEAR, year); /* Determine the first day of the week */ fdow = ucal_getAttribute(c, UCAL_FIRST_DAY_OF_WEEK); /* Print the calendar for the month */ print_month(c, days, useLongNames, fdow, status); } /* Clean up */ ucal_close(c); }
int main(int c, char **v) { int i, year_set = 0; for (i = 1; i < c; i++) { if (!strcmp(v[i], "-w")) { if (++i == c || (width = atoi(v[i])) < 20) goto bail; } else if (!year_set) { if (!sscanf(v[i], "%d", &year) || year <= 0) year = 1969; year_set = 1; } else goto bail; } init_months(); print_year(); return 0; bail: fprintf(stderr, "bad args\nUsage: %s year [-w width (>= 20)]\n", v[0]); exit(1); }
void set_date(){ clear_pixelMatrix(); print_date(POS_DATE_SET); print_year(); print_symbol(16,17, hakenSymb,108,46); print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() / 2 - 4, POS_DATE_SET - 10); update_LCD(); int old_selectedItem = 0; int item = 0; while (item != 3){ cli(); btn_drehenc_pushed = false; sei(); while(!btn_drehenc_pushed){ if(rotary != 0){ item += rotary; cli(); rotary = 0; sei(); item = item % 4; if(item<0){ item += 4; } switch (old_selectedItem){ case 0: for(int x = 0; x<128; x++){ for(int y = 0; y<10; y++) reset_pixel(x,y); } break; case 1: for(int x = 0; x<128; x++){ for(int y = 0; y<10; y++) reset_pixel(x,y); }break; case 2: for(int x = 0; x<128; x++){ for(int y = 30; y<40; y++) reset_pixel(x,y); }break; case 3: for(int x = 94; x<104; x++){ for(int y = 2+3*15+5; y<2+3*15+5+8; y++) reset_pixel(x,y); }break; } switch (item) { case 0: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() / 2 - 4, POS_DATE_SET - 10); break; //-4 = halbe Länge Herz case 1: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() + get_monthWidth() / 2 - 4, POS_DATE_SET - 10); break; case 2: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_yearXPos() + get_yearWidth() / 2 - 4, YPOS_YEAR - 10);break; case 3: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, 94, 2+3*15+5);break; } old_selectedItem = item; update_LCD(); } goodNight(); check_light(); } cli(); btn_drehenc_pushed = false; sei(); switch (item) { case 0: { print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinOffenSymb, get_dateXPos() + get_dayWidth() / 2 - 4, POS_DATE_SET - 10); update_LCD(); set_day(); print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() / 2 - 4, POS_DATE_SET - 10); break; } case 1:{ print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinOffenSymb, get_dateXPos() + get_dayWidth() + get_monthWidth() / 2 - 4, POS_DATE_SET - 10); update_LCD(); set_month(); print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() + get_monthWidth() / 2 - 4, POS_DATE_SET - 10); break; } case 2: { print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinOffenSymb, get_yearXPos() + get_yearWidth() / 2 - 4, YPOS_YEAR - 10); update_LCD(); set_year(); print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_yearXPos() + get_yearWidth() / 2 - 4, YPOS_YEAR - 10); break; } default: break; } update_LCD(); } }