void clear_line(uint8_t line){ shift_cursor_to(line*LINE_LENGTH+15); uint8_t i; for(i=0; i<LINE_LENGTH-1; ++i){ //LINE_LENGTH-1, bo w ostatniej iteracji nie chce przesuwac kursora dwukrotnie data_write(' '); shift_cursor(SH_LEFT); shift_cursor(SH_LEFT); } data_write(' '); shift_cursor(SH_LEFT); }
void shift_cursor_to(uint8_t pos){ cursor_home(); uint8_t i = 0; for(i=0; i<pos; ++i) shift_cursor(SH_RIGHT); }
void set_alarm() { uchar i; keyfive_flag=0; lcd_writecommand(0x01); ds1820_readalarm(); while(keyfive_flag==0) { lcd_writecommand(0x80+0x02); for(i=0;i<12;i++) { lcd_writedata(alarm_panel[i]); } lcd_writecommand(0x80+0x42); for(i=13;i<16;i++) { lcd_writedata(alarm_panel[i]); } lcd_writedata(decimal_character(a/10)); lcd_writedata(decimal_character(a%10)); lcd_writecommand(0x80+0x49); for(i=17;i<20;i++) { lcd_writedata(alarm_panel[i]); } lcd_writedata(decimal_character(b/10)); lcd_writedata(decimal_character(b%10)); if(keysix_flag==1) shift_cursor(); keyfive_scan(); keysix_scan(); } ds18b20_initial(); ds18b20_writebyte(0xcc); ds18b20_writebyte(0x48); }
int main(int argc, char **argv) { int check_busy = 0; if (argc < 3) usage(); //init spi oled init_spi_oled(argv[1]); argc-=2; argv+=2; while (argc >= 1) { const char *cmd = argv[0]; int args = 0; if (strcmp(cmd, "-B") == 0) { check_busy = 0; args = 1; check_busy_flag3(atoi(argv[1])); } if (strcmp(cmd, "-b") == 0) check_busy = 1; if (check_busy) check_busy_flag(); if (strcmp(cmd, "-f") == 0) { select_font(atoi(argv[1])); args = 1; } if (strcmp(cmd, "-e") == 0) { entry_mode_set(atoi(argv[1]), atoi(argv[2])); args = 2; } if (strcmp(cmd, "-m") == 0) { display_mode(atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); args = 3; } if (strcmp(cmd, "-c") == 0) clear_display(); if (strcmp(cmd, "-g") == 0) { set_ddram_address(atoi(argv[1]) * 0x40 + atoi(argv[2])); args = 2; } if (strcmp(cmd, "-a") == 0) { set_ddram_address(strtoul(argv[1], NULL, 0)); args = 1; } if (strcmp(cmd, "-A") == 0) { set_cgram_address(strtoul(argv[1], NULL, 0)); args = 1; } if (strcmp(cmd, "-w") == 0) { write_data(strtoul(argv[1], NULL, 0)); args = 1; } if (strcmp(cmd, "-h") == 0) return_home(); if (strcmp(cmd, "-C") == 0) { shift_cursor(*argv[1] == 'r'); args = 1; } if (strcmp(cmd, "-S") == 0) { shift_display(*argv[1] == 'r'); args = 1; } if (strcmp(cmd, "-t") == 0) { write_str(argv[1]); args = 1; } if (*cmd != '-') write_str(cmd); check_busy = 1; argc -= 1 + args; argv += 1 + args; } }
int main(void){ //ustawienie portow DDRD = 0xff; DDRC = 0x0f; PORTC = 0x30; DDRB = 0x00; PORTB = 0x02; display_on(); display_clear(); set_entry_mode(); function_set(); print("Ladies and"); _delay_ms(1500); clear_line(0); print("Gentlemen"); _delay_ms(1500); clear_line(0); print("We are floating"); _delay_ms(1500); clear_line(0); print("in space"); _delay_ms(1500); clear_line(0); short offset = 0; while(1){ if(!(PINC & 0x20)){ ++offset; data_write('a'+offset); shift_cursor(SH_LEFT); _delay_ms(20); // przeczekaj drgania stykow uint8_t step = 10, counter = 0; while(!(PINC & 0x20)){ //dopoki wcisniety if(counter>100){ step = 3; counter = 0; ++offset; data_write('a'+offset); shift_cursor(SH_LEFT); }else ++counter; _delay_ms(step); } _delay_ms(20); // przeczekaj drgania stykow } if(!(PINC & 0x10)){ --offset; data_write('a'+offset); shift_cursor(SH_LEFT); _delay_ms(20); // przeczekaj drgania stykow uint8_t step = 10, counter = 0; while(!(PINC & 0x10)){ //dopoki wcisniety if(counter>100){ step = 3; counter = 0; --offset; data_write('a'+offset); shift_cursor(SH_LEFT); }else ++counter; _delay_ms(step); } _delay_ms(20); // przeczekaj drgania stykow } if(!(PINB & 0x2)){ shift_cursor(SH_RIGHT); data_write('a'); shift_cursor(SH_LEFT); offset = 0; _delay_ms(20); // przeczekaj drgania stykow while(!(PINB & 0x2)){} //dopoki wcisniety _delay_ms(20); // przeczekaj drgania stykow } } }