1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 00:05:17 +03:00

Flash savings 24B

I am learning code optimisations, can someone check this comit please?
This have not to change anything, only save flash.
This commit is contained in:
mhotar 2014-01-26 12:32:09 +01:00
parent 1d0ebe5642
commit f676589989
4 changed files with 14 additions and 16 deletions

View file

@ -2271,7 +2271,8 @@ void DrawCurve(uint8_t offset=0)
uint8_t i = 0; uint8_t i = 0;
do { do {
point_t point = getPoint(i++); point_t point = getPoint(i);
i++;
if (point.x == 0) break; if (point.x == 0) break;
lcd_filled_rect(point.x-offset, point.y-1, 3, 3, SOLID, FORCE); // do markup square lcd_filled_rect(point.x-offset, point.y-1, 3, 3, SOLID, FORCE); // do markup square
} while(1); } while(1);

View file

@ -64,7 +64,8 @@ void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags
for (uint8_t yb = 0; yb < hb; yb++) { for (uint8_t yb = 0; yb < hb; yb++) {
uint8_t *p = &displayBuf[ (y / 8 + yb) * LCD_W + x ]; uint8_t *p = &displayBuf[ (y / 8 + yb) * LCD_W + x ];
for (xcoord_t i=0; i<w; i++){ for (xcoord_t i=0; i<w; i++){
uint8_t b = pgm_read_byte(q++); uint8_t b = pgm_read_byte(q);
q++;
ASSERT_IN_DISPLAY(p); ASSERT_IN_DISPLAY(p);
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
uint8_t val = inv ? ~b : b; uint8_t val = inv ? ~b : b;
@ -199,7 +200,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
b1 = ~b1; b1 = ~b1;
b2 = ~b2; b2 = ~b2;
} }
uint8_t ym8 = (y & 0x07); const uint8_t ym8 = (y & 0x07);
if (&p[LCD_W+1] < DISPLAY_END) { if (&p[LCD_W+1] < DISPLAY_END) {
LCD_BYTE_FILTER(p, ~(0xff << ym8), b1 << ym8); LCD_BYTE_FILTER(p, ~(0xff << ym8), b1 << ym8);
uint8_t *r = p + LCD_W; uint8_t *r = p + LCD_W;
@ -220,7 +221,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
} }
else if (flags & SMLSIZE) { else if (flags & SMLSIZE) {
q = (c < 0xC0) ? &font_4x6[(c-0x20)*5] : &font_4x6_extra[(c-0xC0)*5]; q = (c < 0xC0) ? &font_4x6[(c-0x20)*5] : &font_4x6_extra[(c-0xC0)*5];
uint8_t ym8 = (y & 0x07); const uint8_t ym8 = (y & 0x07);
for (int8_t i=0; i<=6; i++) { for (int8_t i=0; i<=6; i++) {
uint8_t b = 0; uint8_t b = 0;
if (!i) { if (!i) {
@ -247,7 +248,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
} }
else if (flags & TINSIZE) { else if (flags & TINSIZE) {
q = &font_3x5[((uint16_t)c-0x2D)*3]; q = &font_3x5[((uint16_t)c-0x2D)*3];
uint8_t ym8 = (y & 0x07); const uint8_t ym8 = (y & 0x07);
for (int8_t i=0; i<=4; i++) { for (int8_t i=0; i<=4; i++) {
uint8_t b = 0; uint8_t b = 0;
if (!i) { if (!i) {
@ -273,7 +274,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
} }
#endif #endif
else { else {
uint8_t ym8 = (y & 0x07); const uint8_t ym8 = (y & 0x07);
#if defined(BOLD_FONT) && defined(CPUM64) && !defined(EXTSTD) #if defined(BOLD_FONT) && defined(CPUM64) && !defined(EXTSTD)
uint8_t bb = 0; uint8_t bb = 0;
if (inv) bb = 0xff; if (inv) bb = 0xff;
@ -364,7 +365,7 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag
xcoord_t orig_x = x; xcoord_t orig_x = x;
#endif #endif
bool setx = false; bool setx = false;
while(len!=0) { while(len--) {
unsigned char c; unsigned char c;
switch (mode & (BSS+ZCHAR)) { switch (mode & (BSS+ZCHAR)) {
case BSS: case BSS:
@ -408,7 +409,6 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag
x += (c*FW/2); //EXTENDED SPACE x += (c*FW/2); //EXTENDED SPACE
} }
s++; s++;
len--;
} }
lcdLastPos = x; lcdLastPos = x;
lcdNextPos = x; lcdNextPos = x;
@ -671,7 +671,7 @@ void lcd_hlineStip(xcoord_t x, uint8_t y, xcoord_t w, uint8_t pat, LcdFlags att)
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ]; uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
uint8_t msk = BITMASK(y%8); uint8_t msk = BITMASK(y%8);
while(w) { while(w--) {
if(pat&1) { if(pat&1) {
lcd_mask(p, msk, att); lcd_mask(p, msk, att);
pat = (pat >> 1) | 0x80; pat = (pat >> 1) | 0x80;
@ -679,7 +679,6 @@ void lcd_hlineStip(xcoord_t x, uint8_t y, xcoord_t w, uint8_t pat, LcdFlags att)
else { else {
pat = pat >> 1; pat = pat >> 1;
} }
w--;
p++; p++;
} }
} }

View file

@ -4817,7 +4817,8 @@ void stack_paint()
q = &__bss_end ; q = &__bss_end ;
p -= 2 ; p -= 2 ;
while ( p > q ) while ( p > q )
*p-- = 0x55 ; *p = 0x55 ;
p--;
} }
uint16_t stack_free() uint16_t stack_free()
@ -4825,10 +4826,7 @@ uint16_t stack_free()
unsigned char *p ; unsigned char *p ;
p = &__bss_end + 1 ; p = &__bss_end + 1 ;
while ( *p == 0x55 ) while ( *p++ == 0x55 );
{
p+= 1 ;
}
return p - &__bss_end ; return p - &__bss_end ;
} }
#endif #endif