int get_distance() { int dlugosc = 0; char ch_liczba[3]; //przechowywana jest liczba int w formie stringu wyswietl_LCD("dlugosc PBC:"); _delay_ms(200); int wait = TAK; do { if(bit_is_clear(PIN_SWITCH, SWITCH_UP)) { dlugosc += 1; gen_char(ch_liczba, &dlugosc); wyswietl_LCD(ch_liczba); } else if(bit_is_clear(PIN_SWITCH, SWITCH_DOWN)) { dlugosc -= 1; gen_char(ch_liczba, &dlugosc); wyswietl_LCD(ch_liczba); } else if(bit_is_clear(PIN_SWITCH, SWITCH_OK)) { wait = NIE; } if(dlugosc>16) dlugosc = 0; _delay_ms(200); } while(wait == TAK); return dlugosc; }
static int draw_height(int unicode, const char *utf8, int size) { const struct dfont_rect * rect = dfont_lookup(Dfont,unicode,FONT_SIZE); if (rect == NULL) { rect = gen_char(unicode,utf8,size); } if (rect) { return rect->h * size / FONT_SIZE; } return 0; }
static int draw_size(int unicode, const char *utf8, int size, int gen_new) { const struct dfont_rect * rect = dfont_lookup(Dfont,unicode,FONT_SIZE); if (rect == NULL && gen_new) { rect = gen_char(unicode,utf8,size,Outline); } if (rect) { return (rect->w -1) * size / FONT_SIZE; } return 0; }
void init_buf(char *buf, int64_t len, int rw_type, int64_t start_byte) { int i; if (rw_type == WRITE) { for (i = 0; i < len; i++) { #if 0 /* numbers 0 - 9 */ buf[i] = gen_char(i + start_byte, 10, 48); /* letters A -J */ buf[i] = gen_char(i + start_byte, 10, 65); #else /* assorted letters and some symbols A - Z - symbols a - z*/ buf[i] = gen_char(i+start_byte, 58, 65); #endif } } else /* READ */ { memset(buf, start_byte, len); } }
int ilosc_petli() { int wait = TAK; int ile_petli = 0; char ch_liczba[3]; //przechowywana jest liczba int w formie stringu wyswietl_LCD("ilosc petli:"); _delay_ms(200); wait = TAK; do { if(bit_is_clear(PIN_SWITCH, SWITCH_UP)) { ile_petli += 5; gen_char(ch_liczba, &ile_petli); wyswietl_LCD(ch_liczba); } else if(bit_is_clear(PIN_SWITCH, SWITCH_DOWN)) { ile_petli -= 5; gen_char(ch_liczba, &ile_petli); wyswietl_LCD(ch_liczba); } else if(bit_is_clear(PIN_SWITCH, SWITCH_OK)) { wait = NIE; } _delay_ms(200); } while(wait == TAK); return ile_petli; }
void label_rawdraw(const char * str, float fx, float y, struct pack_label * l) { shader_texture(Tex, 0); uint32_t color = l->color; int edge = l->edge; int size = l->size; int width = raw_width(str, l); int x = (int)fx; switch (l->align) { case LABEL_ALIGN_LEFT: break; case LABEL_ALIGN_RIGHT: x += l->width - width; break; case LABEL_ALIGN_CENTER: x += (l->width - width)/2; break; } char utf8[7]; int i; struct matrix mat = {{ 1024,0,0,1024,0,y * SCREEN_SCALE}}; for (i=0; str[i];) { int len = unicode_len(str[i]); int unicode = copystr(utf8, str+i, len); i+=len; const struct dfont_rect * rect = dfont_lookup(Dfont, unicode, FONT_SIZE, edge); if (rect == NULL) { rect = gen_char(unicode,utf8,FONT_SIZE,edge); if (rect == NULL) continue; } mat.m[4]=x*SCREEN_SCALE; draw_rect(rect,size,&mat,color,0); x += (rect->w-1) * size / FONT_SIZE + l->space_w; } }
void wykonaj (int ile_petli, int dlugosc) { int licznik=0; char ch_liczba[3]; pozycjonowanie(); _delay_ms(500); relay_on(); _delay_ms(50); init_LCD(); init_PWM(); _delay_ms(200); int delay = 370; if(dlugosc>MIN_DLUGOSC) delay = delay + (dlugosc-MIN_DLUGOSC)*190; for (licznik=0; licznik<ile_petli; licznik++) { int do_konca = ile_petli-licznik; gen_char(ch_liczba, &do_konca); //wyswietla ile cykli pozostało do konca naswietlania wyswietl_LCD(ch_liczba); kierunek(PRZOD); _delay_ms(delay); //odleglosc dokad dojadą lampy stop(); _delay_ms(2000); pozycjonowanie(); //jezdie do tylu az napotka krancowe _delay_ms(2000); } _delay_ms(1000); wyswietl_LCD("KONIEC PRACY"); _delay_ms(1000); relay_off(); beep(); }