ايران ويج

نسخه‌ی کامل: نمایش عکس روی lcd 6610 nokia
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
صفحه‌ها: 1 2 3
سلام
مهندسین من این lcd راه انداختم و نوشته و غیرورو روش نمایش دادادم .زیادم سخت نبود
حالا یه مشکل دارم من تصویر آماده که با فرمت bgc هستو نشون میدم کامل ولی تصاویری که با lcdconverter bascam با همین فرمتو مسازمو درست نمایش نمیده و یه چیز در هم میاره هم جوره تست کردم نشد ؟>!!!
کسی این کارو کرده ؟ جواب داده ؟ چجوری آ[]؟Sad
مرسیHappyClapShyHeart
اقا این مشکل حل شد مشکل تو نرم افزار تبدیل بود .!!!
حالا یه مشکل جدید دارم اونم فونت برای این lcd فونت 16*16 هست تو بیکام ولی برای کاری که میخوام کوچیکه چه جوری میشه بزرگش کرد مثلا 32*32 ؟ کسی فونت بزرگترشو داره ؟
سلام آقاي maxn@morteza ميشه بگي من چطوري ميتونم اين ال سي دي رو تو پروتئوس شبيه سازي كنم دستت درد نكنه
(۰۹-مهر-۱۳۹۰, ۲۲:۴۵:۰۵)do...loop نوشته است: [ -> ]سلام آقاي maxn@morteza ميشه بگي من چطوري ميتونم اين ال سي دي رو تو پروتئوس شبيه سازي كنم دستت درد نكنه

سلام دوست عزیز از فایل پیوست استفاده کن
دوباره سلام
لطفا يه سورس بيسكام بديد تا بدونم كي به كيه...
اينا فقط فايل هگز توشه و به درد من نميخوره.
ميكرويي كه استفاده شده ترجيحا avr و مگا 32 باشه.
خيلي ممنون
كسي ميدونه تو بسكام چرا براي دستور فونت ارور ميده
$include "font8x8.font"

این یک سورس کامل در مورد کار با 6610
کد:
/*****************************************************************
*  www.bargh20.com                        *
*  www.bargh20.com                     *
*  www.bargh20.com                                          *
*  www.bargh20.com  
*  www.bargh20.com              *
*****************************************************************/


// Epson S1D15G00 entegreli ekranlarý sürmek için aþaðýdaki fonksiyonlarda deðiþiklik yapmak gerekmektedir.
//        LCDDriverInitialize()
//        LCDSelectColorMode()
//        LCDSetContrast()
//        Glcd_komut_yaz()
//        Glcd_veri_yaz()


// ------------------------------------------------------------------------------
//
//
// The LCD controller can be configured for different coordinate systems.  I choose
// to mount the display with the connector tab on the top, and I setup the coordinate
// system with 0,0 in the upper left corner.  X moves down and Y moves to the right.
// With this display, the X=0 and X=131 columns, along with the Y=0 and Y = 131 rows
// are not visible and are not used.  
//
//
//                     ----------- Y ----------->
//                                        ___
//                    _ _ _ _ _ _ _ _ _ _|_ _|_ _
//                   |                           |
//             (0,0) |---------------------------| (131,0)
//        |          |                           |
//        |          |                           |
//        |          |                           |
//        |          |                           |
//        |          |    Nokia 6100 display     |
//        X          |                           |
//        |          |                           |
//        |          |                           |
//        |          |                           |
//        |          |                           |
//       \|/         |                           |
//           (0,131)  ---------------------------  (131,131)
//
//
// The auto increment and wrap feature of the RAMWR command is configured
// to write bytes in the Y direction, going from top to bottom, then wrapping  
// left to right. As a result, bitmap data should be stored in arrays with the  
// first byte representing the pixel in the upper left corner, then advancing
// downward and to the right.
//

/* ------------------------------------------------------------------------ */


#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "LCDDriver.h"


/* ------------------------------------------------------------------------ */


//
// command set for the Philips PCF8833 LCD controller
//
#define NOOP     0x00         // nop
#define SWRESET 0x01         // software reset
#define BSTROFF 0x02         // booster voltage OFF
#define BSTRON     0x03         // booster voltage ON
#define RDDIDIF 0x04         // read display identification
#define RDDST     0x09         // read display status
#define SLEEPIN 0x10         // sleep in
#define SLEEPOUT 0x11         // sleep out
#define PTLON     0x12         // partial display mode
#define NORON     0x13         // display normal mode
#define INVOFF     0x20         // inversion OFF
#define INVON     0x21         // inversion ON
#define DALO     0x22         // all pixel OFF
#define DAL     0x23         // all pixel ON
#define SETCON     0x25         // write contrast
#define DISPOFF 0x28         // display OFF
#define DISPON     0x29         // display ON
#define CASET     0x2A         // column address set
#define PASET     0x2B         // page address set
#define RAMWR     0x2C         // memory write
#define RGBSET     0x2D         // colour set
#define PTLAR     0x30         // partial area
#define VSCRDEF 0x33         // vertical scrolling definition
#define TEOFF     0x34         // test mode
#define TEON     0x35        // test mode
#define MADCTL     0x36         // memory access control
#define SEP     0x37         // vertical scrolling start address
#define IDMOFF     0x38         // idle mode OFF
#define IDMON     0x39         // idle mode ON
#define COLMOD     0x3A         // interface pixel format
#define SETVOP     0xB0         // set Vop
#define BRS     0xB4         // bottom row swap
#define TRS     0xB6         // top row swap
#define DISCTR     0xB9         // display control
#define DATOR     0xBA         // data order
#define TCDFE     0xBD         // enable/disable DF temperature compensation
#define TCVOPE     0xBF         // enable/disable Vop temp comp
#define EC         0xC0         // internal or external oscillator
#define SETMUL     0xC2         // set multiplication factor
#define TCVOPAB 0xC3         // set TCVOP slopes A and B
#define TCVOPCD 0xC4         // set TCVOP slopes c and d
#define TCDF     0xC5         // set divider frequency
#define DF8COLOR 0xC6         // set divider frequency 8-color mode
#define SETBS     0xC7         // set bias system
#define RDTEMP     0xC8         // temperature read back
#define NLI     0xC9         // n-line inversion
#define RDID1     0xDA         // read ID1
#define RDID2     0xDB         // read ID2
#define RDID3     0xDC         // read ID3


const prog_uint8_t Font5x7[] = {
    0x00, 0x00, 0x00, 0x00, 0x00,// (space)
    0x00, 0x00, 0x5F, 0x00, 0x00,// !
    0x00, 0x07, 0x00, 0x07, 0x00,// "
    0x14, 0x7F, 0x14, 0x7F, 0x14,// #
    0x24, 0x2A, 0x7F, 0x2A, 0x12,// $
    0x23, 0x13, 0x08, 0x64, 0x62,// %
    0x36, 0x49, 0x55, 0x22, 0x50,// &
    0x00, 0x05, 0x03, 0x00, 0x00,// '
    0x00, 0x1C, 0x22, 0x41, 0x00,// (
    0x00, 0x41, 0x22, 0x1C, 0x00,// )
    0x08, 0x2A, 0x1C, 0x2A, 0x08,// *
    0x08, 0x08, 0x3E, 0x08, 0x08,// +
    0x00, 0x50, 0x30, 0x00, 0x00,// ,
    0x08, 0x08, 0x08, 0x08, 0x08,// -
    0x00, 0x60, 0x60, 0x00, 0x00,// .
    0x20, 0x10, 0x08, 0x04, 0x02,// /
    0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
    0x00, 0x42, 0x7F, 0x40, 0x00,// 1
    0x42, 0x61, 0x51, 0x49, 0x46,// 2
    0x21, 0x41, 0x45, 0x4B, 0x31,// 3
    0x18, 0x14, 0x12, 0x7F, 0x10,// 4
    0x27, 0x45, 0x45, 0x45, 0x39,// 5
    0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
    0x01, 0x71, 0x09, 0x05, 0x03,// 7
    0x36, 0x49, 0x49, 0x49, 0x36,// 8
    0x06, 0x49, 0x49, 0x29, 0x1E,// 9
    0x00, 0x36, 0x36, 0x00, 0x00,// :
    0x00, 0x56, 0x36, 0x00, 0x00,// ;
    0x00, 0x08, 0x14, 0x22, 0x41,// <
    0x14, 0x14, 0x14, 0x14, 0x14,// =
    0x41, 0x22, 0x14, 0x08, 0x00,// >
    0x02, 0x01, 0x51, 0x09, 0x06,// ?
    0x32, 0x49, 0x79, 0x41, 0x3E,// @
    0x7E, 0x11, 0x11, 0x11, 0x7E,// A
    0x7F, 0x49, 0x49, 0x49, 0x36,// B
    0x3E, 0x41, 0x41, 0x41, 0x22,// C
    0x7F, 0x41, 0x41, 0x22, 0x1C,// D
    0x7F, 0x49, 0x49, 0x49, 0x41,// E
    0x7F, 0x09, 0x09, 0x01, 0x01,// F
    0x3E, 0x41, 0x41, 0x51, 0x32,// G
    0x7F, 0x08, 0x08, 0x08, 0x7F,// H
    0x00, 0x41, 0x7F, 0x41, 0x00,// I
    0x20, 0x40, 0x41, 0x3F, 0x01,// J
    0x7F, 0x08, 0x14, 0x22, 0x41,// K
    0x7F, 0x40, 0x40, 0x40, 0x40,// L
    0x7F, 0x02, 0x04, 0x02, 0x7F,// M
    0x7F, 0x04, 0x08, 0x10, 0x7F,// N
    0x3E, 0x41, 0x41, 0x41, 0x3E,// O
    0x7F, 0x09, 0x09, 0x09, 0x06,// P
    0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
    0x7F, 0x09, 0x19, 0x29, 0x46,// R
    0x46, 0x49, 0x49, 0x49, 0x31,// S
    0x01, 0x01, 0x7F, 0x01, 0x01,// T
    0x3F, 0x40, 0x40, 0x40, 0x3F,// U
    0x1F, 0x20, 0x40, 0x20, 0x1F,// V
    0x7F, 0x20, 0x18, 0x20, 0x7F,// W
    0x63, 0x14, 0x08, 0x14, 0x63,// X
    0x03, 0x04, 0x78, 0x04, 0x03,// Y
    0x61, 0x51, 0x49, 0x45, 0x43,// Z
    0x00, 0x00, 0x7F, 0x41, 0x41,// [
    0x02, 0x04, 0x08, 0x10, 0x20,// "\"
    0x41, 0x41, 0x7F, 0x00, 0x00,// ]
    0x04, 0x02, 0x01, 0x02, 0x04,// ^
    0x40, 0x40, 0x40, 0x40, 0x40,// _
    0x00, 0x01, 0x02, 0x04, 0x00,// `
    0x20, 0x54, 0x54, 0x54, 0x78,// a
    0x7F, 0x48, 0x44, 0x44, 0x38,// b
    0x38, 0x44, 0x44, 0x44, 0x20,// c
    0x38, 0x44, 0x44, 0x48, 0x7F,// d
    0x38, 0x54, 0x54, 0x54, 0x18,// e
    0x08, 0x7E, 0x09, 0x01, 0x02,// f
    0x08, 0x14, 0x54, 0x54, 0x3C,// g
    0x7F, 0x08, 0x04, 0x04, 0x78,// h
    0x00, 0x44, 0x7D, 0x40, 0x00,// i
    0x20, 0x40, 0x44, 0x3D, 0x00,// j
    0x00, 0x7F, 0x10, 0x28, 0x44,// k
    0x00, 0x41, 0x7F, 0x40, 0x00,// l
    0x7C, 0x04, 0x18, 0x04, 0x78,// m
    0x7C, 0x08, 0x04, 0x04, 0x78,// n
    0x38, 0x44, 0x44, 0x44, 0x38,// o
    0x7C, 0x14, 0x14, 0x14, 0x08,// p
    0x08, 0x14, 0x14, 0x18, 0x7C,// q
    0x7C, 0x08, 0x04, 0x04, 0x08,// r
    0x48, 0x54, 0x54, 0x54, 0x20,// s
    0x04, 0x3F, 0x44, 0x40, 0x20,// t
    0x3C, 0x40, 0x40, 0x20, 0x7C,// u
    0x1C, 0x20, 0x40, 0x20, 0x1C,// v
    0x3C, 0x40, 0x30, 0x40, 0x3C,// w
    0x44, 0x28, 0x10, 0x28, 0x44,// x
    0x0C, 0x50, 0x50, 0x50, 0x3C,// y
    0x44, 0x64, 0x54, 0x4C, 0x44,// z
    0x00, 0x08, 0x36, 0x41, 0x00,// {
    0x00, 0x00, 0x7F, 0x00, 0x00,// |
    0x00, 0x41, 0x36, 0x08, 0x00,// }
    0x08, 0x08, 0x2A, 0x1C, 0x08,// ->
    0x08, 0x1C, 0x2A, 0x08, 0x08 // <-
};


/* ------------------------------------------------------------------------ */


//
// color map for RGB12 (rrrrggggbbbb)
//
static  char RGB12ColorMap[] = {
    // number of bytes in the table excluding this one
    48,
    
    // red map: an input 4 bit rrrr color is mapped to an output 5 bit rrrrr color
    0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,0x10,0x12,0x14,0x16,0x18,0x1A,0x1C,0x1F,
    
    // green map: an input 4 bit gggg color is mapped to an output 6 bit gggggg color
    0x00,0x07,0x0B,0x0F,0x13,0x17,0x1B,0x1F,0x23,0x27,0x2B,0x2F,0x33,0x37,0x3B,0x3F,
    
    // blue map: an input 4 bit bbbb color is mapped to an output 5 bit bbbbb color
    0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,0x10,0x12,0x14,0x16,0x18,0x1A,0x1C,0x1F};



//
// color map for RGB8 (rrrgggbb).  This color table does not follow the requirements
// detailed in the Philips datasheet, but does work correctly with the displays used
// to develop this software.  I'm not sure why.
//
static  char RGB8ColorMap[] = {
    // number of bytes in the table excluding this one
    48,

    // red map: an input 3 bit rrr color is mapped to an output 5 bit rrrrr color
    0, 4, 9, 13, 18, 22, 27, 31, 0, 0, 0, 0, 0, 0, 0, 0,
    
    // green map: an input 3 bit ggg color is mapped to an output 6 bit gggggg color
    0, 9, 18, 27, 36, 45, 54, 63, 0, 0, 0, 0, 0, 0, 0, 0,
    
    // blue map: an input 2 bit bb color is mapped to an output 5 bit bbbbb color
    0, 10, 21, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};



//
// color map for RGB8 (rrrgggbb). This color table has not been tested.  It is
// here because it matches the required as documented in the Philips datasheet.
//
//static rom byte RGB8ColorMap[] = {
//    // number of bytes in the table excluding this one
//    20,
//
//    // red map: an input 3 bit rrr color is mapped to an output 4 bit rrrr color
//    0, 2, 5, 7, 9, 11, 14, 15,
//    
//    // green map: an input 3 bit ggg color is mapped to an output 4 bit gggg color
//    0, 2, 4, 6, 9, 11, 14, 15,
//    
//    // blue map: an input 2 bit bb color is mapped to an output 4 bit bbbb color
//    0, 6, 11, 15};



/* ------------------------------------------------------------------------ */
/*                     Private variables local to this module                    */
/* ------------------------------------------------------------------------ */

static char CurrentColorMode;
static char *CurrentColorMap;


/* ------------------------------------------------------------------------ */
/*                          Local function declarations                           */
/* ------------------------------------------------------------------------ */

static void spi_init(void);
static void spi_byte_gonder (char);
static void Glcd_komut_yaz(char);
static void WriteRomDataToLCD( char *, unsigned int);
static void Glcd_veri_yaz(char);
static void DeselectLCD(void);


/* ------------------------------------------------------------------------ */
/*                              Public general functions                          */
/* ------------------------------------------------------------------------ */

//
// initialize this module and the LCD controller
//        Enter:    ColorMode = LCD_COLOR_MODE_RGB8 or LCD_COLOR_MODE_RGB8
//
void LCDDriverInitialize(char ColorMode)
{    //
    // initialize state variables
    //
    CurrentColorMode = LCD_COLOR_MODE_UNDEFINED;
    CurrentColorMap = 0;
    
    
    //
    // initialize the SPI registers that communicate with the LCD display
    //
    spi_init();
    //
    // hardware reset the LCD display
    //
    GLCD_RESET_PORT&=~_BV(LCD_RESET);
    _delay_ms(30);
    GLCD_RESET_PORT|=_BV(LCD_RESET);
    _delay_ms(30);


    //
    // take the controller out of sleep (start the power booster)
    //
    //SPIData = SLEEPOUT;
    Glcd_komut_yaz(SLEEPOUT);
    _delay_ms(2);

    
    //
    // don't mirror x & y, write in Y dir, color = RGB
    // Note: The V bit is set so that writes to RAM increment in the Y direction, going
    // from top to bottom, then left to right.  I picked the Y direction to be compatible
    // with the variable pitch font.  Setting this bit also required switching PASET and
    // CASET
    //
    //SPIData = MADCTL;
    Glcd_komut_yaz(MADCTL);
    //SPIData = 0x20;            
    Glcd_veri_yaz(0x20);

    //
    // initialize the contrast
    //
    Glcd_komut_yaz(SETCON);
    Glcd_veri_yaz(0x30);
    DeselectLCD();

    //
    // turn on the display
    //
    _delay_ms(4);
    Glcd_komut_yaz(DISPON);        

    //
    // set the default color mode (RGB8 or RGB12) and the color map
    //
    LCDSelectColorMode(ColorMode, 0);
    DeselectLCD();
}

//
// select color mode, either RGB8 or RGB12
//        Enter:    ColorMode = LCD_COLOR_MODE_RGB8 or LCD_COLOR_MODE_RGB8
//                ColorMap -> color map table, if 0 then use default table
//
void LCDSelectColorMode(char ColorMode,  char *ColorMap)
{     char *ColorMapTable;
    
    //
    // check if the display is already in the current mode
    //
    if ((CurrentColorMode == ColorMode) && (CurrentColorMap == ColorMap))
        return;
    // set the color mode
    Glcd_komut_yaz(COLMOD);
    
    if (ColorMode == LCD_COLOR_MODE_RGB8)
    {
        Glcd_veri_yaz(2);
        ColorMapTable = RGB8ColorMap;
    }
    else
    {    
        Glcd_veri_yaz(3);
        ColorMapTable = RGB12ColorMap;
    }

    // check if the default table should not be used
    if (ColorMap != 0)
        ColorMapTable = ColorMap;
    // load the color table
    Glcd_komut_yaz(RGBSET);
    WriteRomDataToLCD(ColorMapTable + 1, ColorMapTable[0]);
    Glcd_komut_yaz(NOOP);
    CurrentColorMode = ColorMode;
    CurrentColorMap = ColorMap;
    DeselectLCD();
}

//
// Ekranýn tamamýný beyaza boyar.
//
void Glcd_temizle(void)
{    if (CurrentColorMode == LCD_COLOR_MODE_RGB8)
        ici_dolu_dortgen_ciz_RGB8(0, 0, LCD_WIDTH - 1, LCD_HEIGHT - 1, RGB8_WHITE);
    
    else
        ici_dolu_dortgen_ciz_RGB212(0, 0, LCD_WIDTH - 1, LCD_HEIGHT - 1, RGB12_WHITE);
}

//
// Ekranýný kontrast seviyesinhi ayarlar
//        Enter:    Value = Kontrast deðeri (-64 to 63)
//
void Kontrast_ayarla(char Value)
{    
    Glcd_komut_yaz(SETCON);
    Glcd_veri_yaz((char) Value);
    DeselectLCD();
}

/* ------------------------------------------------------------------------ */
/*                                    RGB8 Fonksiyonlar                             */
/* ------------------------------------------------------------------------ */

//
// ekranda 8 bit renge sahip bir piksel görüntülenir.
//        Enter:    X = x koordinatý (1 - 130)
//                Y = y koordinatý (1 - 130)
//                Color = piksel rengi (rrrgggbb)
//
void Pixel_yaz_RGB8(char X, char Y, char ColorRGB8)
{    //
    // set the coords of a box including just this one pixel
    //
    Glcd_komut_yaz(PASET);
    Glcd_veri_yaz(X);
    Glcd_veri_yaz(X);
    
    Glcd_komut_yaz(CASET);
    Glcd_veri_yaz(Y);
    Glcd_veri_yaz(Y);
    
    // set the color of the pixel
    Glcd_komut_yaz(RAMWR);
    Glcd_veri_yaz(ColorRGB8);
    
    DeselectLCD();
}

//
//         8 bit renk ile içi dolu dörtgen çizen fonksiyon
//        Giriþ:    Left = sol x Koordinatý (1 - 130)
//                Top = tepe y Koordinatý (1 - 130)
//                Right = Sað x Koordinatý (1 - 130)
//                Bottom = Taban y Koordinatý (1 - 130)
//                ColorRGB8 = pixel rengi (rrrgggbb)
//
void ici_dolu_dortgen_ciz_RGB8(char Left, char Top, char Right, char Bottom, char ColorRGB8)
{    int i,PixelCount;
    // Dörtgenin çizilebilirliðini doðrula
    if ((Left > Right) || (Top > Bottom))
        return;
    // Dörtgenini koordinatlarýný gir
    Glcd_komut_yaz(PASET);
    Glcd_veri_yaz(Left);
    Glcd_veri_yaz(Right);
    Glcd_komut_yaz(CASET);
    Glcd_veri_yaz(Top);
    Glcd_veri_yaz(Bottom);
    // Dörtgenini içini boya
    Glcd_komut_yaz(RAMWR);
    PixelCount = (unsigned int) (Right - Left + 1) * (unsigned int) (Bottom - Top + 1);
    for (i = 0; i < PixelCount; i++)
    Glcd_veri_yaz(ColorRGB8);
    Glcd_komut_yaz(NOOP);
    DeselectLCD();
}

//
// draw a horizontal gradient
//        Enter:    ColorTable -> to a table in RAM of RGB8 colors
//                LeftX = left side of horizontal gradient to draw
//                RightX = right side of horizontal gradient to draw
//                TopY = Y coord of top line of horizontal gradient to draw, will draw down from there
//                LineCount = number of lines to draw
//
void DrawHorzGradientRGB8( char *ColorTable, char LeftX, char RightX, char TopY, char LineCount)
{    //char i;
    
    while(LineCount)
    {    ici_dolu_dortgen_ciz_RGB8(
          LeftX, TopY,
          RightX, TopY,
          *ColorTable);

        LineCount--;
        TopY++;
        ColorTable++;
    }
}

//
//     8 bit renk kullanarak çizgi çizme algoritmasý by Jack Bresenham
//        Giriþ:    X1, Y1 = Baþlangýç
//                X2, Y2 = Bitiþ
//                ColorRGB8 = pixel rengi (rrrgggbb)
//
void cizgi_ciz_RGB8(int X1, int Y1, int X2, int Y2, char ColorRGB8)
{    int dy;
    int dx;
    int StepX, StepY;
    int Fraction;
    
    dy = Y2 - Y1;
    dx = X2 - X1;

    if (dy < 0)
    {    dy = -dy;
        StepY = -1;
    }
    else
        StepY = 1;
        
    if (dx < 0)
    {    dx = -dx;
        StepX = -1;
    }
    else
        StepX = 1;

    dy <<= 1;                                     // dy is now 2*dy
    dx <<= 1;                                     // dx is now 2*dx
    Pixel_yaz_RGB8(X1, Y1, ColorRGB8);

    if (dx > dy)
    {    Fraction = dy - (dx >> 1);                 // same as 2*dy - dx
        while (X1 != X2)
        {    if (Fraction >= 0)
            {    Y1 += StepY;
                Fraction -= dx;                 // same as fraction -= 2*dx
            }

            X1 += StepX;
            Fraction += dy;                     // same as fraction -= 2*dy
            Pixel_yaz_RGB8(X1, Y1, ColorRGB8);
        }
    }
    
    else
    {    Fraction = dx - (dy >> 1);
        while (Y1 != Y2)
        {    if (Fraction >= 0)
            {    X1 += StepX;
                Fraction -= dy;
            }

            Y1 += StepY;
            Fraction += dx;
            Pixel_yaz_RGB8(X1, Y1, ColorRGB8);
        }
    }
}



//
// 8 bit renk kullanarak içi boþ çember çizme algoritmasý by Jack Bresenham
//        Giriþ:    X1, Y1 = Çemberin merkezi
//                radius = Çember yarý çapý
//                ColorRGB8 = pixel rengi (rrrgggbb)
//
void ici_bos_cember_ciz_RGB8(int X1, int Y1, int Radius, char ColorRGB8)
{    int f;
    int ddF_x;
    int ddF_y;
    int x;
    int y;
    
    f = 1 - Radius;
    ddF_x = 0;
    ddF_y = -2 * Radius;
    x = 0;
    y = Radius;

    Pixel_yaz_RGB8(X1, Y1 + Radius, ColorRGB8);
    Pixel_yaz_RGB8(X1, Y1 - Radius, ColorRGB8);
    Pixel_yaz_RGB8(X1 + Radius, Y1, ColorRGB8);
    Pixel_yaz_RGB8(X1 - Radius, Y1, ColorRGB8);

    while (x < y)
    {    if (f >= 0)
        {    y--;
            ddF_y += 2;
            f += ddF_y;
        }

        x++;
        ddF_x += 2;
        f += ddF_x + 1;
        
        Pixel_yaz_RGB8(X1 + x, Y1 + y, ColorRGB8);
        Pixel_yaz_RGB8(X1 - x, Y1 + y, ColorRGB8);
        Pixel_yaz_RGB8(X1 + x, Y1 - y, ColorRGB8);
        Pixel_yaz_RGB8(X1 - x, Y1 - y, ColorRGB8);
        Pixel_yaz_RGB8(X1 + y, Y1 + x, ColorRGB8);
        Pixel_yaz_RGB8(X1 - y, Y1 + x, ColorRGB8);
        Pixel_yaz_RGB8(X1 + y, Y1 - x, ColorRGB8);
        Pixel_yaz_RGB8(X1 - y, Y1 - x, ColorRGB8);
    }
}

//
// 8 bit renkli bmp resmi çizer
//        Giriþ:    Bitmap -> RGB8 resim datalarý
//                X, Y = resim yerleþtirme koordinatý (sol üst köþesi)
//
void resim_ciz_RGB8( char *Bitmap, char X, char Y)
{    char Width;
    char Height;
    int ByteCount;
    
    Width = Bitmap[1];
    Height = Bitmap[2];
    ByteCount = Bitmap[3] + ((int)Bitmap[4] << 8);
    
    Glcd_komut_yaz(PASET);
    Glcd_veri_yaz(X);
    Glcd_veri_yaz(X + Width - 1);
    
    Glcd_komut_yaz(CASET);
    Glcd_veri_yaz(Y);
    Glcd_veri_yaz(Y + Height - 1);

    Glcd_komut_yaz(RAMWR);
    WriteRomDataToLCD(Bitmap + 5, ByteCount);

    Glcd_komut_yaz(NOOP);
    DeselectLCD();
}

//
//     8 bit renk ile yazýlarý görüntüler
//        Giriþ:    S -> yazdýrýlmak istenen karakterler
//                X = x koordinatý
//                Y = y koordinatý
//                karakter_renk8 = Karakterlerin ana rengi
//                arkaplan_renk8 = Karakterlerin arka plan rengi
//
void lcd_yazi_yaz8( const char *s,char X,char Y,char karakter_renk8,char arkaplan_renk8)
{
    while(*s)
        {
        karakter_yaz8(*s++,X,Y,karakter_renk8,arkaplan_renk8);
        X=X+6;
        }
        }

//    
//  8 bit renk kullanrak karakter yazar
//        Giriþ:    c = yazdrýlmak istenen karakter
//                X = x koordinatý
//                Y = y koordinatý
//                karakter_renk8 = Karakterlerin ana rengi
//                arkaplan_renk8 = Karakterlerin arka plan rengi
//
void karakter_yaz8(char C ,char X,char Y,char karakter_renk8,char arkaplan_renk8){
    char chardata,column,row,mask;
    Glcd_komut_yaz(PASET);
    Glcd_veri_yaz(X);
    Glcd_veri_yaz(X + 4);    
    Glcd_komut_yaz(CASET);
    Glcd_veri_yaz(Y);
    Glcd_veri_yaz(Y + 7);
    Glcd_komut_yaz(RAMWR);
        for(column=0; column<5; column++){
        chardata=pgm_read_byte(&Font5x7[(((C - 0x20) * 5) + column)]);
        mask=0x01;
        for (row = 0; row < 8; row++){
        if ((chardata & mask) == 0)
            Glcd_veri_yaz(arkaplan_renk8);
        else
            Glcd_veri_yaz(karakter_renk8);
            mask = mask << 1;}
        }
        Glcd_komut_yaz(NOOP);
        DeselectLCD();
        }

/* ------------------------------------------------------------------------ */
/*                                    RGB12 Fonksiyonlar                          */
/* ------------------------------------------------------------------------ */

//
// 12 bit renk kullanarak içi dolu dörtgen çizer
//        Enter:    Left = sol x koordinatý (1 - 130)
//                Top = Tepe y koordinatý (1 - 130)
//                Right = Sað x koordinatý (1 - 130)
//                Bottom = Taban y koordinatý (1 - 130)
//                ColorRGB12 = Pixel rengi (rrrrggggbbbb)
//
void ici_dolu_dortgen_ciz_RGB212(char Left, char Top, char Right, char Bottom, int ColorRGB12)
{    int i;
    int PixelCount;
    char Byte1, Byte2, Byte3;
    int LoopCount;
    
    // Dörtgenini çizilebilirliðini doðrula
    if ((Left > Right) || (Top > Bottom))
        return;
    // Dörtgenin koordinatlarý girilir.
    Glcd_komut_yaz(PASET);
    Glcd_veri_yaz(Left);
    Glcd_veri_yaz(Right);
    Glcd_komut_yaz(CASET);
    Glcd_veri_yaz(Top);
    Glcd_veri_yaz(Bottom);
    // Dörtgenini içi boyanýr.
    Glcd_komut_yaz(RAMWR);
    
    Byte1 = (ColorRGB12 >> 4) & 0xff;
    Byte2 = (((ColorRGB12 & 0x0f) << 4) | ((ColorRGB12 >> 8) & 0x0f));
    Byte3 = (ColorRGB12 & 0xff);
    
    PixelCount = (unsigned int) (Right - Left + 1) * (unsigned int) (Bottom - Top + 1);
    LoopCount = (PixelCount / 2) + 1;
    for (i = 0; i < LoopCount; i++)
    {    
        Glcd_veri_yaz(Byte1);
        Glcd_veri_yaz(Byte2);
        Glcd_veri_yaz(Byte3);
    }
    Glcd_komut_yaz(NOOP);
    DeselectLCD();
}

//
// 12 renkli bit bmp resmi çizer
//        Giriþ:    Bitmap -> RGB8 resim datalarý
//                X, Y = resim yerleþtirme koordinatý (sol üst köþesi)
//
void resim_ciz_RGB12( char *Bitmap, char X, char Y)
{    char Width;
    char Height;
    int ByteCount;
    
    Width = Bitmap[1];
    Height = Bitmap[2];
    ByteCount = Bitmap[3] + ((int)Bitmap[4] << 8);
    Glcd_komut_yaz(PASET);
    Glcd_veri_yaz(X);
    Glcd_veri_yaz(X + Width - 1);
    Glcd_komut_yaz(CASET);
    Glcd_veri_yaz(Y);
    Glcd_veri_yaz(Y + Height - 1);
    Glcd_komut_yaz(RAMWR);
    WriteRomDataToLCD(Bitmap + 5, ByteCount);
    Glcd_komut_yaz(NOOP);
    DeselectLCD();
}

static void spi_init(void)
{
    // Lcd giriþ/çýkýþ pinlerini düzenler
    GLCD_CS_PORT|=_BV(LCD_CS);
    GLCD_CS_DDR|=_BV(LCD_CS);
    GLCD_RESET_PORT&=~_BV(LCD_RESET);
    GLCD_RESET_DDR|=_BV(LCD_RESET);
    GLCD_SPI_SDO_DDR|=_BV(SPI_SDO);
    GLCD_SPI_SCK_DDR|=_BV(SPI_SCK);

}

//
// Yazýlýmsal spi kullanarak glcdye 1 byte komut gönderir.
//        Enter:    data = komut
//
static void Glcd_komut_yaz(char data)
{
    // Lcd seçilir
    GLCD_CS_PORT&=~_BV(LCD_CS);
    // 9. biti lojik 0 yaparak komut byetý gönderir.
    GLCD_SPI_SDO_PORT&=~_BV(SPI_SDO);
    GLCD_SPI_SCK_PORT|=_BV(SPI_SCK);
    GLCD_SPI_SCK_PORT&=~_BV(SPI_SCK);
    spi_byte_gonder(data);
}

//
// Program hafýzasý içindeki veri dizisini glcdye gönderir.
//        Giriþ:    RomData -> Gönderilmek istenen diznin iþaretçisi
//                Count = Gönderilmek istenen byte sayýsý
//
static void WriteRomDataToLCD( char *RomData, unsigned int Count)
{    unsigned int i;
    
    for (i = 0; i < Count; i++)
    {
        Glcd_veri_yaz(*RomData++);
    }
}

//
// Yazýlýmsal spi kullanarak glcdye 1 byte veri gönderir.
//        Enter:    data = veri
//
static void Glcd_veri_yaz(char data)
{
    // 9. biti lojik 1 yaparak veri byetý gönderir.
    GLCD_SPI_SDO_PORT|=_BV(SPI_SDO);
    GLCD_SPI_SCK_PORT|=_BV(SPI_SCK);
    GLCD_SPI_SCK_PORT&=~_BV(SPI_SCK);
    spi_byte_gonder(data);
}
// Msb first (Maksimum deðerlikli bit ilk) olarak 1 byte bilgi yazýlýmsal spi kullanarak gödnerilir.
static void spi_byte_gonder (char spi_data){

    GLCD_SPI_SDO_PORT&=~_BV(SPI_SDO); //öncelikle data hattý lojik sýfýr yapýlýr.
    if (spi_data & 0x80) GLCD_SPI_SDO_PORT|=_BV(SPI_SDO); //datanýn 8.biti 1 ise data hattý lojik bir yapýlýr.
    GLCD_SPI_SCK_PORT|=_BV(SPI_SCK); GLCD_SPI_SCK_PORT&=~_BV(SPI_SCK); //saat sinyali gödnerilir.
    
    GLCD_SPI_SDO_PORT&=~_BV(SPI_SDO);    //öncelikle data hattý lojik sýfýr yapýlýr.
    if (spi_data & 0x40) GLCD_SPI_SDO_PORT|=_BV(SPI_SDO); //datanýn 7.biti 1 ise data hattý lojik bir yapýlýr.
    GLCD_SPI_SCK_PORT|=_BV(SPI_SCK); GLCD_SPI_SCK_PORT&=~_BV(SPI_SCK); //saat sinyali gödnerilir.
    
    GLCD_SPI_SDO_PORT&=~_BV(SPI_SDO); //öncelikle data hattý lojik sýfýr yapýlýr.
    if (spi_data & 0x20) GLCD_SPI_SDO_PORT|=_BV(SPI_SDO); //datanýn 6.biti 1 ise data hattý lojik bir yapýlýr.
    GLCD_SPI_SCK_PORT|=_BV(SPI_SCK); GLCD_SPI_SCK_PORT&=~_BV(SPI_SCK); //saat sinyali gödnerilir.
    
    GLCD_SPI_SDO_PORT&=~_BV(SPI_SDO); //öncelikle data hattý lojik sýfýr yapýlýr.
    if (spi_data & 0x10) GLCD_SPI_SDO_PORT|=_BV(SPI_SDO);    //datanýn 5.biti 1 ise data hattý lojik bir yapýlýr.
    GLCD_SPI_SCK_PORT|=_BV(SPI_SCK); GLCD_SPI_SCK_PORT&=~_BV(SPI_SCK); //saat sinyali gödnerilir.
    
    GLCD_SPI_SDO_PORT&=~_BV(SPI_SDO); //öncelikle data hattý lojik sýfýr yapýlýr.
    if (spi_data & 0x08) GLCD_SPI_SDO_PORT|=_BV(SPI_SDO);  //datanýn 4.biti 1 ise data hattý lojik bir yapýlýr.
    GLCD_SPI_SCK_PORT|=_BV(SPI_SCK); GLCD_SPI_SCK_PORT&=~_BV(SPI_SCK); //saat sinyali gödnerilir.
    
    GLCD_SPI_SDO_PORT&=~_BV(SPI_SDO); //öncelikle data hattý lojik sýfýr yapýlýr.
    if (spi_data & 0x04) GLCD_SPI_SDO_PORT|=_BV(SPI_SDO); //datanýn 3.biti 1 ise data hattý lojik bir yapýlýr.
    GLCD_SPI_SCK_PORT|=_BV(SPI_SCK); GLCD_SPI_SCK_PORT&=~_BV(SPI_SCK); //saat sinyali gödnerilir.
    
    GLCD_SPI_SDO_PORT&=~_BV(SPI_SDO); //öncelikle data hattý lojik sýfýr yapýlýr.
    if (spi_data & 0x02) GLCD_SPI_SDO_PORT|=_BV(SPI_SDO); //datanýn 2.biti 1 ise data hattý lojik bir yapýlýr.
    GLCD_SPI_SCK_PORT|=_BV(SPI_SCK); GLCD_SPI_SCK_PORT&=~_BV(SPI_SCK); //saat sinyali gödnerilir.
    
    GLCD_SPI_SDO_PORT&=~_BV(SPI_SDO); //öncelikle data hattý lojik sýfýr yapýlýr.
    if (spi_data & 0x01) GLCD_SPI_SDO_PORT|=_BV(SPI_SDO); //datanýn 1.biti 1 ise data hattý lojik bir yapýlýr.
    GLCD_SPI_SCK_PORT|=_BV(SPI_SCK); GLCD_SPI_SCK_PORT&=~_BV(SPI_SCK); //saat sinyali gödnerilir.
}

//
// Glcd býrak (komut gönderiminden sonra yapýlmalý)
//
static void DeselectLCD(void)
{
    GLCD_CS_PORT|=_BV(LCD_CS);
}
شرمنده جناب من با سي كار نكردم فقط بيسيك بلدم
يكي ميتونه بگه متن رو تو السيدي 6610 چطوري ميشه نشون داد.
من با پروتئوس شبيه سازي كردم ولي متن رو نشون نميده.
لطفا سريع تر راهنمائي كنيد.
منتظرم
اقا سلام يكي يه نگاهي به برنامه من بندازه بگه مشكلش از كجاست
ميخام عكس روي السيدي نشون بدم ولي ارور ميده.
تشكر


$lib "lcd-pcf8833.lbx"
$regfile = "m32def.dat"
$crystal = 8000000
'First we define that we use a graphic LCD
Config Graphlcd = Color , Controlport = Portc , Cs = 1 , Rs = 0 , Scl = 3 , Sda = 2

Const Blue = &B00000011
Const Yellow = &B11111100
Const Red = &B11100000
Const Green = &B00011100
Const Black = &B00000000
Const White = &B11111111
Const Brightgreen = &B00111110
Const Darkgreen = &B00010100
Const Darkred = &B10100000
Const Darkblue = &B00000010
Const Brightblue = &B00011111
Const Orange = &B11111000

Do
Cls 'clear the display

Waitms 500
Box(0 , 0) -(131 , 131) , Red
Waitms 200
Box(0 , 0) -(131 , 131) , Black
Waitms 200
Boxfill(20 , 20) -(40 , 40) , Green
Waitms 1000
Boxfill(41 , 41) -(60 , 60) , Yellow

Showpic 10 , 10 , Ali

Loop
End

Ali:
$bgf "bbb.bgc"




خط اخری که نوشتی اشتباه باید .bgf بنویسی و شما .bgc نوشتی
صفحه‌ها: 1 2 3