diff --git a/common/app/screen_guitest.c b/common/app/screen_guitest.c index 15733c2..282636e 100644 --- a/common/app/screen_guitest.c +++ b/common/app/screen_guitest.c @@ -10,7 +10,7 @@ static CHECKBOX_STRUCT c_cbox; static NUMUPDOWN_STRUCT n_updown; static void checkboxCB(void *checkbox, bool checked) { - // printf("Checkbox %s\n",(checked?"checked":"unchecked")); + printf("Checkbox %s\n",(checked?"checked":"unchecked")); } static void b_back_cb(void* button) { @@ -18,7 +18,7 @@ static void b_back_cb(void* button) { } static void n_updown_cb(void* numupdown, int16_t value) { - //printf("New NumUpDown Value %d\n",value); + printf("New NumUpDown Value %d\n",value); } static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction) { @@ -104,14 +104,14 @@ static void enter(void* screen) { n_updown.max=11; n_updown.min =-5; n_updown.callback=n_updown_cb; - //gui_numupdown_add(&n_updown); + gui_numupdown_add(&n_updown); } static void leave(void* screen) { gui_button_remove(&b_back); gui_checkbox_remove(&c_cbox); - //gui_numupdown_remove(&n_updown); + gui_numupdown_remove(&n_updown); touch_unregister_area(&a_area); } diff --git a/discovery/Makefile b/discovery/Makefile index ec75176..d4caf01 100644 --- a/discovery/Makefile +++ b/discovery/Makefile @@ -50,7 +50,7 @@ LIBSEARCHDIRS+=$(LIB_DIR)/StmUsbHost LIBSEARCHDIRS+=$(LIB_DIR)/Pixy -LDFLAGS=--specs=nosys.specs -Wl,--gc-sections +LDFLAGS=--specs=nano.specs -Wl,--gc-sections LDFLAGS+=$(addprefix -L,$(LIBSEARCHDIRS)) LDFLAGS+=$(addprefix -l,$(LIBS)) diff --git a/discovery/src/ll_tft.c b/discovery/src/ll_tft.c index dbe9894..ba290e5 100644 --- a/discovery/src/ll_tft.c +++ b/discovery/src/ll_tft.c @@ -411,90 +411,55 @@ void tft_reset_window() void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) { - if(y1==y2){ - if(x2 abs(y2-y1)) - { - //Without floating point! - int deltax = ((int)x2-(int)x1); - int deltay = ((int)y2-(int)y1)<<1; - int x = 0; - if (x1>x2) - { - do - { - tft_set_cursor(x1+x,y1+ (((long)deltay*(long)x/deltax+1)>>1)); - TFT_RAM = color; - } - while(x--!=deltax); - } - else - { - do - { - tft_set_cursor(x1+x,y1+ (((long)deltay*(long)x/deltax+1)>>1)); - TFT_RAM = color; - } - while(x++!=deltax); + if(abs(x2-x1) > abs(y2-y1)) //line has more distance in x than y => iterate over x distance + { + //Without floating point! + int deltax = ((int)x2-(int)x1); + int deltay = ((int)y2-(int)y1)<<1; + int x = 0; + if (x1>x2) + { + do + { + tft_set_cursor(x1+x,y1+ (((long)deltay*(long)x/deltax+1)>>1)); + TFT_RAM = color; } + while(x--!=deltax); } else { - int deltax = ((int)x2-(int)x1)<<1; - int deltay = ((int)y2-(int)y1); - int y = 0; - if (y1>y2) - { - do - { - tft_set_cursor(x1+ (((long)deltax*(long)y/deltay+1)>>1),y1+ y); - TFT_RAM = color; - } - while(y--!=deltay); + do + { + tft_set_cursor(x1+x,y1+ (((long)deltay*(long)x/deltax+1)>>1)); + TFT_RAM = color; } - else - { - do - { - tft_set_cursor(x1+ (((long)deltax*(long)y/deltay+1)>>1),y1+ y); - TFT_RAM = color; - } - while(y++!=deltay); - } - } - } + while(x++!=deltax); + } + } + else // => iterate over y distance + { + int deltax = ((int)x2-(int)x1)<<1; + int deltay = ((int)y2-(int)y1); + int y = 0; + if (y1>y2) + { + do + { + tft_set_cursor(x1+ (((long)deltax*(long)y/deltay+1)>>1),y1+ y); + TFT_RAM = color; + } + while(y--!=deltay); + } + else + { + do + { + tft_set_cursor(x1+ (((long)deltax*(long)y/deltay+1)>>1),y1+ y); + TFT_RAM = color; + } + while(y++!=deltay); + } + } } void ll_tft_draw_pixel(uint16_t x,uint16_t y,uint16_t color) @@ -521,20 +486,26 @@ void ll_tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, u } i = x1; - + //Drawing the two horizontal lines tft_set_cursor(x1, y1); while(i++ != x2) TFT_RAM = color; tft_set_cursor(x1,y2); while(i-- != x1) TFT_RAM = color; - i = y1; + /* + //uncommented because tft_write_reg seems to fail sometimes so it's safer to use draw line instead (below) + i = y1; tft_write_reg(0x11,0x6030); // Change adresspointer direction tft_set_cursor(x2, y1); while(i++ != y2) TFT_RAM = color; tft_set_cursor(x1, y1); while(i-- != y1) TFT_RAM = color; tft_write_reg(0x11,0x6018); // Set adresspointer direction normal again + */ + tft_draw_line(x1,y1,x1,y2,color); + tft_draw_line(x2,y1,x2,y2,color); + } void ll_tft_fill_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color)