Ejemplo n.º 1
0
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();
}
Ejemplo n.º 2
0
mixed can_throw_obj() {
    if( this_player()->GetParalyzed() ) {
        return "You cannot do anything.";
    }
    if(intp(check_light(0))) return this_player()->CanManipulate();
    else return check_light(0);
}
Ejemplo n.º 3
0
mixed can_steal_obj_from_liv() {
    if( (int)this_player()->GetSkillLevel("stealing") < 1 )
        return "You are not skillful enough at stealing.";
    if( (int)environment(this_player())->GetProperty("no steal") )
        return "Mystical forces prevent your thievery.";
    if( (int)this_player()->GetStaminaPoints() < 20 )
        return "You are too tired for such skullduggery.";
    if(intp(check_light(0))) return this_player()->CanManipulate();
    else return check_light(0);
}
Ejemplo n.º 4
0
void set_month(){
	cli();
	btn_drehenc_pushed = false;
	sei();
	while(!btn_drehenc_pushed){
		if(rotary != 0){
			month += rotary;
			cli();
			rotary = 0;
			sei();
			month = month % 12;
			if (month < 0) {
				month += 12;
			}
			if(day > pgm_read_byte(&daysPerMonth[month])){
				day = pgm_read_byte(&daysPerMonth[month]);
			}
			for(int x = 0; x<128; x++){
				for(int y = 0; y<10; y++)
				reset_pixel(x,y);
			}
			
			print_date(POS_DATE_SET);
			print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinOffenSymb, get_dateXPos() + get_dayWidth() + get_monthWidth() / 2 - 4, POS_DATE_SET - 10);
			update_LCD();
		}
		goodNight();
		check_light();
	}
}
Ejemplo n.º 5
0
void set_timeParameter(int *timeParameter, int maxTime, bool timeType){ //timeParameter = {minute, hour, alarmMinute, alarmHour}
	while(!btn_drehenc_pushed) {
		if(rotary!=0) {
			cli();
			*timeParameter += rotary;
			rotary = 0;
			*timeParameter = *timeParameter % maxTime;
			if(*timeParameter<0){
				*timeParameter += maxTime;
			}
			seconds = 0;
			sei();
			for(int x = timeXPos; x < timeXPos + hourWidth + minuteWidth + 2*SPACE_TO_DOTS + TIMEDOT_WIDTH; x++){
				for(int y = 0; y < timeYPos + BIG_NUMBER_HEIGHT; y++)
					reset_pixel(x,y);
			}
			print_time(timeType);
			if(maxTime == 60)
				print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinOffenSymb,timeXPos+hourWidth + 2*SPACE_TO_DOTS + TIMEDOT_WIDTH + minuteWidth/2-4, 2);
			else
				print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinOffenSymb,timeXPos+hourWidth/2-4, 2);
			update_LCD();
		}
		goodNight();
		check_light();
	}
	cli();
	btn_drehenc_pushed = false;
	sei();
}
Ejemplo n.º 6
0
int get_menuSelection(int numItems, int selectedItem){
	print_menuSelection(selectedItem, numItems);
	update_LCD();
	cli();
	rotary = 0;
	btn_drehenc_pushed = false;
	sei();
	while(!btn_drehenc_pushed){
		if(rotary != 0){
			cli();
			selectedItem += rotary;
			rotary = 0;
			sei();
			selectedItem = selectedItem % (numItems+1);
			if(selectedItem < 0){
				selectedItem += numItems+1;
			}
			print_menuSelection(selectedItem, numItems);
			update_LCD();
		}
		goodNight();
		check_light();
	}
	cli();
	btn_drehenc_pushed = false;
	sei();
	return selectedItem;
}
Ejemplo n.º 7
0
int main(void)
{
	_delay_ms(1000); //Oszillator powerup


	set_ports();//Ein- und Ausgänge einstellen
	configureTimerAndInterrupts();//Benötigte Interrupts aktivieren, Timer einstellen
	
	lcdInit();
	clear_LCD();
    print_stdDisplay();
	
	sei(); //globale Interrupts aktivieren

	while(1) {
		if(btn_light_pushed == true){
			check_light();
		}
		if(rotary!=0){//Drehen soll hier keine Auswirkung haben
			rotary = 0;
		}
		if(check_TimeUpdate()  ){
			if(!menuOpen) { 
				update_time();
			}
			if((hour == alarm_hour) && (minute == alarm_minute) && (alarm)){
				wakeUp_User();
			}
		}
		if(btn_drehenc_pushed){
			
			//Timer starten zum Zählen
			start_btnPress();
			//warten, solange Taste gedrückt ist
			while((PINB & (1<<PINB2)) && (btn_press_duration<BTN_PRESS_LONG)){_delay_ms(50);}//KANN DELAY WEGGELASSEN WERDEN?
			//Zeitmessung beenden
			stop_btnPress();
			//falls länger als BTN_PRESS_LONG gedrückt wurde, Menü öffnen
			if(btn_press_duration > BTN_PRESS_LONG){ 
				for(int i=0; i<32; i++){
					herzSymb[i] = pgm_read_byte(&herz[0][i]);
				}
				for(int i=0; i<HERZ_KLEIN_WIDTH; i++){
					herzKleinSymb[i] = pgm_read_byte(&herzKlein[0][i]);
					herzKleinOffenSymb[i] = pgm_read_byte(&herzKleinOffen[0][i]);
				}
				for(int i=0; i<HAKEN_WIDTH; i++){//PRÜFEN hakenSymb i<60
					hakenSymb[i] = pgm_read_byte(&haken[0][i]);
				}
				menuOpen = true;
				show_mainMenu(STDDISPLAY);
			} 
			btn_drehenc_pushed = false;
			menuOpen = false;
		}
		goodNight();
	}
	
}
Ejemplo n.º 8
0
mixed can_look_at_str(string str, string verb) {
    if( !environment(this_player()) ) return "You are nowhere.";
    if( SEASONS_D->GetLong(str) == 0 ) {
        //return "There is no " + remove_article(str) + " here.";
    }
    else {
        return check_light(0);
    }
}
Ejemplo n.º 9
0
void boombox(){
	boot_amp();
	clear_LCD();
	clear_pixelMatrix();
	uint8_t weckerSymb[72];
	for(int i=0; i<72; i++){
		weckerSymb[i] = pgm_read_byte(&note[0][i]);
	}
	print_symbol(16,9,weckerSymb,55,24);
	print_symbol(16,17, hakenSymb,108,46);
	print_symbol(16,16, herzSymb, 92, 2+3*15);
	update_LCD();
	while(!btn_drehenc_pushed){
		goodNight();
		check_light();
	}
	shutdown_amp();
}
Ejemplo n.º 10
0
mixed can_look_at_obj(string verb, string id) {
    return check_light(0);
}
Ejemplo n.º 11
0
mixed can_look() {
    if( !environment(this_player()) ) return "You are nowhere.";
    else return check_light(0);
}
Ejemplo n.º 12
0
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();
	}
}
Ejemplo n.º 13
0
void set_time(bool timeType){
	int *hou = &hour;
	int *min = &minute;
	update_timeXPos(hour, minute);
	if (timeType == ALARM_TYPE){
		hou = &alarm_hour;
		min = &alarm_minute;
		update_timeXPos(alarm_hour, alarm_minute);
	}
	int item = 0;
	int old_selectedItem = 1;
	cli();
	btn_drehenc_pushed = false;
	sei();
	clear_pixelMatrix();
	print_time(timeType);
	
	print_symbol(16,17, hakenSymb,108,46);
	print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,timeXPos+get_timeWidth(alarm_hour)/2-4, 2);
	update_LCD();
	while(item != 2){
		while(!btn_drehenc_pushed){
			if(rotary != 0){
				item += rotary;
				cli();
				rotary = 0;
				sei();
				item = item % 3;
				if(item<0){
					item += 3;
				}
				
				switch (old_selectedItem){
					case 0: for(int x = 0; x<128; x++){
								for(int y = 2; y<10; y++)
									reset_pixel(x,y);
							} break;
					case 1: for(int x = 0; x<128; x++){
								for(int y = 2; y<10; y++)
								reset_pixel(x,y);
							}break;
					case 2: for(int x = 92; x<102; x++){
								for(int y = 2+3*15+5; y<2+3*15+8+5; y++)
									reset_pixel(x,y);
							}break;
				}
				switch (item) {
					case 0: print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,timeXPos+hourWidth/2-4, 2); break;
					case 1: print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,timeXPos+hourWidth+2*SPACE_TO_DOTS+ TIMEDOT_WIDTH + minuteWidth/2-4, 2); break;
					case 2: print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb, 92, 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,timeXPos+hourWidth/2-4, 2); 
				update_LCD(); 
				set_timeParameter(hou, 24, timeType); 
				print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,timeXPos+hourWidth/2-4, 2);
				break;
			}
			
			case 1: {
				print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinOffenSymb,timeXPos+hourWidth+2*SPACE_TO_DOTS+ TIMEDOT_WIDTH + minuteWidth/2-4, 2); 
				update_LCD(); 
				set_timeParameter(min, 60, timeType); 
				print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,timeXPos+hourWidth+2*SPACE_TO_DOTS+ TIMEDOT_WIDTH + minuteWidth/2-4, 2);
				break;
			}
			case 2: {	seconds = 0;
						cli();
						TCNT2 = 0;
						timeAdvance = 0;
						timeUpdate = 0;
						sei();
						break;
			}
		}
		update_LCD();
	}
}
Ejemplo n.º 14
0
void set_audio(){
	btn_drehenc_pushed = false;
	int item = 0;
	clear_pixelMatrix();
	clear_LCD();
	print_symbol(16,17, hakenSymb,108,46);
	int warte_ASCII [strlen("Bitte warten")];
	convertString("Bitte warten", warte_ASCII);
	print_ASCIIString(20,16, warte_ASCII, sizeof(warte_ASCII)/sizeof(warte_ASCII[0]));
	update_LCD();
	mp3Player_onoff();//On
	play_pause();
	_delay_ms(1000);
	boot_amp();
	//Speaker-Symbol aus EEPROM holen
	uint8_t speakerSymb[SPEAKER_WIDTH];
	for(int i=0; i<SPEAKER_WIDTH; i++){
		speakerSymb[i] = pgm_read_byte(&speaker[0][i]);
	}
	clear_pixelMatrix();
	clear_LCD();
	print_symbol(16,17, hakenSymb,108,46);
	print_symbol(24,31,speakerSymb,(128-31)/2,(64-24)/2);
	rotary = 0;
	while(item!=1){
		while(!btn_drehenc_pushed){
			
			item+=rotary;
			item=item%2;
			if(item<0)
			item+=2;
			rotary = 0;
			if(item == 0){
				//ggf. offenes Herz entfernen
				for(int x = 64-HERZ_KLEIN_WIDTH/2; x<64-HERZ_KLEIN_WIDTH/2+2; x++){
					for(int y = 2; y<11; y++)		
						reset_pixel(x,y);
				}
				print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,64-4, 2);//kleines Herz über Speaker malen
				for(int x = 92; x<92+16; x++){//Großes Herz am Haken entfernen
					for(int y = 2+3*15; y<64; y++)
					reset_pixel(x,y);
				}
				} else {
				print_symbol(16,16, herzSymb, 92, 2+3*15);//Großes Herz am Haken malen
				for(int x = 64-8; x<64+8; x++){//kleines Herz über Speaker entfernen
					for(int y = 2; y<11; y++)
					reset_pixel(x,y);
				}
			}
			update_LCD();
			goodNight();
			check_light();
		}
		btn_drehenc_pushed = false;
		for(int x = 64-8; x<64+8; x++){
			for(int y = 2; y<11; y++)
			reset_pixel(x,y);
		}
		if(item==0){
			print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinOffenSymb,64-HERZ_KLEIN_WIDTH/2, 2);
			update_LCD();
			btn_drehenc_pushed = false;
			while(!btn_drehenc_pushed){
				goodNight();
				if(rotary>0){
					volume(UP);
					rotary = 0;
				} else {
					volume(DOWN);
					rotary = 0;
				}
				check_light();
			}
			btn_drehenc_pushed = false;
		}
	}
	clear_pixelMatrix();
	clear_LCD();
	print_ASCIIString(20,16, warte_ASCII, sizeof(warte_ASCII)/sizeof(warte_ASCII[0]));
	update_LCD();
	shutdown_amp();
	mp3Player_onoff();
}
Ejemplo n.º 15
0
void set_snoozeDuration(){
	btn_drehenc_pushed = false;
	int item = 0;
	clear_pixelMatrix();
	clear_LCD();
	print_symbol(16,17, hakenSymb,108,46);
	while(item!=1){
		int width = pgm_read_byte(&bigNumberWidth[snoozeDuration%10]);
		if(snoozeDuration>9){
			width += pgm_read_byte(&bigNumberWidth[snoozeDuration/10]);
		}
		printSnoozetime();
		while(!btn_drehenc_pushed){
			item+=rotary;
			item=item%2;
			if(item<0)
				item+=2;
			rotary = 0;
			if(item == 0){
				print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,64-4, 2); 
				for(int x = 92; x<92+16; x++){
					for(int y = 2+3*15; y<64; y++)
					reset_pixel(x,y);
				}
			} else {
				print_symbol(16,16, herzSymb, 92, 2+3*15);
				for(int x = 64-8; x<64+8; x++){
					for(int y = 2; y<11; y++)
					reset_pixel(x,y);
				}
			}
			update_LCD();
			goodNight();
			check_light();	
		}
		btn_drehenc_pushed = false;
		for(int x = 64-8; x<64+8; x++){
			for(int y = 2; y<11; y++)
			reset_pixel(x,y);
		}
		if(item==0){
			print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinOffenSymb,64-HERZ_KLEIN_WIDTH/2, 2);
			update_LCD();
			while(!btn_drehenc_pushed){
				if(rotary!=0){
					for(int x = 64-width/2; x<64+width/2;x++){
						for(int y = timeYPos; y<timeYPos+BIG_NUMBER_HEIGHT; y++)
						reset_pixel(x,y);
					}
					snoozeDuration+=rotary;
					snoozeDuration=snoozeDuration%99;
					if(snoozeDuration<0)
					snoozeDuration+=99;
					rotary = 0;
				}
				printSnoozetime();
				update_LCD();
				goodNight();
				check_light();
			}
			btn_drehenc_pushed = false;
		}
	}
}