LCDInfo.com
http://forum.lcdinfo.com/

Siemens M65 LCD (132x176) Atmega64 test.
http://forum.lcdinfo.com/viewtopic.php?f=9&t=2336
Page 1 of 1

Author:  MiliKilLer [ Sun Sep 23, 2007 18:38 ]
Post subject:  Siemens M65 LCD (132x176) Atmega64 test.

Hallo.

I like colour display.

I make rutines for controlling any colour display...
on AVR atmega64 work with 22fps (complete buffered) 32Kb Ram.

Now making on LPT - AVR convertor...
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
http://milikiller.ic.cz/external/M65/1.avi
http://milikiller.ic.cz/external/M65/2.avi
http://milikiller.ic.cz/external/M65/3.avi
http://milikiller.ic.cz/external/M65/4.avi

Code:
/*****************************************************
This program was produced by the
CodeWizardAVR V1.24.8d Professional
Automatic Program Generator
© Copyright 1998-2006 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project :
Version :
Date    : 2.6.2007
Author  : MiliKiller                           
Company : Milisoft                           
Comments:


Chip type           : ATmega64
Program type        : Application
Clock frequency     : 20,000000 MHz
Memory model        : Small
External SRAM size  : 64 Kb
Data Stack size     : 1024
*****************************************************/

#include <mega64.h>
#include <delay.h>
#include <math.h>

#define DC              PORTE.7
#define RESET           PORTE.6
#define CS              PORTE.5


#define SRX             132
#define SRY             176
#define OFFSETX SRX/2                // offset for screen wont change unless
#define OFFSETY SRY/2                 // i use different screen! so its kinda fixed
#define OFFSETZ 32
           
unsigned char LCD_RAM[132][176];

unsigned char cursX = 0;
unsigned char cursY = 0; 

unsigned char joy = 0;

 int i,vertex;                          // temp variable for loops
 float xt,yt,zt,x,y,z,sinax,cosax,sinay,cosay,sinaz,cosaz;  // lots of work variables
 float xpos=0;            // position for object in 3d space, in x
 float ypos=0;            // y
 float zpos=0;            // and z values
 float rotx=0;                     // starting amount of x rotation
 float roty=0;                       // starting amount of y rotation
 float rotz=0;                      // starting amount of z rotation




int newx[64];
int newy[64];

const float aa[64] = {7.14178371429,8.39784812927,9.3311882019,9.90593624115,10.1000041962,9.90593624115,9.3311882019,8.39784812927,7.14178371429,5.61126422882,3.8651061058,1.97041475773,1.47197215483e-006,-1.97041165829,-3.86510229111,-5.61125946045,-7.14177846909,-8.3978433609,-9.33118247986,-9.90592861176,-10.0999956131,-9.90592479706,-9.33117485046,-8.39783191681,-7.14176464081,-5.61124324799,-3.8650841713,-1.97039234638,2.09770769288e-005,1.97043383121,3.86512422562,5.61128044128,7.14179754257,8.39785957336,9.3311958313,9.90594100952,10.1000041962,9.90593338013,9.33118247986,8.39784145355,7.14177894592,5.61126232147,3.86510896683,1.97042238712,1.41541995617e-005,-1.97039449215,-3.86508178711,-5.61123657227,-7.1417555809,-8.39782238007,-9.3311662674,-9.90592002869,-10.0999956131,-9.90593624115,-9.33119773865,-8.39786911011,-7.14181470871,-5.61130571365,-3.86515831947,-1.97047567368,-6.87620340614e-005,1.97034108639,3.86503243446,5.61119365692};
const float bb[64] = {7.14178419113,5.61126470566,3.86510801315,1.9704182148,6.30520207778e-006,-1.97040557861,-3.86509585381,-5.6112537384,-7.14177322388,-8.39783859253,-9.33117961884,-9.90592670441,-10.0999956131,-9.90592575073,-9.33117675781,-8.39783477783,-7.14176940918,-5.61124801636,-3.86508989334,-1.97039806843,1.52952252392e-005,1.97042834759,3.86511850357,5.61127567291,7.14179325104,8.39785575867,9.33119392395,9.90593910217,10.1000051498,9.90593338013,9.33118152618,8.39783763885,7.14177036285,5.61124849319,3.86508870125,1.9703963995,-1.71329884324e-005,-1.97042512894,-3.86511087418,-5.61126327515,-7.14177799225,-8.3978395462,-9.33117866516,-9.90592575073,-10.0999956131,-9.90592956543,-9.33118534088,-8.39785003662,-7.14179134369,-5.6112780571,-3.86512851715,-1.97044348717,-3.59154437319e-005,1.97037339211,3.86506223679,5.61122083664,7.14174365997,8.39781475067,9.33116340637,9.90592193604,10.1000051498,9.90595245361,9.33121967316,8.39789581299};
const float cc[64] = {-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,-10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815,10.1000003815};
const int ff[96] = {1,2,33,1,2,3,34,3,4,35,4,5,36,5,6,37,6,7,38,7,8,39,8,9,40,9,10,41,10,11,42,11,12,43,12,13,44,13,14,45,14,15,46,15,16,47,16,17,48,17,18,49,18,19,50,19,20,51,20,21,52,21,22,53,22,23,54,23,24,55,24,25,56,25,26,57,26,27,58,27,28,59,28,29,60,29,30,61,30,31,62,31,32,63,1,33};
const int gg[96] = {2,34,34,33,3,35,35,4,36,36,5,37,37,6,38,38,7,39,39,8,40,40,9,41,41,10,42,42,11,43,43,12,44,44,13,45,45,14,46,46,15,47,47,16,48,48,17,49,49,18,50,50,19,51,51,20,52,52,21,53,53,22,54,54,23,55,55,24,56,56,25,57,57,26,58,58,27,59,59,28,60,60,29,61,61,30,62,62,31,63,63,32,64,64,32,64};
const int vert =64;
const int edges =96;







int sx,sy,ex,ey;                   // define global vars for calling graphics subroutines















flash unsigned char FontLookup [92][5] ={
    { 0x00, 0x00, 0x00, 0x00, 0x00 },   // sp
    { 0x00, 0x00, 0x2f, 0x00, 0x00 },   // !
    { 0x00, 0x07, 0x00, 0x07, 0x00 },   // "
    { 0x14, 0x7f, 0x14, 0x7f, 0x14 },   // #
    { 0x24, 0x2a, 0x7f, 0x2a, 0x12 },   // $
    { 0xc4, 0xc8, 0x10, 0x26, 0x46 },   // %
    { 0x36, 0x49, 0x55, 0x22, 0x50 },   // &
    { 0x00, 0x05, 0x03, 0x00, 0x00 },   // '
    { 0x00, 0x1c, 0x22, 0x41, 0x00 },   // (
    { 0x00, 0x41, 0x22, 0x1c, 0x00 },   // )
    { 0x14, 0x08, 0x3E, 0x08, 0x14 },   // *
    { 0x08, 0x08, 0x3E, 0x08, 0x08 },   // +
    { 0x00, 0x00, 0x50, 0x30, 0x00 },   // ,
    { 0x10, 0x10, 0x10, 0x10, 0x10 },   // -
    { 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 },   // ;
    { 0x08, 0x14, 0x22, 0x41, 0x00 },   // <
    { 0x14, 0x14, 0x14, 0x14, 0x14 },   // =
    { 0x00, 0x41, 0x22, 0x14, 0x08 },   // >
    { 0x02, 0x01, 0x51, 0x09, 0x06 },   // ?
    { 0x32, 0x49, 0x59, 0x51, 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, 0x09, 0x01 },   // F
    { 0x3E, 0x41, 0x49, 0x49, 0x7A },   // 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, 0x0C, 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
    { 0x3F, 0x40, 0x38, 0x40, 0x3F },   // W
    { 0x63, 0x14, 0x08, 0x14, 0x63 },   // X
    { 0x07, 0x08, 0x70, 0x08, 0x07 },   // Y
    { 0x61, 0x51, 0x49, 0x45, 0x43 },   // Z
    { 0x00, 0x7F, 0x41, 0x41, 0x00 },   // [
    { 0x55, 0x2A, 0x55, 0x2A, 0x55 },   // 55
    { 0x00, 0x41, 0x41, 0x7F, 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
    { 0x0C, 0x52, 0x52, 0x52, 0x3E },   // g
    { 0x7F, 0x08, 0x04, 0x04, 0x78 },   // h
    { 0x00, 0x44, 0x7D, 0x40, 0x00 },   // i
    { 0x20, 0x40, 0x44, 0x3D, 0x00 },   // j
    { 0x7F, 0x10, 0x28, 0x44, 0x00 },   // 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
    { 0x18, 0x18, 0x7E, 0x3C, 0x18 }    // sipka
};

flash unsigned char cisla [10][14][12] ={
{
{ 255,255,0,0,0,0,0,0,255,255,255,255 },
{ 255,255,0,0,0,0,0,0,255,255,255,255 },
{ 0,0,0,0,255,255,0,0,0,0,255,255 },
{ 0,0,0,0,255,255,0,0,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,0,0,255,255,0,0,0,0,255,255 },
{ 0,0,0,0,255,255,0,0,0,0,255,255 },
{ 255,255,0,0,0,0,0,0,255,255,255,255 },
{ 255,255,0,0,0,0,0,0,255,255,255,255 }},
{
{ 255,255,255,0,0,0,0,0,0,255,255,255 },
{ 255,255,255,0,0,0,0,0,0,255,255,255 },
{ 255,0,0,0,0,255,255,0,0,255,255,255 },
{ 255,0,0,0,0,255,255,0,0,255,255,255 },
{ 255,0,0,255,255,255,255,0,0,255,255,255 },
{ 255,0,0,255,255,255,255,0,0,255,255,255 },
{ 255,0,0,0,0,255,255,0,0,255,255,255 },
{ 255,0,0,0,0,255,255,0,0,255,255,255 },
{ 255,255,255,0,0,255,255,0,0,255,255,255 },
{ 255,255,255,0,0,255,255,0,0,255,255,255 },
{ 255,255,255,0,0,255,255,0,0,255,255,255 },
{ 255,255,255,0,0,255,255,0,0,255,255,255 },
{ 255,255,255,0,0,0,0,0,0,255,255,255 },
{ 255,255,255,0,0,0,0,0,0,255,255,255 }},
{
{ 0,0,0,0,0,0,0,0,255,255,255,255 },
{ 0,0,0,0,0,0,0,0,255,255,255,255 },
{ 0,0,255,255,255,255,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,0,0,255,255,0,0,0,0,255,255 },
{ 0,0,0,0,255,255,0,0,0,0,255,255 },
{ 0,0,255,255,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 }},

{
{ 0,0,0,0,0,0,0,0,255,255,255,255 },
{ 0,0,0,0,0,0,0,0,255,255,255,255 },
{ 0,0,255,255,255,255,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,255,255,255,255 },
{ 0,0,0,0,0,0,0,0,255,255,255,255 }},

{
{ 0,0,0,0,0,0,255,255,255,255,255,255 },
{ 0,0,0,0,0,0,255,255,255,255,255,255 },
{ 0,0,255,255,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,0,0,255,255,0,0,0,0,255,255 },
{ 0,0,0,0,255,255,0,0,0,0,255,255 },
{ 255,255,0,0,255,255,0,0,255,255,255,255 },
{ 255,255,0,0,255,255,0,0,255,255,255,255 },
{ 255,255,0,0,0,0,0,0,255,255,255,255 },
{ 255,255,0,0,0,0,0,0,255,255,255,255 }},
 
{
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,255,255,255,255 },
{ 0,0,0,0,0,0,0,0,255,255,255,255 }},

{
{ 255,255,0,0,0,0,0,0,0,0,255,255 },
{ 255,255,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,0,0,255,255,255,255,0,0,255,255 },
{ 0,0,0,0,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 }},
{
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 255,255,0,0,255,255,255,255,0,0,255,255 },
{ 255,255,0,0,255,255,255,255,0,0,255,255 },
{ 255,255,0,0,0,0,255,255,0,0,255,255 },
{ 255,255,0,0,0,0,255,255,0,0,255,255 },
{ 255,255,255,255,0,0,255,255,0,0,255,255 },
{ 255,255,255,255,0,0,255,255,0,0,255,255 },
{ 255,255,255,255,0,0,0,0,0,0,255,255 },
{ 255,255,255,255,0,0,0,0,0,0,255,255 }},
{
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 }},
 
{
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,255,255,255,255,255,255,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 },
{ 0,0,0,0,0,0,0,0,0,0,255,255 }}
};       


flash unsigned char info [5][8][76] ={
{
{ 255,255,255,255,255,255,255,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 },
{ 255,255,255,255,255,255,8,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24 },
{ 255,255,255,255,255,8,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,255,255,24,24,255,255,24,24,255,255,24,255,24,255,24,24,8,24,24,24,255,24,24,24,255,24,24,255,24,255,255,24,255,24,255,24,255,255,255,24 },
{ 255,255,255,255,8,24,24,255,255,255,24,24,24,255,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,255,24,24,24,24,255,24,255,24,255,24,255,24,255,24,24,255,24,255,24,24,8,24,24,24,24,255,24,24,255,255,24,255,24,255,24,24,255,24,255,24,24,255,24,24 },
{ 255,255,255,8,24,24,255,24,255,24,255,24,255,255,255,24,8,24,255,24,255,24,255,24,255,255,255,24,8,24,255,255,255,255,255,24,255,255,24,24,255,255,24,24,255,255,24,255,24,255,24,24,8,24,255,255,255,255,255,24,255,24,255,255,24,255,255,24,24,255,24,24,24,255,24,24 },
{ 255,255,8,24,24,24,24,24,255,24,24,24,24,255,24,24,8,24,24,255,255,255,24,24,24,24,24,24,8,24,24,255,24,24,24,24,255,24,24,24,255,24,255,24,255,24,24,255,24,255,24,24,8,24,24,24,24,255,24,24,255,24,24,255,24,255,24,24,255,24,255,24,24,255,24,24 },
{ 255,8,24,24,24,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,255,24,24,24,255,24,255,24,255,255,24,24,255,24,24,24,8,24,24,24,255,24,24,24,255,24,24,255,24,255,255,24,255,24,255,24,24,255,24,24 },
{ 8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24 }},

{
{ 255,255,255,255,255,255,255,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 },
{ 255,255,255,255,255,255,8,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24 },
{ 255,255,255,255,255,8,24,24,231,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,255,255,24,24,255,255,24,24,255,255,24,255,24,255,24,24,8,24,24,24,255,24,24,24,255,24,24,255,24,255,255,24,255,24,255,24,255,255,255,24 },
{ 255,255,255,255,8,24,24,231,231,231,24,24,24,231,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,255,24,24,24,24,255,24,255,24,255,24,255,24,255,24,24,255,24,255,24,24,8,24,24,24,24,255,24,24,255,255,24,255,24,255,24,24,255,24,255,24,24,255,24,24 },
{ 255,255,255,8,24,24,231,24,231,24,231,24,231,231,231,24,8,24,255,24,255,24,255,24,255,255,255,24,8,24,255,255,255,255,255,24,255,255,24,24,255,255,24,24,255,255,24,255,24,255,24,24,8,24,255,255,255,255,255,24,255,24,255,255,24,255,255,24,24,255,24,24,24,255,24,24 },
{ 255,255,8,24,24,24,24,24,231,24,24,24,24,231,24,24,8,24,24,255,255,255,24,24,24,24,24,24,8,24,24,255,24,24,24,24,255,24,24,24,255,24,255,24,255,24,24,255,24,255,24,24,8,24,24,24,24,255,24,24,255,24,24,255,24,255,24,24,255,24,255,24,24,255,24,24 },
{ 255,8,24,24,24,24,24,24,231,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,255,24,24,24,255,24,255,24,255,255,24,24,255,24,24,24,8,24,24,24,255,24,24,24,255,24,24,255,24,255,255,24,255,24,255,24,24,255,24,24 },
{ 8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24 }},

{
{ 255,255,255,255,255,255,255,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 },
{ 255,255,255,255,255,255,8,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24 },
{ 255,255,255,255,255,8,24,24,255,24,24,24,24,24,24,24,8,24,24,24,231,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,255,255,24,24,255,255,24,24,255,255,24,255,24,255,24,24,8,24,24,24,255,24,24,24,255,24,24,255,24,255,255,24,255,24,255,24,255,255,255,24 },
{ 255,255,255,255,8,24,24,255,255,255,24,24,24,255,24,24,8,24,24,24,231,24,24,24,24,24,24,24,8,24,24,255,24,24,24,24,255,24,255,24,255,24,255,24,255,24,24,255,24,255,24,24,8,24,24,24,24,255,24,24,255,255,24,255,24,255,24,24,255,24,255,24,24,255,24,24 },
{ 255,255,255,8,24,24,255,24,255,24,255,24,255,255,255,24,8,24,231,24,231,24,231,24,231,231,231,24,8,24,255,255,255,255,255,24,255,255,24,24,255,255,24,24,255,255,24,255,24,255,24,24,8,24,255,255,255,255,255,24,255,24,255,255,24,255,255,24,24,255,24,24,24,255,24,24 },
{ 255,255,8,24,24,24,24,24,255,24,24,24,24,255,24,24,8,24,24,231,231,231,24,24,24,24,24,24,8,24,24,255,24,24,24,24,255,24,24,24,255,24,255,24,255,24,24,255,24,255,24,24,8,24,24,24,24,255,24,24,255,24,24,255,24,255,24,24,255,24,255,24,24,255,24,24 },
{ 255,8,24,24,24,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,231,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,255,24,24,24,255,24,255,24,255,255,24,24,255,24,24,24,8,24,24,24,255,24,24,24,255,24,24,255,24,255,255,24,255,24,255,24,24,255,24,24 },
{ 8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24 }},

{
{ 255,255,255,255,255,255,255,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 },
{ 255,255,255,255,255,255,8,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24 },
{ 255,255,255,255,255,8,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,231,24,24,24,231,231,24,24,231,231,24,24,231,231,24,231,24,231,24,24,8,24,24,24,255,24,24,24,255,24,24,255,24,255,255,24,255,24,255,24,255,255,255,24 },
{ 255,255,255,255,8,24,24,255,255,255,24,24,24,255,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,231,24,24,24,24,231,24,231,24,231,24,231,24,231,24,24,231,24,231,24,24,8,24,24,24,24,255,24,24,255,255,24,255,24,255,24,24,255,24,255,24,24,255,24,24 },
{ 255,255,255,8,24,24,255,24,255,24,255,24,255,255,255,24,8,24,255,24,255,24,255,24,255,255,255,24,8,24,231,231,231,231,231,24,231,231,24,24,231,231,24,24,231,231,24,231,24,231,24,24,8,24,255,255,255,255,255,24,255,24,255,255,24,255,255,24,24,255,24,24,24,255,24,24 },
{ 255,255,8,24,24,24,24,24,255,24,24,24,24,255,24,24,8,24,24,255,255,255,24,24,24,24,24,24,8,24,24,231,24,24,24,24,231,24,24,24,231,24,231,24,231,24,24,231,24,231,24,24,8,24,24,24,24,255,24,24,255,24,24,255,24,255,24,24,255,24,255,24,24,255,24,24 },
{ 255,8,24,24,24,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,231,24,24,24,231,24,24,24,231,24,231,24,231,231,24,24,231,24,24,24,8,24,24,24,255,24,24,24,255,24,24,255,24,255,255,24,255,24,255,24,24,255,24,24 },
{ 8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24 }},

{
{ 255,255,255,255,255,255,255,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 },
{ 255,255,255,255,255,255,8,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24 },
{ 255,255,255,255,255,8,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,255,255,24,24,255,255,24,24,255,255,24,255,24,255,24,24,8,24,24,24,231,24,24,24,231,24,24,231,24,231,231,24,231,24,231,24,231,231,231,24 },
{ 255,255,255,255,8,24,24,255,255,255,24,24,24,255,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,255,24,24,24,24,255,24,255,24,255,24,255,24,255,24,24,255,24,255,24,24,8,24,24,24,24,231,24,24,231,231,24,231,24,231,24,24,231,24,231,24,24,231,24,24 },
{ 255,255,255,8,24,24,255,24,255,24,255,24,255,255,255,24,8,24,255,24,255,24,255,24,255,255,255,24,8,24,255,255,255,255,255,24,255,255,24,24,255,255,24,24,255,255,24,255,24,255,24,24,8,24,231,231,231,231,231,24,231,24,231,231,24,231,231,24,24,231,24,24,24,231,24,24 },
{ 255,255,8,24,24,24,24,24,255,24,24,24,24,255,24,24,8,24,24,255,255,255,24,24,24,24,24,24,8,24,24,255,24,24,24,24,255,24,24,24,255,24,255,24,255,24,24,255,24,255,24,24,8,24,24,24,24,231,24,24,231,24,24,231,24,231,24,24,231,24,231,24,24,231,24,24 },
{ 255,8,24,24,24,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,24,24,24,24,8,24,24,24,255,24,24,24,255,24,24,24,255,24,255,24,255,255,24,24,255,24,24,24,8,24,24,24,231,24,24,24,231,24,24,231,24,231,231,24,231,24,231,24,24,231,24,24 },
{ 8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,8,8,8,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24 }}

};




void Draw_cisla(unsigned char cislo,unsigned char x,unsigned char y)
{
unsigned char ix,iy;
for(ix = 0; ix < 14; ix++)
    {
    for(iy = 0; iy < 12; iy++)
    {
    LCD_RAM [(char)(x+ix)][(char)(y+iy)] = cisla[cislo][ix][iy];
    };
    };
}


void WRCMD(unsigned int output_data)
{       
        CS = 0;
        DC = 1;
        SPDR= (output_data >> 8);
        while ((SPSR & (1<<7))==0);
       
        delay_us(5);
       
        SPDR= (output_data & 0x00FF);
        while ((SPSR & (1<<7))==0);
        delay_us(5);
        CS = 1;
   
}

void WRDATA(unsigned int output_data)
{
        CS = 0;
        DC = 0;
        SPDR= (output_data >> 8);
        while ((SPSR & (1<<7))==0);
       
        delay_us(3);
       
        SPDR= (output_data & 0x00FF);
        while ((SPSR & (1<<7))==0);
        delay_us(3);
        CS = 1;   
}


void Draw_RAM(void)
{
unsigned char temp;

unsigned char ix = 0;
unsigned char iy = 0;

WRCMD(0xEF90);
WRCMD(0x0500);
WRCMD(0x0600);
WRCMD(0x0700);


DC = 0;
CS = 0;
ix = 176;

while ( ix != 0 ) {
    iy = 0;
    ix--;
    while ( iy < 132 ) {
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
       
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
               
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
                       
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
               
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
               
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
               
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
               
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
               
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
               
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
               
        temp = LCD_RAM [iy][ix];
        #asm
        nop
        #endasm
        SPDR= (temp & 231);
       
        LCD_RAM [iy][ix] = 255;
        #asm
        nop
        #endasm
        SPDR= (temp & 24);
        iy++;
    }
    };
while ((SPSR & (1<<7))==0);
CS = 1;
}





void LCD_char(unsigned char data,unsigned char colour)
{
unsigned char index;

data = data - 32;

for(index = 0; index < 5; index++)
{
        if ((FontLookup[data][index]&1)==1) 
        {
        LCD_RAM [cursY][cursX] = colour;
        }

        if ((FontLookup[data][index]&2)==2) 
        {
        LCD_RAM [(char)(cursY+1)][cursX] = colour;
        }

        if ((FontLookup[data][index]&4)==4) 
        {
        LCD_RAM [(char)(cursY+2)][cursX] = colour;
        }
       
        if ((FontLookup[data][index]&8)==8) 
        {
        LCD_RAM [(char)(cursY+3)][cursX] = colour;
        }
       
        if ((FontLookup[data][index]&16)==16) 
        {
        LCD_RAM [(char)(cursY+4)][cursX] = colour;
        }
       
        if ((FontLookup[data][index]&32)==32) 
        {
        LCD_RAM [(char)(cursY+5)][cursX] = colour;
        }
       
        if ((FontLookup[data][index]&64)==64) 
        {
        LCD_RAM [(char)(cursY+6)][cursX] = colour;
        }

        if ((FontLookup[data][index]&128)==128) 
        {
        LCD_RAM [(char)(cursY+7)][cursX] = colour;
        }
        cursX++;
   };
   cursX++;
}


void LCD_text (flash char *dataPtr ,unsigned char colour)
{
    while ( *dataPtr )
    {
        LCD_char(*dataPtr++ , colour);
    }
}


void LCD_line (int x1,int y1,int x2,int y2,unsigned char colour )
{
    int dx, dy, stepx, stepy, fraction;
   
        if (x1 <= x2)
        {
        dx = x2 - x1;
        }
        else 
        {   
        dx = x1 - x2;
        dx = (dx) - (dx+dx);
        };
       
       
        if (y1 <= y2)
        {
        dy = y2 - y1;
        }
        else 
        {   
        dy = y1 - y2;
        dy = (dy) - (dy+dy);
        };
   

    if ( dy < 0 )
    {
        dy = -dy;
        stepy = -1;     
    }
    else
    {
        stepy = 1;
    }

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

    if (x1<SRX & x1>=0 & y1<SRY & y1>=0)
                {
                LCD_RAM [x1][y1] = colour;
                };

    if ( dx > dy )
    {
        fraction = dy - (dx >> 1);
        while ( x1 != x2 )
        {
            if ( fraction >= 0 )
            {
                y1 += stepy;
                fraction -= dx;
            }
            x1 += stepx;
            fraction += dy;
            if (x1<SRX & x1>=0 & y1<SRY & y1>=0)
                {
                LCD_RAM [x1][y1] = colour;
                };
        }
    }
    else
    {
        fraction = dx - (dy >> 1);
        while ( y1 != y2 )
        {
            if ( fraction >= 0 )
            {
                x1 += stepx;
                fraction -= dy;
            }
            y1 += stepy;
            fraction += dx;
            if (x1<SRX & x1>=0 & y1<SRY & y1>=0)
                {
                LCD_RAM [x1][y1] = colour;
                };
           
        }
    }
}





void LCD_cislo(unsigned int data,unsigned char mista,unsigned char colour)
{
if (mista == 1)
{
LCD_char(data + 48,colour);
};

if (mista == 2)
{
LCD_char(data / 10 + 48,colour);
data = data % 10;
LCD_char(data + 48,colour);
};

if (mista == 3)
{
LCD_char(data / 100 + 48,colour);
data = data % 100;
LCD_char(data / 10 + 48,colour);
data = data % 10;
LCD_char(data + 48,colour);
};

if (mista == 4)
{
LCD_char(data / 1000 + 48,colour);
data = data % 1000;
LCD_char(data / 100 + 48,colour);
data = data % 100;
LCD_char(data / 10 + 48,colour);
data = data % 10;
LCD_char(data + 48,colour);
};

if (mista == 5)
{
LCD_char(data / 10000 + 48,colour);
data = data % 10000;
LCD_char(data / 1000 + 48,colour);
data = data % 1000;
LCD_char(data / 100 + 48,colour);
data = data % 100;
LCD_char(data / 10 + 48,colour);
data = data % 10;
LCD_char(data + 48,colour);
};

}

void BIG_LCD_cislo(unsigned int data,unsigned char mista)
{
if (mista == 1)
{
Draw_cisla(data,cursX,cursY);
};

if (mista == 2)
{
Draw_cisla(data / 10 ,cursX,cursY);
data = data % 10;
cursY= cursY + 12;
Draw_cisla(data,cursX,cursY);
};

if (mista == 3)
{
Draw_cisla(data / 100,cursX,cursY);
data = data % 100;
cursY= cursY + 12;
Draw_cisla(data / 10 ,cursX,cursY);
data = data % 10;
cursY= cursY + 12;
Draw_cisla(data,cursX,cursY);
};

if (mista == 4)
{
Draw_cisla(data / 1000,cursX,cursY);
data = data % 1000;
cursY= cursY + 12;
Draw_cisla(data / 100,cursX,cursY);
data = data % 100;
cursY= cursY + 12;
Draw_cisla(data / 10 ,cursX,cursY);
data = data % 10;
cursY= cursY + 12;
Draw_cisla(data,cursX,cursY);
};

if (mista == 5)
{
Draw_cisla(data / 10000,cursX,cursY);
data = data % 10000;
cursY= cursY + 12;
Draw_cisla(data / 1000,cursX,cursY);
data = data % 1000;
cursY= cursY + 12;
Draw_cisla(data / 100,cursX,cursY);
data = data % 100;
cursY= cursY + 12;
Draw_cisla(data / 10 ,cursX,cursY);
data = data % 10;
cursY= cursY + 12;
Draw_cisla(data,cursX,cursY);
};

}


void LCD_init(void)
{
RESET = 0;
delay_ms(20);
RESET = 1;


WRCMD(0xFDFD);
WRCMD(0xFDFD);

WRCMD(0xEF00);

WRCMD(0xEE04);
WRCMD(0x1B04);

WRCMD(0xFEFE);
WRCMD(0xFEFE);

WRCMD(0xEF90);
WRCMD(0x4A04);
WRCMD(0x7F3F);
WRCMD(0xEE04);
WRCMD(0x4306);

delay_ms(5);

WRCMD(0xEF90);
WRCMD(0x0983);
WRCMD(0x0800);
WRCMD(0x0BAF);
WRCMD(0x0A00);
WRCMD(0x0500);
WRCMD(0x0600);
WRCMD(0x0700);

WRCMD(0xEF00);

WRCMD(0xEE0C);

WRCMD(0xEF90);
WRCMD(0x0080);

WRCMD(0xEFB0);
WRCMD(0x4902);

WRCMD(0xEF00);

WRCMD(0x7F01);
WRCMD(0xE181);

WRCMD(0xE202);

WRCMD(0xE276);

WRCMD(0xE183);

WRCMD(0x8001);


WRCMD(0xEF90);
WRCMD(0x0500);
WRCMD(0x0600);
WRCMD(0x0700);
}

void read_joy(void)
{
joy = 0;

PORTE.3 = 255;
PORTE.4 = 0;

#asm
    nop
    nop
    nop
#endasm

if (PINF&8)
{
joy = 4;
};

if (PINF&4)
{
joy = 2;
};

PORTE.3 = 0;
PORTE.4 = 255;

#asm
    nop
    nop
    nop
#endasm


if (PINF&8)
{
joy = 1;
};

if (PINF&4)
{
joy = 3;
};

}


void Draw_info(unsigned char value,unsigned char x,unsigned char y)
{
unsigned char ix,iy;
for(ix = 0; ix < 8; ix++)
    {
    for(iy = 0; iy < 76; iy++)
    {
    LCD_RAM [(char)(x+ix)][(char)(y+iy)] = info[value][ix][iy];
    };
    };
}

void cube()                        // routine to draw and calc 3d cube
 {
  xpos=xpos+0.0;         // move the object
  ypos=ypos+0.0;         // it would wander off screen
  zpos=zpos+0.0;         // really quick, so leave it centered

  rotx=rotx+0.00;                   // rotate the cube on X axis
  roty=roty+0.00;                   // and on its y axis
  rotz=rotz+0.00;                   // dont bother with z or it gets confusing

  sinax=sin(rotx);         // precalculate the sin and cos values
  cosax=cos(rotx);         // for the rotation as this saves a
 
  sinay=sin(roty);         // little time when running as we
  cosay=cos(roty);         // call sin and cos less often
 
  sinaz=sin(rotz);         // they are slow routines
  cosaz=cos(rotz);         // and we dont want slow!

  for (i=0; i<vert; i++)              // translate 3d vertex position to 2d screen position
        {
        x=aa[i];                   // get x for vertex i
        y=bb[i];                   // get y for vertex i
        z=cc[i];                   // get z for vertex i

        yt = y * cosax - z * sinax;   // rotate around the x axis
        zt = y * sinax + z * cosax;   // using the Y and Z for the rotation
        y = yt;
        z = zt;

        xt = x * cosay - z * sinay;   // rotate around the Y axis
        zt = x * sinay + z * cosay;   // using X and Z
        x = xt;
        z = zt;

        xt = x * cosaz - y * sinaz;   // finaly rotate around the Z axis
        yt = x * sinaz + y * cosaz;   // using X and Y
        x = xt;
        y = yt;

        x=x+xpos;         // add the object position offset
        y=y+ypos;         // for both x and y
        z=z+OFFSETZ-zpos;      // as well as Z

        newx[i]=(x*64/z)+OFFSETX;   // translate 3d to 2d coordinates for screen
        newy[i]=(y*64/z)+OFFSETY;   // drawing so we can see the cube
        }

  for (i=0; i<edges; i++)      // draw the lines that make up the object
        {
        vertex=ff[i]-1;         // temp = start vertex for this line
        sx=newx[vertex];        // set line start x to vertex[i] x position
        sy=newy[vertex];        // set line start y to vertex[i] y position   
        vertex=gg[i]-1;         // temp = end vertex for this line
        ex=newx[vertex];   // set line end x to vertex[i+1] x position
        ey=newy[vertex];   // set line end y to vertex[i+1] y position
        LCD_line(sx,sy,ex,ey,0);// draw the line between these 2 vertex
        }
 }


void main(void)
{
PORTB=0x00;
DDRB=247;

PORTE=0x00;
DDRE=0xFF;

PORTF=0x00;
DDRF=192;

PORTD=0x00;
DDRD=0x00;

// External SRAM page configuration:
//              -              / 0000h - FFFFh
// Lower page wait state(s): None
// Upper page wait state(s): None
MCUCR=0x80;
XMCRA=0x00;

// SPI initialization
// SPI Type: Master
// SPI Clock Rate: 2*4000,000 kHz
// SPI Clock Phase: Cycle Half
// SPI Clock Polarity: Low
// SPI Data Order: MSB First
SPCR=0x50;
SPSR=0x01;

LCD_init();

while (1)
      {     
      read_joy();
     
      rotx=rotx+0.02;
      roty=roty+0.04;   
      rotz=rotz+0.06;
     
      if (joy == 4)
        {
        rotx=rotx+0.1;
        };
     
      if (joy == 3)
        {
        rotx=rotx-0.1;
        };
       
     
      if (joy == 2)
        {
        roty=roty+0.1;
        };
     
      if (joy == 1)
        {
        roty=roty-0.1;
        };
       
      cube();
      cursX = 2;
      cursY = 2;
      LCD_text("176x220 LCD",224);
      cursX = 2;
      cursY = 10;
      LCD_text("ATmega64 @ 20MHz",224);
      cursX = 2;
      cursY = 18;
      LCD_text("64Kbyte Ram",224);

      Draw_info(joy,124,100);
      Draw_RAM();
      };
}

Author:  buze [ Sun Sep 23, 2007 21:40 ]
Post subject: 

Nice one Mili; did you find a datasheet for the screen ?

Also, brave of you to hook up the external SRAM on a breadboard ! What SRAM model did you use ?

Author:  MiliKilLer [ Sun Sep 23, 2007 22:23 ]
Post subject: 

Hi datasheet is non free...but i use this :)
http://www.superkranz.de/christian/S65_ ... Index.html

Ram is standard Static RAM
a625308a its 32kb

I use 2 module and flip CE pin for 64Kbit :)

CPU is overclocked from 16mhz to 20mhz

On 16mhz it work fine but 20mhz is faster and stabile.... 3 month without reset

Page 1 of 1 All times are UTC + 2 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/