Zahada C atmel studio

Jaroslav Buchta jaroslav.buchta na hascomp.cz
Sobota Květen 3 15:34:02 CEST 2014


To si nemyslim, v podstate jen ctou flash a pouzivaji lokalni male 
promenne...
Kdyz dam c jako volatile, tak to funguje jak ma - jinak pri krokovani se 
prave zda, ze to nejdriv udela c++ a pak vola tu funkci.
Cely projekt je ke stazeni zde http://www.hascomp.cz/test/test1.zip

funkce vypadaji takto:

uint8_t ct[12] = {0, 25, 48, 71, 94, 117, 140, 163, 186, 209, 232, 255};

uint8_t CharHeight(const  uint8_t *font)
{
     uint8_t h = pgm_read_byte(font+1);
     return h;
}

uint8_t CharWidth(uint8_t code, const  uint8_t *font)
{
     code -= 0x20;
     uint16_t ofs = pgm_read_word(font + 4 + code + code);
     uint8_t w = pgm_read_byte(font+ofs+0);
     return w;
}

uint8_t DrawChar (uint8_t code, uint16_t x, uint16_t y, const uint8_t *font)
{
     code -= 0x20;
     uint16_t ofs = pgm_read_word(font + 4 + code + code);
     uint8_t w = pgm_read_byte(font+ofs+0);
     uint8_t h = pgm_read_byte(font+ofs+1);
     uint8_t bl = pgm_read_byte(font+ofs+2);
     ofs += 3;
     uint8_t n = 0;
     y -= bl;
     uint8_t pxx;
     while (h)
     {
         for (uint8_t i = 0; i < w; i++)
         {
             uint8_t px;
             if (n == 0)
             {
                 pxx = pgm_read_byte(font+ofs);
                 px = pxx & 0x0f;
                 ofs++;
                 n = 1;
             }
             else
             {
                 px = pxx >> 4;
                 n = 0;
             }
             if (px == 4) continue;
             px = ct[px-4];
             drawPixel(x+i,y,COLOR565(px,px,0));

         }
         h--;
         y--;
     }


     return w;
}




Dne 3. 5. 2014 14:14, Marek Peca napsal(a):
>> Muze mi nekdo vysvetli, proc v Atmel studiu se mi pri nasledujicim kodu
>>
>>        int16_t x = 0;
>>        int16_t y = CharHeight(FontTahoma_12)+2;
>>        uint8_t c = 0x20;
>>        DrawChar(0x7f, x, y, FontTahoma_12);
>>        while (y < 320)
>>        {
>>
>>            uint8_t w = CharWidth(c, FontTahoma_12); 
>> <-----------------------------------------
>>            if (x + w > 240)
>>            {
>>                x = 0;
>>                y += CharHeight(FontTahoma_12) + 2;
>>                continue;
>>            }
>>            DrawChar(c, x, y, FontTahoma_12);
>>            x += w + 2;
>>            c++;
>>            if (c >= 0x80) c = 0x20;
>>        }
>>
>> dostane do oznacene funkce hodnota c =0x80??? Evidentne je to 
>> optimalizaci (O1), (..)
>
> Tipnul bych, ze nektera z tech tajuplnych fontovych fci nekde prasi a 
> pise do pameti, kam nema.
>
>
> ZdraviM.P.
> _______________________________________________
> HW-list mailing list  -  sponsored by www.HW.cz
> Hw-list na list.hw.cz
> http://list.hw.cz/mailman/listinfo/hw-list


---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com



Další informace o konferenci Hw-list