اطلاعیه

Collapse
No announcement yet.

کمک فوری (تبدیل کتابخانه codevision به atmel studio)

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    کمک فوری (تبدیل کتابخانه codevision به atmel studio)

    با سلام خدمت همه اساتید
    ببخشید یه کتابخانه برای lcd گرافیکی در سایت زیر بئد که دانلودش کردم اما برای کامپایلر codevision هست .

    حال تغییراتی را ایجاد کردم ولی باز هم خطا میگیرد.(مثلا در atmel studio چگونه باید حافظه flash را تعریف کرد ؟؟؟ و چند مورد دیگه )
    /*
    * glcd for atmel studio.c
    *
    * Created: 3/24/2019 808 PM
    * Author : Saati
    */
    #define F_CPU 8000000UL
    #include <util/delay.h>
    #include <stdlib.h>
    #include <string.h>
    #include "font.h"
    #include <math.h>


    typedef unsigned char byte;
    //DEBUG
    //#define DEBUG_READ 0
    //#define DEBUG_GLCD 0
    //----------------------
    #define E_DELAY 3
    #define DATAPORT PORTC
    #define DATADDR DDRC
    #define DATAPIN PINC
    //#define CONTROLPORT PORTB
    #define CS1 PORTD //CS1 = PORTD.3
    #define CS2 PORTD //CS2 = PORTD.4
    #define RS PORTD //RS = PORTD.2
    #define RW PORTD //RW = PORTD.0
    #define EN PORTD //EN = PORTD.1
    //#define CS_ACTIVE_LOW 0 //Define this if your GLCD CS
    //is active low (refer to datasheet)
    #pragma used+

    //--------Arabic----------
    static int prevLet = 193;
    static byte stat = 0;
    static byte prevX = 0;
    static byte prevY = 0;
    //------------------------
    void trigger()
    {
    EN |= (1<<1); //EN high
    _delay_us(E_DELAY);
    EN &= 0; //EN low
    _delay_us(E_DELAY);
    }
    //----------------------
    void glcd_on()
    {
    //Activate both chips
    #ifdef CS_ACTIVE_LOW
    CS1 &= ~(1<<3);
    CS2 &= ~(1<<4);
    #else
    CS1 |= (1<<3);
    CS2 |= (1<<4);
    #endif
    RS &= ~(1<<2); //RS low --> command
    RW &= ~(1<<0); //RW low --> write
    DATAPORT = 0x3F; //ON command
    trigger();
    }
    //----------------------
    void glcd_off()
    {
    //Activate both chips
    #ifdef CS_ACTIVE_LOW
    CS1 &= ~(1<<3);
    CS2 &= ~(1<<4);
    #else
    CS1 |= (1<<3);
    CS2 |= (1<<4);
    #endif
    RS &= ~(1<<2); //RS low --> command
    RW &= ~(1<<1); //RW low --> write
    DATAPORT = 0x3E; //OFF command
    trigger();
    }
    //----------------------
    void set_start_line(byte line)
    {
    RS &= ~(1<<2); //RS low --> command
    RW &= ~(1<<0); //RW low --> write
    //Activate both chips
    #ifdef CS_ACTIVE_LOW
    CS1 &= ~(1<<3);
    CS2 &= ~(1<<4);
    #else
    CS1 |= (1<<3);
    CS2 |= (1<<4);
    #endif
    DATAPORT = 0xC0 | line; //Set Start Line command
    trigger();
    }
    //----------------------
    void goto_col(unsigned int x)
    {
    byte pattern;
    RS &= ~(1<<2); //RS low --> command
    RW &= ~(1<<0); //RW low --> write
    if(x<64) //left section
    {
    #ifdef CS_ACTIVE_LOW
    CS1 &= ~(1<<3); //select chip 1
    CS2 |= (1<<4); //deselect chip 2
    #else
    CS1 |= (1<<3); //select chip 1
    CS2 &= ~(1<<4); //deselect chip 2
    #endif
    pattern = x; //put column address on data port
    }
    else //right section
    {
    #ifdef CS_ACTIVE_LOW
    CS2 &= ~(1<<4);
    CS1 |= (1<<3);
    #else
    CS2 |= (1<<4); //select chip 2
    CS1 &= ~(1<<3); //deselct chip 1
    #endif
    pattern = x-64; //put column address on data port
    }
    pattern = (pattern | 0x40 ) & 0x7F; //Command format
    DATAPORT = pattern;
    trigger();
    }
    //----------------------
    void goto_row(unsigned int y)
    {
    byte pattern;
    RS &= ~(1<<2); //RS low --> command
    RW &= ~(1<<0); //RW low --> write
    pattern = (y | 0xB8 ) & 0xBF; //put row address on data port set command
    DATAPORT = pattern;
    trigger();
    }
    //----------------------
    void goto_xy(unsigned int x,unsigned int y)
    {
    goto_col(x);
    goto_row(y);
    }
    //----------------------
    void glcd_write(byte b)
    {
    RS |= (1<<2); //RS high --> data
    RW &= ~(1<<0); //RW low --> write
    DATAPORT = b; //put data on data port
    _delay_us(1);
    trigger();
    }
    //------------------------
    void glcd_clrln(byte ln)
    {
    int i;
    goto_xy(0,ln); //At start of line of left side
    goto_xy(64,ln); //At start of line of right side (Problem)
    #ifdef CS_ACTIVE_LOW
    CS1 &= ~(1<<3);
    #else
    CS1 |= (1<<3);
    #endif
    for(i=0;i<65;i++)
    glcd_write(0);
    }
    //-------------------------
    void glcd_clear()
    {
    int i;
    for(i=0;i<8;i++)
    glcd_clrln(i);
    }
    //-----------------------
    byte is_busy()
    {
    byte status = 0; //Read data here

    EN &= ~(1<<1); //Low Enable
    _delay_us(1); //tf
    RW |= (1<<0); //Read
    RS &= ~(1<<2); //Status
    _delay_us(1); //tasu
    EN |= (1<<1); //High Enable
    _delay_us(5); //tr + max(td,twh)->twh

    //Dummy read
    EN &= ~(1<<1); //Low Enable
    _delay_us(5); //tf + twl + chineese error

    EN |= (1<<1); //High Enable
    _delay_us(1); //tr + td

    status = DATAPIN; //Input data
    EN &= ~(1<<1); //Low Enable
    _delay_us(1); //tdhr
    #ifdef DEBUG_READ
    printf("S:%x\n\r",status);
    #endif
    return (status & 0x80);
    }
    //-----------------------
    byte glcd_read(byte column)
    {
    byte read_data = 0; //Read data here
    DATADDR = 0x00; //Input

    //while(is_busy());
    RW |= (1<<0); //Read
    RS |= (1<<2); //Data
    #ifdef CS_ACTIVE_LOW
    CS1 |= ((column>63)<<3);
    #else
    CS1 |= ((column<64)<<3); //Enable/Disable CS1
    #endif
    if (CS1 & 0b00001000) //Disable/Enable CS2
    {
    CS2 &=0b11101111; //if PORTD.3 == 1 then PORTD.4 = 0;
    }
    else
    {
    CS2 |=0b00010000; //if PORTD.3 == 0 then PORTD.4 = 1;
    }

    _delay_us(1); //tasu
    EN |= (1<<1); //Latch RAM data into ouput register
    _delay_us(1); //twl + tf

    //Dummy read
    //while(is_busy());
    EN &= ~(1<<1); //Low Enable
    _delay_us(20); //tf + twl + chineese error

    EN |= (1<<1); //latch data from output register to data bus
    _delay_us(1); //tr + td(twh)

    read_data = DATAPIN; //Input data
    EN &= ~(1<<1); //Low Enable to remove data from the bus
    _delay_us(1); //tdhr
    #ifdef DEBUG_READ
    printf("R:%x\n\r",read_data);
    #endif
    DATADDR = 0xFF; //Output again
    return read_data;
    }
    //-----------------------
    /*byte get_point(unsigned int x,unsigned int y)
    {
    byte data;
    goto_xy(x,((int)(y/8)));
    data = glcd_read();
    return data;
    } */
    //----------------------
    void point_at(unsigned int x,unsigned int y,byte color)
    {
    byte pattern;
    goto_xy(x,(int)(y/8));
    switch (color)
    {
    case 0: //Light spot
    pattern = ~(1<<(y%8)) & glcd_read(x);
    break;
    case 1: //Dark spot
    pattern = (1<<(y%8)) | glcd_read(x);
    #ifdef DEBUG_GLCD
    delay_ms(30);/////////////////////////////////////////
    #endif
    break;
    }
    goto_xy(x,(int)(y/8));
    glcd_write(pattern);
    }
    //-----------------------
    void h_line(unsigned int x,unsigned int y,byte l,byte s,byte c)
    {
    int i;
    for(i=x; i<(l+x); i += (byte)(s+1))
    point_at(i,y,c);
    }
    //-----------------------
    void v_line(unsigned int x,unsigned int y,signed int l,byte s,byte c)
    {
    unsigned int i;
    for(i=y; i<(y+l); i += (byte)(s+1))
    point_at(x,i,c);
    }
    //-----------------------
    void line(unsigned int x1,unsigned int y1,
    unsigned int x2,unsigned int y2,
    byte s,byte c)
    {
    byte i;
    byte y01;

    byte temp;

    float a;
    float b;

    byte y00;
    byte y010;

    if(x1==x2)
    {
    v_line(x1,min(y1,y2),abs(y2-y1)+1,s,c);
    }
    else if(y1==y2)
    {
    h_line(min(x1,x2),y1,abs(x2-x1)+1,s,c);
    }
    else
    {
    if(x1>x2)
    {
    temp = x1;
    x1 = x2;
    x2 = temp;
    temp = y1;
    y1 = y2;
    y2 = temp;
    }

    a = (float)(signed)(y2-y1)/(x2-x1);
    b = y1 - a*x1;
    y00 = a*x1 + b;
    y010 = y00;

    for(i=(x1+1); i<=x2; i ++)
    {
    y01 = a*i + b + 0.5; //+ 0.5 to approximate to the nearest integer

    if( (signed char)(y01 - y010) > 1 )
    {
    //-------Subject to error
    v_line((i-1),(byte)(y010+1),(y01-y010-1),s,c);
    }
    else if( (signed char)(y010 - y01) > 1 )
    {
    //-------Subject to error
    v_line((i-1),(byte)(y01+1),(y010-y01-1),s,c);
    }

    if((i==x2) && (y00 == y01)) h_line(x1,y01,(x2-x1),0,c);
    y010 = y01;
    if( y00 == y01) continue;
    h_line(x1,y00,(i-x1),0,c);
    x1 = i;
    y00 = y01;
    }
    point_at(x2,y2,c);
    }
    }
    //-----------------------
    void rectangle(unsigned int x1,unsigned int y1,
    unsigned int x2,unsigned int y2,
    byte s,byte c)
    {
    h_line(x1,y1,(x2-x1),s,c);
    h_line(x1,y2,(x2-x1),s,c);
    v_line(x1,y1,(y2-y1),s,c);
    v_line(x2,y1,(y2-y1+1),s,c);
    }
    //-----------------------
    void cuboid(unsigned int x11,unsigned int y11,
    unsigned int x12,unsigned int y12,
    unsigned int x21,unsigned int y21,
    unsigned int x22,unsigned int y22,
    byte s,byte c)
    {
    rectangle(x11,y11,x12,y12,s,c);
    rectangle(x21,y21,x22,y22,s,c);
    line(x11,y11,x21,y21,s,c);
    line(x12,y11,x22,y21,s,c);
    line(x11,y12,x21,y22,s,c);
    line(x12,y12,x22,y22,s,c);
    }
    //-----------------------
    void h_parallelogram(unsigned int x1,unsigned int y1,
    unsigned int x2,unsigned int y2,
    byte l,byte s,byte c)
    {
    h_line(x1,y1,l,s,c);
    h_line((x2-l+1),y2,l,s,c);
    line(x1,y1,(x2-l+1),y2,s,c);
    line((x1+l-1),y1,x2,y2,s,c);
    }
    //-----------------------
    void v_parallelogram(unsigned int x1,unsigned int y1,
    unsigned int x2,unsigned int y2,
    byte l,byte s,byte c)
    {
    v_line(x1,y1,l,s,c);
    v_line(x2,(y2-l+1),l,s,c);
    line(x1,y1,x2,(y2-l+1),s,c);
    line(x1,(y1+l-1),x2,y2,s,c);
    }
    //-----------------------
    void h_parallelepiped(unsigned int x11,unsigned int y11,
    unsigned int x12,unsigned int y12,byte l1,
    unsigned int x21,unsigned int y21,
    unsigned int x22,unsigned int y22,byte l2,
    byte s,byte c)
    {
    h_parallelogram(x11,y11,x12,y12,l1,s,c);
    h_parallelogram(x21,y21,x22,y22,l2,s,c);
    line(x11,y11,x21,y21,s,c);
    line(x12,y12,x22,y22,s,c);
    line((x11+l1-1),y11,(x21+l2-1),y21,s,c);
    line((x12-l1+1),y12,(x22-l2+1),y22,s,c);
    }
    //-----------------------
    void v_parallelepiped(unsigned int x11,unsigned int y11,
    unsigned int x12,unsigned int y12,byte l1,
    unsigned int x21,unsigned int y21,
    unsigned int x22,unsigned int y22,byte l2,
    byte s,byte c)
    {
    v_parallelogram(x11,y11,x12,y12,l1,s,c);
    v_parallelogram(x21,y21,x22,y22,l2,s,c);
    line(x11,y11,x21,y21,s,c);
    line(x12,y12,x22,y22,s,c);
    line(x11,(y11+l1-1),x21,(y21+l2-1),s,c);
    line(x12,(y12-l1+1),x22,(y22-l2+1),s,c);
    }
    //-----------------------
    void circle(unsigned int x0,unsigned int y0,
    unsigned int r,byte s,byte c)
    {
    byte i,y,y00;
    y00 = r; //Point (0,r) is the 1st point
    for(i=0; i<r; i++)
    {
    y = isqrt((int)r*r - (int)i*i);
    point_at((x0+i),(y0+y),c);
    point_at((x0+i),(y0-y),c);
    point_at((x0-i),(y0+y),c);
    point_at((x0-i),(y0-y),c);
    if(abs(y00-y)>1)
    {
    v_line(x0+(i-1),y0+min(y00,y)+1,abs(y00-y),s,c);
    v_line(x0+(i-1),y0-max(y00,y),abs(y00-y),s,c);
    v_line(x0-(i-1),y0+min(y00,y)+1,abs(y00-y),s,c);
    v_line(x0-(i-1),y0-max(y00,y),abs(y00-y),s,c);
    }
    y00 = y;
    }
    v_line(x0+(i-1) ,y0,y ,s,c);
    v_line(x0+(i-1) ,y0-y ,y,s,c);
    v_line(x0-(i-1) ,y0,y ,s,c);
    v_line(x0-(i-1) ,y0-y ,y,s,c);
    }
    //-----------------------
    //void ellipse(unsigned int x0,unsigned int y0,
    // unsigned int a,unsigned int b,
    // byte s,byte c)
    //{
    // byte i,y,y00;
    // y00 = 1;
    // for(i=0; i < a; i++)
    // {
    // y = isqrt((int)a*a - (int)i*i);
    // point_at((x0+i)*(a+x0)/a,(y0+y)*(b+y0)/b,c);
    // point_at((x0+i)*(a+x0)/a,(y0-y)*(b+y0)/b,c);
    // point_at((x0-i)*(a+x0)/a,(y0+y)*(b+y0)/b,c);
    // point_at((x0-i)*(a+x0)/a,(y0-y)*(b+y0)/b,c);
    // /*if(abs(y00-y)>1)
    // {
    // v_line(x0+(i-1),y0+min(y00,y)+1,abs(y00-y),s,c);
    // v_line(x0+(i-1),y0-max(y00,y),abs(y00-y),s,c);
    // v_line(x0-(i-1),y0+min(y00,y)+1,abs(y00-y),s,c);
    // v_line(x0-(i-1),y0-max(y00,y),abs(y00-y),s,c);
    //
    // printf("y=%u y00=%u\n\r",y,y00);
    // }*/
    // y00 = y;
    // }
    // /*v_line(x0+(i-1) ,y0,y ,s,c);
    // v_line(x0+(i-1) ,y0-y ,y,s,c);
    // v_line(x0-(i-1) ,y0,y ,s,c);
    // v_line(x0-(i-1) ,y0-y ,y,s,c);*/
    //}
    //------------Arabic/English Writing-------
    void putIt(int c,int x,int y)
    {
    byte i;
    goto_col(x);
    goto_row(y);
    for(i=0;i<8;i++)
    {
    glcd_write(font[(8*c)+i]);
    }
    }
    //--------------------------
    void enlarge(char *large,unsigned char c,byte size)
    {
    byte i,j,temp;
    byte k = 0;
    for(i=0;i<size;i++)
    {
    for(j=0;j<8;j++)
    {
    large[i] >>= 1;
    temp = c & 0x01;
    if(temp)
    large[i] |= 0x80;
    if(++k == size)
    {
    c >>= 1;
    k = 0;
    }
    }
    }
    }
    //--------------------------
    void putItSz(int c,int x,int y,byte sz)
    {
    byte i,j,k;
    //char large[8][sz];
    char large[8][8];

    goto_col(x);
    goto_row(y);
    for(i=0;i<8;i++)
    {
    enlarge(large[i],font[(8*c)+i],sz); //c here;GCC (c-1)
    }
    for(j=0;j<sz;j++)
    {
    for(i=0;i<8;i++)
    {
    for(k=0;k<sz;k++)
    {
    if(x+k+(sz*i) == 64) goto_xy(64,y); //Problem 1: Forgot to change 3 to sz
    glcd_write(large[i][j]);
    }
    }
    goto_xy(x,++y);
    }
    }
    //--------------------------
    void glcd_putchar(byte c,int x,int y,byte l,byte sz)
    {
    if(l == 1)
    {
    switch(c)
    {
    case 129:
    c = 250;
    break;
    case 144:
    c = 251;
    break;
    case 152:
    c = 252;
    break;
    case 142:
    c = 253;
    break;
    case 141:
    c = 254;
    break;
    }
    if((c >= 193) && (prevLet >= 193) && (map[prevLet-193][5]) && (map[c-193][4]))
    {
    putIt(map[prevLet-193][stat+1],prevX,prevY);
    stat = 2;
    }else stat = 0;


    if(c >= 193) putItSz(map[c-193][stat],x,y,sz);
    else putItSz(c,x,y,sz);


    prevLet = c;
    prevX = x;
    prevY = y;


    }else putItSz(c,x,y,sz);
    }
    //---------------------------
    void glcd_puts(byte *c,int x,int y,unsigned char l,byte sz,signed char space)
    {
    char i = 0;
    char special = 0;
    while((i<strlen(c)) && l==0)
    {
    glcd_putchar(*(c+i),x,y,0,sz);
    x += (8+space)*sz;
    if(x>128-8*sz)
    {
    x=0;
    y += sz;
    }
    i++;
    }


    while((i<strlen(c)) && l==1)
    {
    if((*(c+i) == 225) && (*(c+i+1) == 199))
    special = 249;
    else if((*(c+i) == 225) && (*(c+i+1) == 195))
    special = 231;
    else if((*(c+i) == 225) && (*(c+i+1) == 194))
    special = 232;
    else if((*(c+i) == 225) && (*(c+i+1) == 197))
    special = 233;
    if(special)
    {
    glcd_putchar(special,x-8*sz,y,1,sz);
    i+=2;
    x -= 8*sz;
    special = 0;
    }
    else
    {
    glcd_putchar(*(c+i),x-8*sz,y,l,sz);
    if(*(c+i) == 32) //If space (i.e. new word)
    {
    x -= (8+space)*sz; //Space between words
    }
    else
    {
    x -= 8*sz;
    }
    i++;
    }
    if(x < 8*sz+1)
    {
    x=128-8*sz;
    y += sz;
    }
    }
    prevLet = 193;
    }
    //------------BMP Display--------------------
    void bmp_disp(flash byte *bmp,unsigned int x1,unsigned int y1,
    unsigned int x2,unsigned int y2)
    {
    unsigned int i,j;
    for(i=y1;i<=y2;i++)
    {
    for(j=x1;j<=x2;j++)
    {
    goto_xy(j,i);
    glcd_write(bmp[(128*i)+j]);
    }
    }
    }

    #pragma used-

    ببخشید خیلی زیاد شد.
    منونم میشم اگر راهنمای کنید.(من تازه کارم یه خورده با جزییات تو ضیح دهید.)

    #2
    پاسخ : کمک فوری (تبدیل کتابخانه codevision به atmel studio)

    نوشته اصلی توسط saati.sms نمایش پست ها
    با سلام خدمت همه اساتید
    ببخشید یه کتابخانه برای lcd گرافیکی در سایت زیر بئد که دانلودش کردم اما برای کامپایلر codevision هست .

    حال تغییراتی را ایجاد کردم ولی باز هم خطا میگیرد.(مثلا در atmel studio چگونه باید حافظه flash را تعریف کرد ؟؟؟ و چند مورد دیگه )
    /*
    * glcd for atmel studio.c
    *
    * Created: 3/24/2019 808 PM
    * Author : Saati
    */
    #define F_CPU 8000000UL
    #include <util/delay.h>
    #include <stdlib.h>
    #include <string.h>
    #include "font.h"
    #include <math.h>


    typedef unsigned char byte;
    //DEBUG
    //#define DEBUG_READ 0
    //#define DEBUG_GLCD 0
    //----------------------
    #define E_DELAY 3
    #define DATAPORT PORTC
    #define DATADDR DDRC
    #define DATAPIN PINC
    //#define CONTROLPORT PORTB
    #define CS1 PORTD //CS1 = PORTD.3
    #define CS2 PORTD //CS2 = PORTD.4
    #define RS PORTD //RS = PORTD.2
    #define RW PORTD //RW = PORTD.0
    #define EN PORTD //EN = PORTD.1
    //#define CS_ACTIVE_LOW 0 //Define this if your GLCD CS
    //is active low (refer to datasheet)
    #pragma used+

    //--------Arabic----------
    static int prevLet = 193;
    static byte stat = 0;
    static byte prevX = 0;
    static byte prevY = 0;
    //------------------------
    void trigger()
    {
    EN |= (1<<1); //EN high
    _delay_us(E_DELAY);
    EN &= 0; //EN low
    _delay_us(E_DELAY);
    }
    //----------------------
    void glcd_on()
    {
    //Activate both chips
    #ifdef CS_ACTIVE_LOW
    CS1 &= ~(1<<3);
    CS2 &= ~(1<<4);
    #else
    CS1 |= (1<<3);
    CS2 |= (1<<4);
    #endif
    RS &= ~(1<<2); //RS low --> command
    RW &= ~(1<<0); //RW low --> write
    DATAPORT = 0x3F; //ON command
    trigger();
    }
    //----------------------
    void glcd_off()
    {
    //Activate both chips
    #ifdef CS_ACTIVE_LOW
    CS1 &= ~(1<<3);
    CS2 &= ~(1<<4);
    #else
    CS1 |= (1<<3);
    CS2 |= (1<<4);
    #endif
    RS &= ~(1<<2); //RS low --> command
    RW &= ~(1<<1); //RW low --> write
    DATAPORT = 0x3E; //OFF command
    trigger();
    }
    //----------------------
    void set_start_line(byte line)
    {
    RS &= ~(1<<2); //RS low --> command
    RW &= ~(1<<0); //RW low --> write
    //Activate both chips
    #ifdef CS_ACTIVE_LOW
    CS1 &= ~(1<<3);
    CS2 &= ~(1<<4);
    #else
    CS1 |= (1<<3);
    CS2 |= (1<<4);
    #endif
    DATAPORT = 0xC0 | line; //Set Start Line command
    trigger();
    }
    //----------------------
    void goto_col(unsigned int x)
    {
    byte pattern;
    RS &= ~(1<<2); //RS low --> command
    RW &= ~(1<<0); //RW low --> write
    if(x<64) //left section
    {
    #ifdef CS_ACTIVE_LOW
    CS1 &= ~(1<<3); //select chip 1
    CS2 |= (1<<4); //deselect chip 2
    #else
    CS1 |= (1<<3); //select chip 1
    CS2 &= ~(1<<4); //deselect chip 2
    #endif
    pattern = x; //put column address on data port
    }
    else //right section
    {
    #ifdef CS_ACTIVE_LOW
    CS2 &= ~(1<<4);
    CS1 |= (1<<3);
    #else
    CS2 |= (1<<4); //select chip 2
    CS1 &= ~(1<<3); //deselct chip 1
    #endif
    pattern = x-64; //put column address on data port
    }
    pattern = (pattern | 0x40 ) & 0x7F; //Command format
    DATAPORT = pattern;
    trigger();
    }
    //----------------------
    void goto_row(unsigned int y)
    {
    byte pattern;
    RS &= ~(1<<2); //RS low --> command
    RW &= ~(1<<0); //RW low --> write
    pattern = (y | 0xB8 ) & 0xBF; //put row address on data port set command
    DATAPORT = pattern;
    trigger();
    }
    //----------------------
    void goto_xy(unsigned int x,unsigned int y)
    {
    goto_col(x);
    goto_row(y);
    }
    //----------------------
    void glcd_write(byte b)
    {
    RS |= (1<<2); //RS high --> data
    RW &= ~(1<<0); //RW low --> write
    DATAPORT = b; //put data on data port
    _delay_us(1);
    trigger();
    }
    //------------------------
    void glcd_clrln(byte ln)
    {
    int i;
    goto_xy(0,ln); //At start of line of left side
    goto_xy(64,ln); //At start of line of right side (Problem)
    #ifdef CS_ACTIVE_LOW
    CS1 &= ~(1<<3);
    #else
    CS1 |= (1<<3);
    #endif
    for(i=0;i<65;i++)
    glcd_write(0);
    }
    //-------------------------
    void glcd_clear()
    {
    int i;
    for(i=0;i<8;i++)
    glcd_clrln(i);
    }
    //-----------------------
    byte is_busy()
    {
    byte status = 0; //Read data here

    EN &= ~(1<<1); //Low Enable
    _delay_us(1); //tf
    RW |= (1<<0); //Read
    RS &= ~(1<<2); //Status
    _delay_us(1); //tasu
    EN |= (1<<1); //High Enable
    _delay_us(5); //tr + max(td,twh)->twh

    //Dummy read
    EN &= ~(1<<1); //Low Enable
    _delay_us(5); //tf + twl + chineese error

    EN |= (1<<1); //High Enable
    _delay_us(1); //tr + td

    status = DATAPIN; //Input data
    EN &= ~(1<<1); //Low Enable
    _delay_us(1); //tdhr
    #ifdef DEBUG_READ
    printf("S:%x\n\r",status);
    #endif
    return (status & 0x80);
    }
    //-----------------------
    byte glcd_read(byte column)
    {
    byte read_data = 0; //Read data here
    DATADDR = 0x00; //Input

    //while(is_busy());
    RW |= (1<<0); //Read
    RS |= (1<<2); //Data
    #ifdef CS_ACTIVE_LOW
    CS1 |= ((column>63)<<3);
    #else
    CS1 |= ((column<64)<<3); //Enable/Disable CS1
    #endif
    if (CS1 & 0b00001000) //Disable/Enable CS2
    {
    CS2 &=0b11101111; //if PORTD.3 == 1 then PORTD.4 = 0;
    }
    else
    {
    CS2 |=0b00010000; //if PORTD.3 == 0 then PORTD.4 = 1;
    }

    _delay_us(1); //tasu
    EN |= (1<<1); //Latch RAM data into ouput register
    _delay_us(1); //twl + tf

    //Dummy read
    //while(is_busy());
    EN &= ~(1<<1); //Low Enable
    _delay_us(20); //tf + twl + chineese error

    EN |= (1<<1); //latch data from output register to data bus
    _delay_us(1); //tr + td(twh)

    read_data = DATAPIN; //Input data
    EN &= ~(1<<1); //Low Enable to remove data from the bus
    _delay_us(1); //tdhr
    #ifdef DEBUG_READ
    printf("R:%x\n\r",read_data);
    #endif
    DATADDR = 0xFF; //Output again
    return read_data;
    }
    //-----------------------
    /*byte get_point(unsigned int x,unsigned int y)
    {
    byte data;
    goto_xy(x,((int)(y/8)));
    data = glcd_read();
    return data;
    } */
    //----------------------
    void point_at(unsigned int x,unsigned int y,byte color)
    {
    byte pattern;
    goto_xy(x,(int)(y/8));
    switch (color)
    {
    case 0: //Light spot
    pattern = ~(1<<(y%8)) & glcd_read(x);
    break;
    case 1: //Dark spot
    pattern = (1<<(y%8)) | glcd_read(x);
    #ifdef DEBUG_GLCD
    delay_ms(30);/////////////////////////////////////////
    #endif
    break;
    }
    goto_xy(x,(int)(y/8));
    glcd_write(pattern);
    }
    //-----------------------
    void h_line(unsigned int x,unsigned int y,byte l,byte s,byte c)
    {
    int i;
    for(i=x; i<(l+x); i += (byte)(s+1))
    point_at(i,y,c);
    }
    //-----------------------
    void v_line(unsigned int x,unsigned int y,signed int l,byte s,byte c)
    {
    unsigned int i;
    for(i=y; i<(y+l); i += (byte)(s+1))
    point_at(x,i,c);
    }
    //-----------------------
    void line(unsigned int x1,unsigned int y1,
    unsigned int x2,unsigned int y2,
    byte s,byte c)
    {
    byte i;
    byte y01;

    byte temp;

    float a;
    float b;

    byte y00;
    byte y010;

    if(x1==x2)
    {
    v_line(x1,min(y1,y2),abs(y2-y1)+1,s,c);
    }
    else if(y1==y2)
    {
    h_line(min(x1,x2),y1,abs(x2-x1)+1,s,c);
    }
    else
    {
    if(x1>x2)
    {
    temp = x1;
    x1 = x2;
    x2 = temp;
    temp = y1;
    y1 = y2;
    y2 = temp;
    }

    a = (float)(signed)(y2-y1)/(x2-x1);
    b = y1 - a*x1;
    y00 = a*x1 + b;
    y010 = y00;

    for(i=(x1+1); i<=x2; i ++)
    {
    y01 = a*i + b + 0.5; //+ 0.5 to approximate to the nearest integer

    if( (signed char)(y01 - y010) > 1 )
    {
    //-------Subject to error
    v_line((i-1),(byte)(y010+1),(y01-y010-1),s,c);
    }
    else if( (signed char)(y010 - y01) > 1 )
    {
    //-------Subject to error
    v_line((i-1),(byte)(y01+1),(y010-y01-1),s,c);
    }

    if((i==x2) && (y00 == y01)) h_line(x1,y01,(x2-x1),0,c);
    y010 = y01;
    if( y00 == y01) continue;
    h_line(x1,y00,(i-x1),0,c);
    x1 = i;
    y00 = y01;
    }
    point_at(x2,y2,c);
    }
    }
    //-----------------------
    void rectangle(unsigned int x1,unsigned int y1,
    unsigned int x2,unsigned int y2,
    byte s,byte c)
    {
    h_line(x1,y1,(x2-x1),s,c);
    h_line(x1,y2,(x2-x1),s,c);
    v_line(x1,y1,(y2-y1),s,c);
    v_line(x2,y1,(y2-y1+1),s,c);
    }
    //-----------------------
    void cuboid(unsigned int x11,unsigned int y11,
    unsigned int x12,unsigned int y12,
    unsigned int x21,unsigned int y21,
    unsigned int x22,unsigned int y22,
    byte s,byte c)
    {
    rectangle(x11,y11,x12,y12,s,c);
    rectangle(x21,y21,x22,y22,s,c);
    line(x11,y11,x21,y21,s,c);
    line(x12,y11,x22,y21,s,c);
    line(x11,y12,x21,y22,s,c);
    line(x12,y12,x22,y22,s,c);
    }
    //-----------------------
    void h_parallelogram(unsigned int x1,unsigned int y1,
    unsigned int x2,unsigned int y2,
    byte l,byte s,byte c)
    {
    h_line(x1,y1,l,s,c);
    h_line((x2-l+1),y2,l,s,c);
    line(x1,y1,(x2-l+1),y2,s,c);
    line((x1+l-1),y1,x2,y2,s,c);
    }
    //-----------------------
    void v_parallelogram(unsigned int x1,unsigned int y1,
    unsigned int x2,unsigned int y2,
    byte l,byte s,byte c)
    {
    v_line(x1,y1,l,s,c);
    v_line(x2,(y2-l+1),l,s,c);
    line(x1,y1,x2,(y2-l+1),s,c);
    line(x1,(y1+l-1),x2,y2,s,c);
    }
    //-----------------------
    void h_parallelepiped(unsigned int x11,unsigned int y11,
    unsigned int x12,unsigned int y12,byte l1,
    unsigned int x21,unsigned int y21,
    unsigned int x22,unsigned int y22,byte l2,
    byte s,byte c)
    {
    h_parallelogram(x11,y11,x12,y12,l1,s,c);
    h_parallelogram(x21,y21,x22,y22,l2,s,c);
    line(x11,y11,x21,y21,s,c);
    line(x12,y12,x22,y22,s,c);
    line((x11+l1-1),y11,(x21+l2-1),y21,s,c);
    line((x12-l1+1),y12,(x22-l2+1),y22,s,c);
    }
    //-----------------------
    void v_parallelepiped(unsigned int x11,unsigned int y11,
    unsigned int x12,unsigned int y12,byte l1,
    unsigned int x21,unsigned int y21,
    unsigned int x22,unsigned int y22,byte l2,
    byte s,byte c)
    {
    v_parallelogram(x11,y11,x12,y12,l1,s,c);
    v_parallelogram(x21,y21,x22,y22,l2,s,c);
    line(x11,y11,x21,y21,s,c);
    line(x12,y12,x22,y22,s,c);
    line(x11,(y11+l1-1),x21,(y21+l2-1),s,c);
    line(x12,(y12-l1+1),x22,(y22-l2+1),s,c);
    }
    //-----------------------
    void circle(unsigned int x0,unsigned int y0,
    unsigned int r,byte s,byte c)
    {
    byte i,y,y00;
    y00 = r; //Point (0,r) is the 1st point
    for(i=0; i<r; i++)
    {
    y = isqrt((int)r*r - (int)i*i);
    point_at((x0+i),(y0+y),c);
    point_at((x0+i),(y0-y),c);
    point_at((x0-i),(y0+y),c);
    point_at((x0-i),(y0-y),c);
    if(abs(y00-y)>1)
    {
    v_line(x0+(i-1),y0+min(y00,y)+1,abs(y00-y),s,c);
    v_line(x0+(i-1),y0-max(y00,y),abs(y00-y),s,c);
    v_line(x0-(i-1),y0+min(y00,y)+1,abs(y00-y),s,c);
    v_line(x0-(i-1),y0-max(y00,y),abs(y00-y),s,c);
    }
    y00 = y;
    }
    v_line(x0+(i-1) ,y0,y ,s,c);
    v_line(x0+(i-1) ,y0-y ,y,s,c);
    v_line(x0-(i-1) ,y0,y ,s,c);
    v_line(x0-(i-1) ,y0-y ,y,s,c);
    }
    //-----------------------
    //void ellipse(unsigned int x0,unsigned int y0,
    // unsigned int a,unsigned int b,
    // byte s,byte c)
    //{
    // byte i,y,y00;
    // y00 = 1;
    // for(i=0; i < a; i++)
    // {
    // y = isqrt((int)a*a - (int)i*i);
    // point_at((x0+i)*(a+x0)/a,(y0+y)*(b+y0)/b,c);
    // point_at((x0+i)*(a+x0)/a,(y0-y)*(b+y0)/b,c);
    // point_at((x0-i)*(a+x0)/a,(y0+y)*(b+y0)/b,c);
    // point_at((x0-i)*(a+x0)/a,(y0-y)*(b+y0)/b,c);
    // /*if(abs(y00-y)>1)
    // {
    // v_line(x0+(i-1),y0+min(y00,y)+1,abs(y00-y),s,c);
    // v_line(x0+(i-1),y0-max(y00,y),abs(y00-y),s,c);
    // v_line(x0-(i-1),y0+min(y00,y)+1,abs(y00-y),s,c);
    // v_line(x0-(i-1),y0-max(y00,y),abs(y00-y),s,c);
    //
    // printf("y=%u y00=%u\n\r",y,y00);
    // }*/
    // y00 = y;
    // }
    // /*v_line(x0+(i-1) ,y0,y ,s,c);
    // v_line(x0+(i-1) ,y0-y ,y,s,c);
    // v_line(x0-(i-1) ,y0,y ,s,c);
    // v_line(x0-(i-1) ,y0-y ,y,s,c);*/
    //}
    //------------Arabic/English Writing-------
    void putIt(int c,int x,int y)
    {
    byte i;
    goto_col(x);
    goto_row(y);
    for(i=0;i<8;i++)
    {
    glcd_write(font[(8*c)+i]);
    }
    }
    //--------------------------
    void enlarge(char *large,unsigned char c,byte size)
    {
    byte i,j,temp;
    byte k = 0;
    for(i=0;i<size;i++)
    {
    for(j=0;j<8;j++)
    {
    large[i] >>= 1;
    temp = c & 0x01;
    if(temp)
    large[i] |= 0x80;
    if(++k == size)
    {
    c >>= 1;
    k = 0;
    }
    }
    }
    }
    //--------------------------
    void putItSz(int c,int x,int y,byte sz)
    {
    byte i,j,k;
    //char large[8][sz];
    char large[8][8];

    goto_col(x);
    goto_row(y);
    for(i=0;i<8;i++)
    {
    enlarge(large[i],font[(8*c)+i],sz); //c here;GCC (c-1)
    }
    for(j=0;j<sz;j++)
    {
    for(i=0;i<8;i++)
    {
    for(k=0;k<sz;k++)
    {
    if(x+k+(sz*i) == 64) goto_xy(64,y); //Problem 1: Forgot to change 3 to sz
    glcd_write(large[i][j]);
    }
    }
    goto_xy(x,++y);
    }
    }
    //--------------------------
    void glcd_putchar(byte c,int x,int y,byte l,byte sz)
    {
    if(l == 1)
    {
    switch(c)
    {
    case 129:
    c = 250;
    break;
    case 144:
    c = 251;
    break;
    case 152:
    c = 252;
    break;
    case 142:
    c = 253;
    break;
    case 141:
    c = 254;
    break;
    }
    if((c >= 193) && (prevLet >= 193) && (map[prevLet-193][5]) && (map[c-193][4]))
    {
    putIt(map[prevLet-193][stat+1],prevX,prevY);
    stat = 2;
    }else stat = 0;


    if(c >= 193) putItSz(map[c-193][stat],x,y,sz);
    else putItSz(c,x,y,sz);


    prevLet = c;
    prevX = x;
    prevY = y;


    }else putItSz(c,x,y,sz);
    }
    //---------------------------
    void glcd_puts(byte *c,int x,int y,unsigned char l,byte sz,signed char space)
    {
    char i = 0;
    char special = 0;
    while((i<strlen(c)) && l==0)
    {
    glcd_putchar(*(c+i),x,y,0,sz);
    x += (8+space)*sz;
    if(x>128-8*sz)
    {
    x=0;
    y += sz;
    }
    i++;
    }


    while((i<strlen(c)) && l==1)
    {
    if((*(c+i) == 225) && (*(c+i+1) == 199))
    special = 249;
    else if((*(c+i) == 225) && (*(c+i+1) == 195))
    special = 231;
    else if((*(c+i) == 225) && (*(c+i+1) == 194))
    special = 232;
    else if((*(c+i) == 225) && (*(c+i+1) == 197))
    special = 233;
    if(special)
    {
    glcd_putchar(special,x-8*sz,y,1,sz);
    i+=2;
    x -= 8*sz;
    special = 0;
    }
    else
    {
    glcd_putchar(*(c+i),x-8*sz,y,l,sz);
    if(*(c+i) == 32) //If space (i.e. new word)
    {
    x -= (8+space)*sz; //Space between words
    }
    else
    {
    x -= 8*sz;
    }
    i++;
    }
    if(x < 8*sz+1)
    {
    x=128-8*sz;
    y += sz;
    }
    }
    prevLet = 193;
    }
    //------------BMP Display--------------------
    void bmp_disp(flash byte *bmp,unsigned int x1,unsigned int y1,
    unsigned int x2,unsigned int y2)
    {
    unsigned int i,j;
    for(i=y1;i<=y2;i++)
    {
    for(j=x1;j<=x2;j++)
    {
    goto_xy(j,i);
    glcd_write(bmp[(128*i)+j]);
    }
    }
    }

    #pragma used-

    ببخشید خیلی زیاد شد.
    منونم میشم اگر راهنمای کنید.(من تازه کارم یه خورده با جزییات تو ضیح دهید.)
    سلام
    کار کردن با فلش اش کمی دردسر اش بیشتر از کدویژنه.اول از همه باید هدر زیر رو اول هر فایلی که قراره با متغیرهای فلش کار کنه اد کنید:

    #include <avr/pgmspace.h>

    برای تعریف متغیر فلش هم باید به این شکل عمل کنید:

    const unsigned char PROGMEM A = 0x01;

    عبارت PROGMEM رو باید به تعریف اضافه کنید. کلمه const هم فراموش نشه؛ نبودش باعث ارور میشه. طبیعتا باید مقدار دهی اولیه هم داشته باشه.
    برای دسترسی به متغیر فلش هم باید به شکل زیر عمل کنید. تو این مثال مقدار متغیر A که
    0x01 هستش روی PORTA ریخته میشه:
    [CPP]
    CPP]
    PORTA = PGM_READ_BYTE(&A);

    البته برای متغیر هایی از نوع int و بقیه باید از شبه تابع خودش برای دسترسی داشتن استفاده کنید که توی همون هدری که گفتم بگردید پیدا میشه.ضما همونطور که از قطعه کدی که نوشتم معلومه، این شبه تابع ها با آدرس متغییر کار میکن.
    موفق باشید
    جدیدترین ویرایش توسط hossein.m98; ۰۰:۴۰ ۱۳۹۸/۰۱/۰۵.

    دیدگاه


      #3
      پاسخ : کمک فوری (تبدیل کتابخانه codevision به atmel studio)

      نوشته اصلی توسط hossein.m98 نمایش پست ها
      سلام
      کار کردن با فلش اش کمی دردسر اش بیشتر از کدویژنه.اول از همه باید هدر زیر رو اول هر فایلی که قراره با متغیرهای فلش کار کنه اد کنید:

      #include <avr/pgmspace.h>

      برای تعریف متغیر فلش هم باید به این شکل عمل کنید:

      const unsigned char PROGMEM A = 0x01;

      عبارت PROGMEM رو باید به تعریف اضافه کنید. کلمه const هم فراموش نشه؛ نبودش باعث ارور میشه. طبیعتا باید مقدار دهی اولیه هم داشته باشه.
      برای دسترسی به متغیر فلش هم باید به شکل زیر عمل کنید. تو این مثال مقدار متغیر A که
      0x01 هستش روی PORTA ریخته میشه:
      [CPP]
      CPP]
      PORTA = PGM_READ_BYTE(&A);

      البته برای متغیر هایی از نوع int و بقیه باید از شبه تابع خودش برای دسترسی داشتن استفاده کنید که توی همون هدری که گفتم بگردید پیدا میشه.ضما همونطور که از قطعه کدی که نوشتم معلومه، این شبه تابع ها با آدرس متغییر کار میکن.
      موفق باشید
      خیلی ممنون بابت راهنمایی تون.
      ولی من خوب متو جه نشدم.
      1- باید کتابخانه avr/pgmapace.h رو include کنیم.
      2- داخل برنامه ای که برای کامپایلر کدویژن نوشته شده است برای حافظه فلش که به صورت زیر است :

      flash unsigned char font[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //1/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //2/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //3/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //4/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //5/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //6/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //7/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //8/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //9/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //10/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //11/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //12/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //13/ --> Problem 2
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //14/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //15/ -->
      0x20,0x20,0x28,0x28,0x68,0xB0,0x60,0x20, //16/ -->
      0x20,0x20,0x28,0x2A,0x28,0x30,0x20,0x20, //17/ -->
      0x00,0x80,0x80,0x44,0x32,0x24,0x20,0x20, //18/ -->
      0x00,0x24,0x24,0x24,0x38,0x20,0x20,0x20, //19/ -->
      0x20,0x20,0x20,0x20,0x24,0x2A,0x11,0x00, //20/ -->
      0x20,0x20,0x20,0x24,0x2A,0x11,0x20,0x20, //21/ -->
      0x30,0x20,0x20,0x20,0x24,0x2A,0x11,0x20, //22/ -->
      0x20,0x20,0x30,0x20,0x30,0x28,0x28,0x18, //23/ -->
      0x20,0x24,0x22,0x21,0x24,0x2A,0x11,0x00, //24/ -->
      0x24,0x22,0x21,0x24,0x2A,0x11,0x20,0x20, //25/ -->
      0x30,0x24,0x22,0x21,0x24,0x2A,0x11,0x20, //26/ -->
      0x00,0x80,0x80,0x40,0x30,0x20,0x20,0x20, //27/ -->
      0x20,0x20,0x20,0x60,0xA0,0x60,0x28,0x30, //28/ -->
      0x20,0x20,0x20,0x60,0xB0,0x60,0x20,0x20, //29/ -->
      0x00,0x30,0x28,0x60,0xA0,0x60,0x30,0x20, //30/ -->
      0x00,0x04,0x06,0x1D,0x25,0x24,0x20,0x20, //31/ -->
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //32/ -->
      0x00,0x00,0x4F,0x00,0x00,0x00,0x00,0x00, //33/ --> !
      0x00,0x07,0x00,0x07,0x00,0x00,0x00,0x00, //34/ --> "
      0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00, //35/ --> #
      0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00, //36/ --> $
      0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00, //37/ --> %
      0x00,0x36,0x49,0x55,0x22,0x40,0x00,0x00, //38/ --> &
      0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00, //39/ --> '
      0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00, //40/ --> (
      0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00, //41/ --> )
      0x00,0x14,0x08,0x3E,0x08,0x14,0x00,0x00, //42/ --> *
      0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00, //43/ --> +
      0x00,0x00,0x28,0x18,0x00,0x00,0x00,0x00, //44/ --> ,
      0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, //45/ --> -
      0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00, //46/ --> .
      0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00, //47/ --> /
      0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00, //48/ --> 0
      0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00, //49/ --> 1
      0x00,0x42,0x61,0x51,0x49,0x46,0x00,0x00, //50/ --> 2
      0x00,0x21,0x41,0x45,0x4B,0x31,0x00,0x00, //51/ --> 3
      0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00, //52/ --> 4
      0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00, //53/ --> 5
      0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00, //54/ --> 6
      0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00, //55/ --> 7
      0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, //56/ --> 8
      0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00, //57/ --> 9
      0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00, //58/ --> :
      0x00,0x00,0x56,0x36,0x00,0x00,0x00,0x00, //59/ --> ;
      0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00, //60/ --> <
      0x00,0x24,0x24,0x24,0x24,0x24,0x00,0x00, //61/ --> =
      0x00,0x00,0x41,0x22,0x14,0x08,0x00,0x00, //62/ --> >
      0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00, //63/ --> ?
      0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00, //64/ --> @
      0x00,0x7E,0x11,0x11,0x11,0x7E,0x00,0x00, //65/ --> A
      0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00, //66/ --> B
      0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00, //67/ --> C
      0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00, //68/ --> D
      0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00, //69/ --> E
      0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00, //70/ --> F
      0x00,0x3E,0x41,0x49,0x49,0x3A,0x00,0x00, //71/ --> G
      0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00, //72/ --> H
      0x00,0x00,0x41,0x7F,0x41,0x00,0x00,0x00, //73/ --> I
      0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00, //74/ --> J
      0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00, //75/ --> K
      0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00, //76/ --> L
      0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00, //77/ --> M
      0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00, //78/ --> N
      0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00, //79/ --> O
      0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00, //80/ --> P
      0x3E,0x41,0x51,0x21,0x5E,0x00,0x00,0x00, //81/ --> Q
      0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00, //82/ --> R
      0x00,0x46,0x49,0x49,0x49,0x31,0x00,0x00, //83/ --> S
      0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00, //84/ --> T
      0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00, //85/ --> U
      0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00, //86/ --> V
      0x00,0x3F,0x40,0x60,0x40,0x3F,0x00,0x00, //87/ --> W
      0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00, //88/ --> X
      0x00,0x07,0x08,0x70,0x08,0x07,0x00,0x00, //89/ --> Y
      0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00, //90/ --> Z
      0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00, //91/ --> [
      0x00,0x15,0x16,0x7C,0x16,0x15,0x00,0x00, //92/ --> '\'
      0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00, //93/ --> ]
      0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00, //94/ --> ^
      0x00,0x40,0x40,0x40,0x40,0x40,0x00,0x00, //95/ --> _
      0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00, //96/ --> `
      0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00, //97/ --> a
      0x00,0x7F,0x44,0x44,0x44,0x38,0x00,0x00, //98/ --> b
      0x00,0x38,0x44,0x44,0x44,0x00,0x00,0x00, //99/ --> c
      0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00, //100/ --> d
      0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00, //101/ --> e
      0x00,0x10,0x7E,0x11,0x01,0x02,0x00,0x00, //102/ --> f
      0x00,0x0C,0x52,0x52,0x52,0x3E,0x00,0x00, //103/ --> g
      0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00, //104/ --> h
      0x00,0x00,0x44,0x7D,0x40,0x00,0x00,0x00, //105/ --> i
      0x00,0x20,0x40,0x40,0x3D,0x00,0x00,0x00, //106/ --> j
      0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00, //107/ --> k
      0x00,0x00,0x41,0x7F,0x40,0x00,0x00,0x00, //108/ --> l
      0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00, //109/ --> m
      0x00,0x7C,0x08,0x04,0x04,0x78,0x00,0x00, //110/ --> n
      0x00,0x38,0x44,0x44,0x44,0x38,0x00,0x00, //111/ --> o
      0x00,0x7C,0x14,0x14,0x14,0x08,0x00,0x00, //112/ --> p
      0x00,0x08,0x14,0x14,0x18,0x7C,0x00,0x00, //113/ --> q
      0x00,0x7C,0x08,0x04,0x04,0x08,0x00,0x00, //114/ --> r
      0x00,0x48,0x54,0x54,0x54,0x20,0x00,0x00, //115/ --> s
      0x00,0x04,0x3F,0x44,0x40,0x20,0x00,0x00, //116/ --> t
      0x00,0x3C,0x40,0x40,0x20,0x7C,0x00,0x00, //117/ --> u
      0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00, //118/ --> v
      0x00,0x1E,0x20,0x10,0x20,0x1E,0x00,0x00, //119/ --> w
      0x00,0x22,0x14,0x08,0x14,0x22,0x00,0x00, //120/ --> x
      0x00,0x06,0x48,0x48,0x48,0x3E,0x00,0x00, //121/ --> y
      0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00, //122/ --> z
      0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00, //123/ --> {
      0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00, //124/ --> |
      0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00, //125/ --> }
      0x00,0x08,0x08,0x2A,0x1C,0x08,0x00,0x00, //126/ --> ~
      0x00,0x08,0x1C,0x2A,0x08,0x08,0x00,0x00, //127/ --> 
      0x00,0x3C,0x42,0x41,0x42,0x3C,0x00,0x00, //128/ --> €
      0x00,0x30,0x28,0x60,0xA0,0x60,0x28,0x30, //129/ --> پ
      0x20,0x20,0x20,0x20,0xA0,0x20,0x28,0x30, //130/ --> ‚
      0x20,0x20,0x20,0x20,0xB0,0x20,0x20,0x20, //131/ --> ƒ
      0x00,0x30,0x28,0x20,0xA0,0x20,0x30,0x20, //132/ --> „
      0x20,0x20,0x20,0x22,0x20,0x22,0x28,0x30, //133/ --> …
      0x20,0x20,0x20,0x22,0x30,0x22,0x20,0x20, //134/ --> †
      0x00,0x30,0x28,0x22,0x20,0x22,0x30,0x20, //135/ --> ‡
      0x20,0x20,0x20,0x22,0x21,0x22,0x28,0x30, //136/ --> ˆ
      0x20,0x20,0x20,0x22,0x31,0x22,0x20,0x20, //137/ --> ‰
      0x00,0x30,0x28,0x22,0x21,0x22,0x30,0x20, //138/ --> ٹ
      0x20,0x20,0x28,0x28,0x28,0xB0,0x20,0x20, //139/ --> ‹
      0x20,0x20,0x28,0x28,0x28,0x30,0x20,0x20, //140/ --> Œ
      0x00,0xC0,0xA8,0x28,0x68,0xB0,0x60,0x20, //141/ --> چ
      0x00,0x00,0x80,0x80,0x44,0x32,0x04,0x00, //142/ --> ژ
      0x00,0x24,0x25,0x24,0x38,0x20,0x20,0x20, //143/ --> ڈ
      0x30,0x24,0x22,0x21,0x24,0x2A,0x11,0x00, //144/ --> گ
      0x00,0x80,0x80,0x40,0x34,0x20,0x20,0x20, //145/ --> ‘
      0x20,0x20,0x20,0x38,0x20,0x38,0x20,0x18, //146/ --> ’
      0x20,0x20,0x38,0x20,0x38,0x20,0x38,0x20, //147/ --> “
      0x60,0x80,0x80,0x78,0x20,0x38,0x20,0x18, //148/ --> ”
      0x20,0x20,0x20,0x38,0x22,0x39,0x22,0x18, //149/ --> •
      0x20,0x20,0x38,0x22,0x39,0x22,0x38,0x20, //150/ --> –
      0x60,0x80,0x80,0x78,0x22,0x39,0x22,0x18, //151/ --> —
      0x30,0x20,0x20,0x20,0x24,0x2A,0x11,0x00, //152/ --> ک
      0x20,0x30,0x20,0x30,0x28,0x28,0x38,0x20, //153/ --> ™
      0x60,0x80,0x80,0x60,0x30,0x28,0x28,0x38, //154/ --> ڑ
      0x20,0x20,0x30,0x20,0x30,0x28,0x2A,0x18, //155/ --> ›
      0x20,0x30,0x20,0x30,0x28,0x2A,0x38,0x20, //156/ --> œ
      0x60,0x80,0x80,0x60,0x30,0x28,0x2A,0x38, //157/ --> *
      0x20,0x20,0x3E,0x30,0x28,0x28,0x38,0x20, //158/ --> *
      0x20,0x20,0x3E,0x30,0x28,0x2A,0x38,0x20, //159/ --> ں
      0x20,0x20,0x20,0x20,0x30,0x28,0x28,0x00, //160/ -->
      0x20,0x20,0x20,0x30,0x28,0x28,0x20,0x20, //161/ --> ،
      0x00,0x40,0xA0,0xB0,0x28,0x28,0x20,0x20, //162/ --> ¢
      0x20,0x20,0x20,0x20,0x30,0x28,0x2A,0x00, //163/ --> £
      0x20,0x20,0x20,0x30,0x28,0x2A,0x20,0x20, //164/ --> ¤
      0x00,0x40,0xA0,0xB0,0x28,0x2A,0x20,0x20, //165/ --> ¥
      0x20,0x20,0x20,0x20,0x30,0x28,0x2A,0x30, //166/ --> ¦
      0x20,0x20,0x30,0x28,0x2A,0x30,0x20,0x20, //167/ --> §
      0x00,0x18,0x20,0x20,0x30,0x28,0x2A,0x30, //168/ --> ¨
      0x20,0x20,0x20,0x20,0x30,0x2A,0x28,0x32, //169/ --> ©
      0x20,0x20,0x30,0x2A,0x28,0x32,0x20,0x20, //170/ --> ھ
      0x60,0x80,0x80,0xB2,0xA8,0x7A,0x20,0x20, //171/ --> «
      0x22,0x25,0x25,0x25,0x25,0x25,0x25,0x19, //172/ --> ¬
      0x20,0x20,0x20,0x1C,0x22,0x21,0x20,0x20, //173/ --> *
      0x30,0x28,0x2C,0x2A,0x20,0x3F,0x20,0x20, //174/ --> ®
      0x20,0x20,0x20,0x20,0x20,0x20,0x1F,0x00, //175/ --> ¯
      0x20,0x20,0x20,0x20,0x1F,0x20,0x20,0x20, //176/ --> °
      0x00,0x30,0x40,0x40,0x3F,0x20,0x20,0x20, //177/ --> ±
      0x20,0x20,0x20,0x20,0x30,0x48,0x48,0x30, //178/ --> ²
      0x20,0x20,0x30,0x48,0x48,0x30,0x20,0x20, //179/ --> ³
      0x80,0x40,0x30,0x48,0x48,0x30,0x20,0x20, //180/ --> ´
      0x20,0x20,0x20,0x20,0x22,0x20,0x18,0x00, //181/ --> µ
      0x20,0x20,0x20,0x20,0x1A,0x20,0x20,0x20, //182/ --> ¶
      0x30,0x40,0x44,0x40,0x30,0x20,0x20,0x20, //183/ --> ·
      0x20,0x20,0x20,0x30,0x28,0x3A,0x2C,0x18, //184/ --> ¸
      0x20,0x20,0x30,0x28,0x3A,0x2C,0x38,0x20, //185/ --> ¹
      0x00,0x18,0x14,0x14,0x18,0x20,0x20,0x20, //186/ --> ؛
      0x00,0x21,0x22,0x24,0x28,0x10,0x0F,0x00, //187/ --> »
      0x00,0xB0,0xA8,0x78,0x20,0x20,0x20,0x20, //188/ --> ¼
      0x20,0x20,0x20,0xA0,0x20,0xA0,0x28,0x30, //189/ --> ½
      0x20,0x20,0x20,0xA0,0x30,0xA0,0x20,0x20, //190/ --> ¾
      0x00,0x60,0x80,0x80,0xA0,0x50,0x10,0x20, //191/ --> ؟
      0x00,0x1E,0x20,0x20,0x20,0x20,0x20,0x20, //192/ --> ہ
      0x00,0x20,0x30,0x28,0x28,0x20,0x00,0x00, //193/ --> ء
      0x00,0x04,0x02,0x02,0x3A,0x02,0x02,0x01, //194/ --> آ
      0x00,0x00,0x04,0x06,0x3D,0x05,0x04,0x00, //195/ --> أ
      0x00,0x00,0x04,0xB6,0xAD,0x7D,0x04,0x00, //196/ --> و
      0x00,0x00,0x80,0xC0,0xBF,0xA0,0x80,0x00, //197/ --> ا
      0x04,0x66,0x85,0x95,0xA8,0xA8,0x48,0x00, //198/ --> ئ
      0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, //199/ --> ا
      0x00,0x30,0x28,0x20,0xA0,0x20,0x28,0x30, //200/ --> ب
      0x00,0x00,0x30,0x2A,0x28,0x32,0x00,0x00, //201/ --> ه
      0x00,0x30,0x28,0x22,0x20,0x22,0x28,0x30, //202/ --> ت
      0x00,0x30,0x28,0x22,0x21,0x22,0x28,0x30, //203/ --> ث
      0x00,0xC0,0xA8,0xA8,0x28,0xB0,0x20,0x20, //204/ --> ج
      0x00,0xC0,0xA8,0xA8,0xA8,0x30,0x20,0x20, //205/ --> ح
      0x00,0xC0,0xA8,0xAA,0x28,0x30,0x20,0x20, //206/ --> خ
      0x00,0x00,0x24,0x24,0x24,0x38,0x00,0x00, //207/ --> د
      0x00,0x00,0x24,0x25,0x24,0x38,0x00,0x00, //208/ --> ذ
      0x00,0x80,0x80,0x40,0x30,0x00,0x00,0x00, //209/ --> ر
      0x00,0x00,0x80,0x80,0x40,0x34,0x00,0x00, //210/ --> ز
      0x60,0x80,0x80,0x78,0x20,0x38,0x20,0x18, //211/ --> س
      0x60,0x80,0x80,0x78,0x22,0x39,0x22,0x18, //212/ --> ش
      0x60,0x80,0x80,0x60,0x30,0x28,0x28,0x18, //213/ --> ص
      0x60,0x80,0x80,0x60,0x30,0x28,0x2A,0x18, //214/ --> ض
      0x00,0x22,0x14,0x08,0x14,0x22,0x00,0x00, //215/ --> ×
      0x20,0x20,0x3E,0x30,0x28,0x28,0x18,0x00, //216/ --> ط
      0x20,0x20,0x3E,0x30,0x28,0x2A,0x18,0x00, //217/ --> ظ
      0x00,0x00,0x40,0xA0,0xB0,0x28,0x28,0x00, //218/ --> ع
      0x00,0x00,0x40,0xA0,0xB0,0x2A,0x28,0x00, //219/ --> غ
      0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //220/ --> ـ
      0x00,0x18,0x20,0x20,0x30,0x28,0x2A,0x30, //221/ --> ف
      0x00,0x60,0x80,0x80,0xB2,0xA8,0x7A,0x00, //222/ --> ق
      0x00,0x30,0x28,0x2C,0x2A,0x20,0x3F,0x00, //223/ --> ک
      0x00,0x40,0xA9,0xAA,0xA8,0xF0,0x00,0x00, //224/ --> à
      0x00,0x00,0x60,0x80,0x80,0x7E,0x00,0x00, //225/ --> ل
      0x00,0x40,0xAA,0xA9,0xAA,0xF0,0x00,0x00, //226/ --> â
      0x00,0x00,0xC0,0x20,0x30,0x28,0x28,0x30, //227/ --> م
      0x00,0x00,0x60,0x80,0x88,0x80,0x60,0x00, //228/ --> ن
      0x00,0x00,0x30,0x28,0x28,0x30,0x00,0x00, //229/ --> ه
      0x00,0x00,0x00,0xB0,0xA8,0x78,0x00,0x00, //230/ --> و
      0x04,0x26,0x25,0x25,0x28,0x10,0x0F,0x00, //231/ --> ç
      0x04,0x22,0x22,0x26,0x29,0x10,0x0F,0x00, //232/ --> è
      0x00,0x21,0x22,0x24,0xA8,0xD0,0xAF,0xA0, //233/ --> é
      0x00,0x70,0xAA,0xA9,0xAA,0x30,0x00,0x00, //234/ --> ê
      0x00,0x70,0xAA,0xA8,0xAA,0x30,0x00,0x00, //235/ --> ë
      0x00,0x30,0x40,0x40,0x50,0x28,0x08,0x00, //236/ --> ى
      0x00,0x30,0xC0,0x40,0xD0,0x28,0x08,0x00, //237/ --> ی
      0x00,0x00,0x02,0x79,0x02,0x00,0x00,0x00, //238/ --> î
      0x00,0x00,0x02,0x78,0x02,0x00,0x00,0x00, //239/ --> ï
      0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05, //240/ --> ً
      0x00,0x00,0x00,0x04,0x03,0x0B,0x06,0x06, //241/ --> ٌ
      0xA0,0xA0,0xA0,0x00,0x00,0x00,0x00,0x00, //242/ --> ٍ
      0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00, //243/ --> َ
      0x00,0x21,0x22,0x24,0x28,0x10,0x2F,0x20, //244/ --> ô
      0x00,0x00,0x00,0x00,0x00,0x04,0x03,0x03, //245/ --> ُ
      0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00, //246/ --> ِ
      0x00,0x00,0x10,0x10,0x54,0x10,0x10,0x00, //247/ --> ÷
      0x00,0x00,0x02,0x04,0x02,0x04,0x02,0x00, //248/ --> ّ
      0x20,0x24,0x26,0x25,0x25,0x20,0x28,0x30, //249/ --> ù
      0x20,0x24,0x26,0x25,0x35,0x20,0x20,0x20, //250/ --> ْ
      0x08,0x6C,0x8A,0x8A,0xA0,0x50,0x10,0x20, //251/ --> û
      0x04,0xB6,0xAD,0x7D,0x24,0x20,0x20,0x20, //252/ --> ü
      0x00,0x19,0x14,0x15,0x18,0x20,0x20,0x20, //253/ --> ‎
      0x04,0x02,0x02,0x1A,0x22,0x22,0x21,0x20, //254/ --> ‏
      0x00,0x40,0x60,0x50,0x48,0x50,0x40,0x40 //255/ --> ے
      };


      flash unsigned char map[62][6] = {
      {193,193,193,193,0,0},
      {194,194,254,254,1,0},
      {195,195,31,31,1,0},
      {196,196,252,252,1,0},
      {197,197,197,197,1,1},
      {198,189,191,190,1,1},
      {199,199,192,192,1,0},
      {200,130,132,131,1,1},
      {201,201,253,253,1,0},
      {202,133,135,134,1,1},
      {203,136,138,137,1,1},
      {204,139,204,139,1,1},
      {205,140,205,140,1,1},
      {206,17,206,17,1,1},
      {207,207,19,19,1,0},
      {208,208,143,143,1,0},
      {209,209,27,27,1,0},
      {210,210,145,145,1,0},
      {211,146,148,147,1,1},
      {212,149,151,150,1,1},
      {213,23,154,153,1,1},
      {214,155,157,156,1,1},
      {215,215,215,215,0,0},
      {216,216,158,158,1,1},
      {217,217,159,159,1,1},
      {218,160,162,161,1,1},
      {219,163,165,164,1,1},
      {220,220,220,220,0,0},
      {221,166,168,167,1,1},
      {222,169,171,170,1,1},
      {223,172,174,173,1,1},
      {224,224,224,224,0,0},
      {225,175,177,176,1,1},
      {226,226,226,226,0,0},
      {227,178,180,179,1,1},
      {228,181,183,182,1,1},
      {229,184,186,185,1,1},
      {230,230,188,188,1,0},
      {231,231,231,231,0,0},
      {232,232,232,232,0,0},
      {233,233,233,233,0,0},
      {234,234,234,234,0,0},
      {235,235,235,235,0,0},
      {236,189,191,190,1,1},
      {237,189,191,190,1,1},
      {238,238,238,238,0,0},
      {239,239,239,239,0,0},
      {240,240,240,240,0,0},
      {241,241,241,241,0,0},
      {242,242,242,242,0,0},
      {243,243,243,243,0,0},
      {245,245,245,245,0,0},
      {246,246,246,246,0,0},
      {247,247,247,247,0,0},
      {248,248,248,248,0,0},
      {251,249,251,250,1,1},
      {187,187,244,244,1,0},
      {129,28,30,29,1,1},
      {144,24,26,25,1,1},
      {152,20,22,21,1,1},
      {142,142,18,18,1,0},
      {141,16,141,16,1,1}
      };




      به جای flash unsigned char font []={.....} عبارت زیر رو قرار دهیم:
      const[COLOR=#475063][FONT=Consolas] [/FONT][/COLOR]unsigned char[COLOR=#475063][FONT=Consolas] [/FONT][/COLOR]PROGMEM font = {...};[FONT=Yekan][/FONT]

      باز هم سپاس گذارم.
      جدیدترین ویرایش توسط saati.sms; ۰۸:۵۶ ۱۳۹۸/۰۱/۰۵.

      دیدگاه


        #4
        پاسخ : کمک فوری (تبدیل کتابخانه codevision به atmel studio)

        نوع تعریف آرایه ای که گفتید درسته. برای دسترسی به متغیر هم باید آدرس اش رو بدید به PGM_READ_BYTE تا مقدارش بر گردونده بشه. فرض کنید مقدار خونه شماره 10 آرایه ای مثل A که روی فلش ذخیره شده باشه بخواهیم بریزیم روی متغیر B که یک متغیر عادیه؛ به این شکل عمل میکنیم:
        B = PGM_READ_BYTE(&A[10]);

        فقط اگر قصد تبدیل کتابخونه دارید، باید توجه داشته باشید که همه مواردی که گفتم درست رعایت شده باشه تا کتابخونه درست عمل کنه.
        البته من خودم به شکل زیر نوشتم قبلا. نمیدونم شاید بالاییه عمل نکنه:
        B = PGM_READ_BYTE(&A[0]+10);
        جدیدترین ویرایش توسط hossein.m98; ۱۱:۵۵ ۱۳۹۸/۰۱/۰۵.

        دیدگاه


          #5
          پاسخ : کمک فوری (تبدیل کتابخانه codevision به atmel studio)

          نوشته اصلی توسط hossein.m98 نمایش پست ها
          نوع تعریف آرایه ای که گفتید درسته. برای دسترسی به متغیر هم باید آدرس اش رو بدید به PGM_READ_BYTE تا مقدارش بر گردونده بشه. فرض کنید مقدار خونه شماره 10 آرایه ای مثل A که روی فلش ذخیره شده باشه بخواهیم بریزیم روی متغیر B که یک متغیر عادیه؛ به این شکل عمل میکنیم:
          B = PGM_READ_BYTE(&A[10]);

          فقط اگر قصد تبدیل کتابخونه دارید، باید توجه داشته باشید که همه مواردی که گفتم درست رعایت شده باشه تا کتابخونه درست عمل کنه.
          البته من خودم به شکل زیر نوشتم قبلا. نمیدونم شاید بالاییه عمل نکنه:
          B = PGM_READ_BYTE(&A[0]+10);
          باز هم ممنون از شما.
          ببخشید اگر مرجع مناسبی میدونید برای نوشتن کتابخانه به ویژه برای atmel studio (برای کد ویژن هم مشکلی نیست) ( و ترجیحا با مفاهیم پایه های) راهنمایی نمایید.
          سپاس فراوان.

          دیدگاه


            #6
            پاسخ : کمک فوری (تبدیل کتابخانه codevision به atmel studio)

            نوشته اصلی توسط saati.sms نمایش پست ها
            باز هم ممنون از شما.
            ببخشید اگر مرجع مناسبی میدونید برای نوشتن کتابخانه به ویژه برای atmel studio (برای کد ویژن هم مشکلی نیست) ( و ترجیحا با مفاهیم پایه های) راهنمایی نمایید.
            سپاس فراوان.
            منبع به اون شکل که نه ولی این لینک به نظر مطالبی در همین مورد داره.

            دیدگاه


              #7
              پاسخ : کمک فوری (تبدیل کتابخانه codevision به atmel studio)

              نوشته اصلی توسط saati.sms نمایش پست ها
              باز هم ممنون از شما.
              ببخشید اگر مرجع مناسبی میدونید برای نوشتن کتابخانه به ویژه برای atmel studio (برای کد ویژن هم مشکلی نیست) ( و ترجیحا با مفاهیم پایه های) راهنمایی نمایید.
              سپاس فراوان.
              این تاپیک هم خوبه
              با سلام درپی درخواست دوستان این تاپیک رو ایجاد کردم تا کسانی که با کدویژن کار میکنند و دوست دارند بتوانند تو محیط AtmelStudio کارکنند و از امکاناتش بهره ببرند، این کار براشون راحت باشه. قبل از هرچیز جا داره یک توضیحاتی در رابطه با Atmel Studio بدم: Atmel Studio یک محیط برنامه نویسی( IDE ) مختص برنامه نویسی برای

              دیدگاه


                #8
                پاسخ : کمک فوری (تبدیل کتابخانه codevision به atmel studio)

                در نسخه های بالای avr-gcc که در AtmelStudio هم از آن استفاده می شود، برای دسترسی به حافظه flash در َAVR لزوما نیازی به استفاده از PROGMEM و pgm_read_byte نیست و می توانید بدون نیاز به include کردن pgmspace.h از const __flash استفاده کنید.
                اوژن: به معنای افکننده و شکست دهنده است
                دانایی، توانایی است-Knowledge is POWER
                برای حرفه ای شدن در الکترونیک باید با آن زندگی کرد
                وضعمان بهتر می شود، اگر همه نسبت به جامعه و اطراف خود مسوول باشیم و نگوئیم به ما چه
                قوی شدن و خوب ماندن - خوبی کردن به دیگران یک لذت ماندگار است
                اگر قرار باشد نفت و منابع خام را بدهیم و چرخ بگیریم، بهتر است چرخ را از نو اختراع کنیم
                ساعت کار بدن اکثر انسان ها کمتر از 800000 ساعت است و بعد از آن از کار می افتد

                دیدگاه

                لطفا صبر کنید...
                X