1. Trang chủ
  2. » Công Nghệ Thông Tin

Quá trình hình thành tư liệu hướng dẫn cách chấm mạch eprom trong KIT vi xử lý p8

11 6 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 11
Dung lượng 145,51 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Tham khảo tài liệu ''quá trình hình thành tư liệu hướng dẫn cách chấm mạch eprom trong kit vi xử lý p8'', công nghệ thông tin, đồ họa - thiết kế - flash phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả

Trang 1

extern int GetMtx();

extern int GetMty();

//extern EVENT OldEvent();

extern int Double(LPEVENT);

#endif

// End of MOUSE.H

IX.MODULE MOUSE.CPP

#include <conio.h>

#include <graphics.h>

//#include <STDLIB.H>

#include <COMPLEX.H>

#include "mouse.h"

void SetMouseRange(LPRECT lpRect)

// Dat vung di chuyen cho chuot

{

_AX = 0x07;//ham 07 cua ngat 33 de dinh gioi han di chuyen ngang _CX = lpRect->left;

_DX = lpRect->right;

geninterrupt(INT_MOUSE);//INT_MOUSE=0x33:ngat 33

_AX = 0x08;//ham 08 cua ngat 33 dinh gioi han di chuyen doc cho con tro

_CX = lpRect->top;

_DX = lpRect->bottom;

geninterrupt(INT_MOUSE);

}

// -

int InitMouse(LPRECT lpRect)

// Khoi dong chuot

{

int ax;

_AX = 0;

geninterrupt(INT_MOUSE);

ax = _AX;

if (ax == 0)

return FALSE;

SetMouseRange(lpRect);

return TRUE;

}

// -

void ShowMouse(void)

// Hien thi chuot

{

_AX = 1;

geninterrupt(INT_MOUSE);

}

// -

void HideMouse(void)

// Dau chuot

{

_AX = 2;

geninterrupt(INT_MOUSE);

}

// -

#include <CONIO.H>

#include <STDIO.H>

void MouseRead(LPEVENT lpEvent)

// Tra ve bien co nhan duoc tu chuot : Nut trai hay phai duoc an

{

Trang 2

int bx;

_AX = 3;

geninterrupt(INT_MOUSE);

bx = _BX;

//cx = _CX;

//dx = _DX;

lpEvent->Msg = bx;

lpEvent->Posx = _CX;

lpEvent->Posy = _DX;

gettime(lpEvent->t);

}

// -

void ResetEvent(LPEVENT lpEvent)

{

lpEvent->Msg = 0;

lpEvent->Posx = lpEvent->Posy = 0;

}

// -

EVENT PrevEvent, CurEvent;

// -

LPEVENT GetEvent(void)

{

ResetEvent(&CurEvent);

MouseRead(&CurEvent);

// chuyen sang toa do ViewPort

CurEvent.Posx = CurEvent.Posx-MainWindow.rViewPort.left;

CurEvent.Posy = CurEvent.Posy-MainWindow.rViewPort.top;

// xet trang thai chuot co thay doi hay khong

if((CurEvent.Posx!=PrevEvent.Posx)&&(CurEvent.Posy!=PrevEvent.Posy)) CurEvent.Msg |= M_CHANGE;

PrevEvent = CurEvent;

// delay(50);

return (&CurEvent);

}

// -

void DeviceRelease(int Msg)

{

while(GetEvent()->Msg&Msg);

}

// -

int Double(LPEVENT lpEvent)

{

if(lpEvent->Msg==1)

{

delay(100);

ResetEvent(lpEvent);

lpEvent=GetEvent();

if(lpEvent->Msg==1)

//if((abs(CurEvent.Posx-oldEvent.Posx))<=10&&abs(CurEvent.Posy-oldEvent.Posy)<=10)

{

{

return 1;

}

}

else

return 0;

}

else return 0;

}

// -

Trang 3

void MouseText(int x,int y,int color1,int color2)//,char s[])//gia dau nhay con tro

{

HideMouse();

// int h=textheight(s);

int w=5;

int color=getcolor();

do

{

for(int i=0;i<10&&(!kbhit());i++)

{

setcolor(color2);//WHITE);

line(x,y,x+w,y);

line(x,y+1,x+w,y+1);

delay(10);

setcolor(color);

}

setcolor(color1);//GREEN);

line(x,y,x+w,y);

line(x,y+1,x+w,y+1);

setcolor(color);

for(i=0;i<10&&(!kbhit());i++)

{

setcolor(color1);//GREEN);

line(x,y,x+w,y);

line(x,y+1,x+w,y+1);

delay(10);

setcolor(color);

}

}while(!kbhit());

}

// -

int GetMtx()

{

return getx();

}

// -

int GetMty()

{

return gety();

}

// -

// End of MOUSE.CPP

X.CLASS SCREEN.H

#if !defined( SCREEN_H )

#define SCREEN_H

// Dinh nghia cac kieu du lieu

typedef struct tagRECT{

int left, top, right, bottom ;

}RECT;

typedef RECT far *LPRECT;

typedef struct tagWINDOW {

char sCaption[80]; /*Window's caption*/

RECT rWinRect; /*Rectangle in which window is located*/

Trang 4

RECT rSys; /*System area of window*/

RECT rTitleBar; /*Caption area of window*/

RECT rMenuBar; /*Rectangle in which window's menu is located*/

RECT rMessage; /* Rectangle in which messages is display }WINDOWS;

// Dinh nghia cac ham va bien dung toan cuc

extern int LineColor;

extern int VP_WIDTH;

extern int VP_HEIGHT;

extern WINDOWS MainWindow;

extern void InitGraphics(void);

extern void OutMessage(char *Msg);

extern void InitScreen(void);

extern void InitValues(char *lpCaption);

extern int OutError(char *s);

#endif

// End of SCREEN.H

XI.MODULE SCREEN.CPP

#include <conio.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <graphics.h>

#include "screen.h"

#include "mouse.h"

int T_SIZE, W_SIZE, H_SIZE, W_CHAR, H_CHAR, MSG_SIZE;

int COLOR_WINDOW;

int COLOR_BUTTON;

int COLOR_BORDER;

int COLOR_CAPTION;

int COLOR_TEXT;

int VP_WIDTH;

int VP_HEIGHT;

int Maxx, Maxy; // Maxx - Maxy of screen

WINDOWS MainWindow;

//int Xc, Yc; // Goc toa do

//int LineColor = MAGENTA; // Mau cua duong thang can ve - Dung trong thu tuc SetPixel

// -

void InitGraphics(void)

// Khoi tao che do do hoa

{

int grDrv=DETECT, grMode;

initgraph(&grDrv, &grMode, "");

ErrCode = graphresult();

if(ErrCode!= grOk)

{

printf("Graphics error: %s\n", grapherrormsg(ErrCode));

printf("Press any key to halt ");

getch();

exit(1); /* return with error code */

}

Maxx = getmaxx();

Trang 5

Maxy = getmaxy();

}

// -

void InitValues(char *lpCaption)

// Khoi tao cac gia tri cho bien Windows de ve cua so man hinh

{

int WinWidth, WinHeight;

W_CHAR = 8; H_CHAR = 8; // Chieu rong va chieu cao cua mot ki tu

W_SIZE = 8; H_SIZE = 20; T_SIZE = 18; MSG_SIZE = 20;

COLOR_WINDOW = CYAN;

COLOR_BUTTON = LIGHTGRAY;

COLOR_BORDER = LIGHTGRAY;

COLOR_CAPTION = BLUE;

COLOR_TEXT = BLUE;

strcpy(MainWindow.sCaption, lpCaption);

// Gan gia tri cho WinRect - H.C.nhat chua cua so

MainWindow.rWinRect.left = 0;

MainWindow.rWinRect.top = 0;

MainWindow.rWinRect.right = Maxx;

MainWindow.rWinRect.bottom= Maxy;

WinWidth = MainWindow.rWinRect.right-MainWindow.rWinRect.left+1;

WinHeight= MainWindow.rWinRect.bottom-MainWindow.rWinRect.top+1;

// Gan gia tri cho rSys - H.C.nhat chua SystemMenu

MainWindow.rSys.left = BORDERSIZE;

MainWindow.rSys.top = BORDERSIZE;

MainWindow.rSys.right = MainWindow.rSys.left+T_SIZE;

MainWindow.rSys.bottom= MainWindow.rSys.top+T_SIZE;

// Gan gia tri cho rTitleBar - H.C.nhat chua thong tin thanh

tieu de

MainWindow.rTitleBar.left =

BORDERSIZE+1;//MainWindow.rSys.right+1;

MainWindow.rTitleBar.top = BORDERSIZE+1;

MainWindow.rTitleBar.right = WinWidth-BORDERSIZE-1;

MainWindow.rTitleBar.bottom= MainWindow.rSys.top+T_SIZE;

// Gan gia tri cho rMenuBar - H.C.nhat chua thong tin menu

// Gan gia tri cho rMessage - H.C.nhat chua thong tin cua cac //thong bao

MainWindow.rMessage.left = BORDERSIZE+1;

MainWindow.rMessage.right = WinWidth-BORDERSIZE-2;

MainWindow.rMessage.top = WinHeight-(BORDERSIZE+2)-MSG_SIZE;

MainWindow.rMessage.bottom= MainWindow.rMessage.top+MSG_SIZE;

// Gan gia tri cho rViewPort - H.C.nhat chua thong tin ve vung

lam viec

// thuc su cua cua so

MainWindow.rViewPort.left = BORDERSIZE+1;

MainWindow.rViewPort.top =

MainWindow.rTitleBar.bottom+2;//MainWindow.rMenuBar.bottom+2;

MainWindow.rViewPort.right = WinWidth-BORDERSIZE-2;

MainWindow.rViewPort.bottom= MainWindow.rMessage.top-2;

VP_WIDTH = MainWindow.rViewPort.right-MainWindow.rViewPort.left;

VP_HEIGHT = MainWindow.rViewPort.bottom-MainWindow.rViewPort.top;

}

// -

Trang 6

void OutMessage(char *Msg)

// Ghi thong bao Msg ra cua so rMessage

{

struct fillsettingstype FillInfo;

struct viewporttype vp;

// luu thong tin cu

getfillsettings(&FillInfo);

OldColor = getcolor();

getviewsettings(&vp);

// xoa thong bao cu

setviewport(MainWindow.rWinRect.left, MainWindow.rWinRect.top, MainWindow.rWinRect.right, MainWindow.rWinRect.bottom, 1);

setfillstyle(SOLID_FILL, COLOR_BUTTON);

setcolor(COLOR_TEXT);

bar(MainWindow.rMessage.left, MainWindow.rMessage.top,

MainWindow.rMessage.right, MainWindow.rMessage.bottom);

// in thong bao moi ra

outtextxy(MainWindow.rMessage.left+W_CHAR,

MainWindow.rMessage.bottom-H_CHAR-5, Msg);

// tra ve trang thai cu

setfillstyle(FillInfo.pattern, FillInfo.color);

setcolor(OldColor);

setviewport(vp.left,vp.top, vp.right, vp.bottom, 1);

}

// -

void DrawScreenBorder(int left, int top, int right, int bottom)

// Ve duong vien cho mot hinh chu nhat co toa do (left, top), (right, bottom)

{

setfillstyle(SOLID_FILL, COLOR_BORDER);

bar(left, top, right, top+BORDERSIZE);

bar(left, bottom, right, bottom-BORDERSIZE);

bar(left, top, left+BORDERSIZE, bottom);

bar(right-BORDERSIZE, top, right, bottom);

setcolor(BLACK);

rectangle(left, top, right, bottom);

rectangle(left+BORDERSIZE, top+BORDERSIZE,

right-BORDERSIZE, bottom-BORDERSIZE);

}

// -

#include <dos.h>

void InitScreen(void)

// Ve cac thanh phan cua cua so

{

int WinWidth, WinHeight;

struct viewporttype vp;

getviewsettings(&vp);

setviewport(MainWindow.rWinRect.left, MainWindow.rWinRect.top, MainWindow.rWinRect.right, MainWindow.rWinRect.bottom, 1);

WinWidth = MainWindow.rWinRect.right-MainWindow.rWinRect.left+1; WinHeight= MainWindow.rWinRect.bottom-MainWindow.rWinRect.top+1;

x = (WinWidth-W_CHAR*strlen(MainWindow.sCaption))/2+1;

y = BORDERSIZE+(T_SIZE-H_CHAR)/2+1;

// Ve duong vien cua hinh chu nhat

DrawScreenBorder(0, 0, WinWidth-1, WinHeight-1);

Trang 7

delay(DEMODELAY);

// Ve thanh tieu de

setfillstyle(SOLID_FILL, COLOR_CAPTION);

bar(MainWindow.rTitleBar.left, MainWindow.rTitleBar.top,

MainWindow.rTitleBar.right, MainWindow.rTitleBar.bottom);

setcolor(WHITE);

outtextxy(x, y, MainWindow.sCaption);

delay(DEMODELAY);

// Ve SystemMenu

setfillstyle(SOLID_FILL, COLOR_BUTTON);

/* bar(MainWindow.rSys.left+1, MainWindow.rSys.top+1,

MainWindow.rSys.right-1, MainWindow.rSys.bottom-1);

setcolor(BLACK);

rectangle((MainWindow.rSys.left+MainWindow.rSys.right)/2-5,

(MainWindow.rSys.top+MainWindow.rSys.bottom)/2-1,

(MainWindow.rSys.left+MainWindow.rSys.right)/2+5,

(MainWindow.rSys.top+MainWindow.rSys.bottom)/2+1);

delay(DEMODELAY);

*/ // Ve Menu

// bar(MainWindow.rMenuBar.left, MainWindow.rMenuBar.top,

// MainWindow.rMenuBar.right, MainWindow.rMenuBar.bottom);

// outtextxy(MainWindow.rMenuBar.left+8,

MainWindow.rMenuBar.bottom-13,

// "Menu of Program is here");

// delay(DEMODELAY);

// Ve thanh chua thong bao

bar(MainWindow.rMessage.left, MainWindow.rMessage.top,

MainWindow.rMessage.right, MainWindow.rMessage.bottom);

OutMessage("Welcome to Demo Window Program");

delay(DEMODELAY);

// Ve vung lam viec

setfillstyle(SOLID_FILL, COLOR_WINDOW);

bar(MainWindow.rViewPort.left, MainWindow.rViewPort.top,

MainWindow.rViewPort.right, MainWindow.rViewPort.bottom);

setcolor(BLACK);

rectangle(MainWindow.rViewPort.left-1, MainWindow.rViewPort.top, MainWindow.rViewPort.right+1, MainWindow.rViewPort.bottom); delay(DEMODELAY);

// Dat lai viewport la rViewPort

setviewport(MainWindow.rViewPort.left, MainWindow.rViewPort.top,

MainWindow.rViewPort.right, MainWindow.rViewPort.bottom, 1);

}

// -

/*void DrawSysCoordinates(void)

// Ve he truc toa do

{

Xc = VP_WIDTH/2;

Yc = VP_HEIGHT/2;

setcolor(COLOR_TEXT);

// ve hai truc toa do

line(0, Yc, VP_WIDTH, Yc);

line(Xc, 0, Xc, VP_HEIGHT);

// ve hai mui ten

line(Xc, 0, Xc-5, 5);

line(Xc, 0, Xc+5, 5);

line(VP_WIDTH, Yc, VP_WIDTH-5, Yc-5);

line(VP_WIDTH, Yc, VP_WIDTH-5, Yc+5);

// Ve goc toa do

outtextxy(Xc-8, Yc+8, "O");

}

// -

void SetLineColor(int C)

Trang 8

{

LineColor = C;

}

// -

void SetPixel(int x, int y)

{

putpixel(Xc+x, Yc-y, LineColor);

}

// -

void Set2Pixel(int Ox, int Oy, int x, int y)

{

putpixel(Ox+x, Oy-y, LineColor);

putpixel(Ox-x, Oy-y, LineColor);

}

// -

void Set2PixelHor(int Ox, int Oy, int x, int y)

{

putpixel(Ox+x, Oy-y, LineColor);

putpixel(Ox+x, Oy+y, LineColor);

}

// -

void ClearViewPort(void)

{

struct fillsettingstype FillInfo;

// luu thong tin cu

getfillsettings(&FillInfo);

setfillstyle(SOLID_FILL, COLOR_WINDOW);

bar(0, 0, VP_WIDTH, VP_HEIGHT);

setfillstyle(FillInfo.pattern, FillInfo.color);

DrawSysCoordinates();

} */

// End of SCREEN.C

// -

#include <alloc.h>

int OutError(char *s)

{

void far *buf;//con tro chi vung luu tru man hinh

unsigned int size = imagesize(200,150,470,240);

LPEVENT lpEvent;

int Cx1=280,Cy1=203,Cx2=337,Cy2=223;

int Ox1=350,Oy1=203,Ox2=405,Oy2=223;

if ((buf = farmalloc(size)) == NULL)

{

return -1;

}

else

{

getimage(200,150,470,240,buf);

}

setfillstyle(SOLID_FILL,BLUE);

HideMouse();

bar(200,150,470,240);

setcolor(WHITE);

rectangle(200,150,470,240);

outtextxy(200+(270-8*strlen(s))/2,170,s);

setfillstyle(SOLID_FILL,LIGHTBLUE);

bar(Cx1,Cy1,Cx2,Cy2);//280,203,337,223);

int OK=0;

outtextxy(285,210,"Cancel");

outtextxy(365,210,"OK");

int event;

do

Trang 9

{

lpEvent=GetEvent();

if(kbhit())

{

if((event=getch())==13)

{

CompleteOk:

HideMouse();

putimage(200,150,buf,COPY_PUT);

ShowMouse();

farfree(buf);

return OK;

}

if(event==27)

{

CompleteCancel:

HideMouse();

putimage(200,150,buf,COPY_PUT);

ShowMouse();

farfree(buf);

return 0;

}

if(event==9)

{

OK=!OK;

Cancel:

if(OK==0)

{

HideMouse();

setfillstyle(SOLID_FILL,BLUE);

bar(Ox1,Oy1,Ox2,Oy2);//350,203,405,223);

outtextxy(365,210,"OK");

setfillstyle(SOLID_FILL,LIGHTBLUE);

bar(Cx1,Cy1,Cx2,Cy2);//280,203,337,223);

outtextxy(285,210,"Cancel");

ShowMouse();

}

Ok:

if(OK==1)

{

HideMouse();

setfillstyle(SOLID_FILL,BLUE);

bar(Cx1,Cy1,Cx2,Cy2);//280,203,337,223);

outtextxy(285,210,"Cancel");

setfillstyle(SOLID_FILL,LIGHTBLUE);

bar(Ox1,Oy1,Ox2,Oy2);//350,203,405,223);

outtextxy(365,210,"OK");

ShowMouse();

}

}

if(event==0)

{

event=getch();

if(event==75)

{

OK=0;

goto Cancel;

}

if(event==77)

{

OK=1;

goto Ok;

}

Trang 10

}

else

flushall();

}

if(lpEvent->Msg==1)

{

if(lpEvent->Posx>=Cx1&&lpEvent->Posx<=Cx2&&lpEvent->Posy>=Cy1&&lpEvent->Posy<=Cy2)

{

OK=0;

goto CompleteCancel;

}

if(lpEvent->Posx>=Ox1&&lpEvent->Posx<=Ox2&&lpEvent->Posy>=Oy1&&lpEvent->Posy<=Oy2)

{

OK=1;

goto CompleteOk;

}

}

ShowMouse();

}while(1);

}

XII CLASS SEND.HPP

#include <stdio.h>

#include <conio.h>

#include <dos.h>

#include <MATH.H>

#include <COMPLEX.H>

#include <PROCESS.H>

#include <string.h>

#if !defined SEND

#define SEND

class SEND

{

private:

char OutFile[100];

public:

char *CatFile(char St_add[],char End_add[],char InFile[]);

int Out();

int DeleteFile();//se del OutFile

};

#endif

extern int Esc();

XIII MODULE SEND.CPP

#include "screen.h"

#include "send.hpp"

#define data 0x378

#define sta 0x379

#define ctr 0x37a

char *SEND::CatFile(char St_add[],char End_add[],char InFile[])

{

char

KyTu_Hex[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E ','F','a','b','c','d','e','f'};

int

Gtri_Dec[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15}; unsigned int i,DemSpace;

Ngày đăng: 08/05/2021, 12:17

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm