📄 main.lst
字号:
268 3 DispRam[(y>>3)+1][x+i]=StrAddr[0][i]>>(8-(y%8))|(DispRam[(y>>3)+1][x+i]&(0xFF<<(y%8)));
269 3 DispRam[(y>>3)+1][x+i]=StrAddr[1][i]<<(y%8) |(DispRam[(y>>3)+1][x+i]&(0xFF>>(8-(y%8))));
270 3 DispRam[(y>>3)+2][x+i]=StrAddr[1][i]>>(8-(y%8))|(DispRam[(y>>3)+2][x+i]&(0xFF<<(y%8)));
271 3 }
272 2 }
273 1 }
274 //-----------------------------------------------------------------------------
275
276 void Show_EnglishChar16(unsigned char x,unsigned char y,unsigned char StrAddr[2][8])
277 {
278 1 unsigned char i;
279 1 if((y%8)==0)
280 1 {
281 2 for(i=0;i<8;i++)
282 2 {
283 3 DispRam[y>>3][x+i] =StrAddr[0][i];
284 3 DispRam[(y>>3)+1][x+i]=StrAddr[1][i];
285 3 }
286 2 }
287 1 else
288 1 {
289 2 for(i=0;i<8;i++)
290 2 {
291 3 DispRam[y>>3][x+i] =StrAddr[0][i]<<(y%8) |(DispRam[y>>3][x+i] &(0xFF>>(8-(y%8))));
292 3 DispRam[(y>>3)+1][x+i]=StrAddr[0][i]>>(8-(y%8))|(DispRam[(y>>3)+1][x+i]&(0xFF<<(y%8)));
293 3 DispRam[(y>>3)+1][x+i]=StrAddr[1][i]<<(y%8) |(DispRam[(y>>3)+1][x+i]&(0xFF>>(8-(y%8))));
294 3 DispRam[(y>>3)+2][x+i]=StrAddr[1][i]>>(8-(y%8))|(DispRam[(y>>3)+2][x+i]&(0xFF<<(y%8)));
295 3 }
296 2 }
297 1 }
298 //-----------------------------------------------------------------------------
299 void Show_ChineseChar12(unsigned char x,unsigned char y,unsigned char StrAddr[2][12])
300 {
301 1 unsigned char i;
302 1 if((y%8)==0)
303 1 {
C51 COMPILER V8.08 MAIN 03/09/2008 16:59:57 PAGE 6
304 2 for(i=0;i<12;i++)
305 2 {
306 3 DispRam[y>>3][x+i] =StrAddr[0][i];
307 3 DispRam[(y>>3)+1][x+i]=StrAddr[1][i]|(DispRam[(y>>3)+1][x+i]&(0xFF<<4));
308 3 }
309 2 }
310 1 else
311 1 {
312 2 for(i=0;i<12;i++)
313 2 {
314 3 DispRam[y>>3][x+i] =StrAddr[0][i]<<(y%8) |(DispRam[y>>3][x+i] &(0xFF>>(8-(y%8))));
315 3 DispRam[(y>>3)+1][x+i]=StrAddr[0][i]>>(8-(y%8))|(DispRam[(y>>3)+1][x+i]&(0xFF<<(y%8)));
316 3 DispRam[(y>>3)+1][x+i]=StrAddr[1][i]<<(y%8) |(DispRam[(y>>3)+1][x+i]&(0xFF>>(8-(y%8))));
317 3 DispRam[(y>>3)+2][x+i]=StrAddr[1][i]>>(8-(y%8))|(DispRam[(y>>3)+2][x+i]&(0xFF<<(y%8)));
318 3 }
319 2 }
320 1 }
321
322 //-----------------------------------------------------------------------------
323 void Show_EnglishChar12(unsigned char x,unsigned char y,unsigned char StrAddr[2][6])
324 {
325 1 unsigned char i;
326 1 if((y%8)==0)
327 1 {
328 2 for(i=0;i<6;i++)
329 2 {
330 3 DispRam[y>>3][x+i] =StrAddr[0][i];
331 3 DispRam[(y>>3)+1][x+i]=StrAddr[1][i]|(DispRam[(y>>3)+1][x+i]&(0xFF<<4));
332 3 }
333 2 }
334 1 else
335 1 {
336 2 for(i=0;i<6;i++)
337 2 {
338 3 DispRam[y>>3][x+i] =StrAddr[0][i]<<(y%8) |(DispRam[y>>3][x+i] &(0xFF>>(8-(y%8))));
339 3 DispRam[(y>>3)+1][x+i]=StrAddr[0][i]>>(8-(y%8))|(DispRam[(y>>3)+1][x+i]&(0xFF<<(y%8)));
340 3 DispRam[(y>>3)+1][x+i]=StrAddr[1][i]<<(y%8) |(DispRam[(y>>3)+1][x+i]&(0xFF>>(8-(y%8))));
341 3 DispRam[(y>>3)+2][x+i]=StrAddr[1][i]>>(8-(y%8))|(DispRam[(y>>3)+2][x+i]&(0xFF<<(y%8)));
342 3 }
343 2 }
344 1 }
345 //-----------------------------------------------------------------------------
346 void Draw_Point(unsigned char x,unsigned char y)
347 {
348 1 DispRam[y>>3][x]|=1<<(y%8);
349 1 }
350 //-----------------------------------------------------------------------------
351 void Clear_Point(unsigned char x,unsigned char y)
352 {
353 1 DispRam[y>>3][x]&=~(1<<(y%8));
354 1 }
355 //-----------------------------------------------------------------------------
356 void Circle(unsigned char x,unsigned char y,unsigned char r)
357 {
358 1 float thete;
359 1 for(thete=0;thete<6.28;thete+=0.1)
360 1 {
361 2 Draw_Point(x+(float)r*sin(thete),y+(float)r*cos(thete));
362 2 }
363 1 }
364
365 //-----------------------------------------------------------------------------
C51 COMPILER V8.08 MAIN 03/09/2008 16:59:57 PAGE 7
366 void Line(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1)
367 {
368 1 float k;
369 1 unsigned char i;
370 1 unsigned char Temp;
371 1 if(x0>x1)
372 1 {
373 2 Temp=x0;
374 2 x0=x1;
375 2 x1=Temp;
376 2 }
377 1 if(y0>y1)
378 1 {
379 2 Temp=y0;
380 2 y0=y1;
381 2 y1=Temp;
382 2 }
383 1
384 1 if(x0==x1)
385 1 {
386 2 for(i=y0;i<=y1;i++)
387 2 {
388 3 Draw_Point(x0,i);
389 3 }
390 2 }
391 1
392 1 else if(y0==y1)
393 1 {
394 2 for(i=x0;i<=x1;i++)
395 2 {
396 3 Draw_Point(i,y0);
397 3 }
398 2 }
399 1 else
400 1 {
401 2 k=(y1-y0)/(x1-x0);
402 2 for(i=x0;i<x1;i++)
403 2 {
404 3 Draw_Point(i,i*k);
405 3 }
406 2 }
407 1 }
408
409
410 //-----------------------------------------------------------------------------
411 void Oscillator_Init (void)
412 {
413 1 OSCICN = 0x87; // Configure internal oscillator for
414 1 RSTSRC = 0x40; // Enable missing clock detector
415 1 }
416
417 //-----------------------------------------------------------------------------
418
419 void Port_Init (void)
420 {
421 1 P0MDIN = 0xFF;
422 1 P0SKIP = 0x00;
423 1 P0MDOUT= 0xFF;
424 1
425 1 P1MDIN = 0xFF;
426 1 P1SKIP = 0x00;
427 1 P1MDOUT= 0xFF;
C51 COMPILER V8.08 MAIN 03/09/2008 16:59:57 PAGE 8
428 1
429 1 P2MDIN = 0xFF;
430 1 P2SKIP = 0x00;
431 1 P2MDOUT= 0xFF;
432 1
433 1 P0=0xFF;
434 1 P1=0xFF;
435 1 P2=0xFF;
436 1
437 1 XBR0 = 0x00;
438 1 XBR1 = 0x40;
439 1
440 1 }
441 //-----------------------------------------------------------------------------
442 void Timer2_Init (void)
443 {
444 1 TMR2CN = 0x00; // Stop Timer2; Clear TF2;
445 1 // use SYSCLK as timebase, 16-bit
446 1 // auto-reload
447 1 CKCON |= 0x10; // Select SYSCLK for timer 2 source
448 1 TMR2RL = 65535 - (SYSCLK /10000); // Init reload value for 100 us
449 1 TMR2 = 0xffff; // Set to reload immediately
450 1 ET2 = 1; // Enable Timer2 interrupts
451 1 TR2 = 1; // Start Timer2
452 1 }
453 /*----------------------------------------------------------------------------------------------*/
454
455 void Timer2_ISR (void) interrupt 5
456 {
457 1 TF2H = 0;
458 1 // Clear Timer2 interrupt flag
459 1 UpData_LCD(DispRam);
460 1 }
461
462 //-----------------------------------------------------------------------------
463 // MAIN Routine
464 //-----------------------------------------------------------------------------
465
466 void main (void)
467 {
468 1 PCA0MD &=~0x40; // WDTE = 0 (clear watchdog timerenable)
469 1 Oscillator_Init (); // Initialize system clock to
470 1 Port_Init (); // Initialize crossbar and GPIO
471 1
472 1 memset(DispRam,0x00,1024*sizeof(unsigned char));
473 1
474 1
475 1
476 1
477 1 Timer2_Init ();
478 1
479 1 Clear_LCD();
480 1 Show_ChineseChar16(16,0,Zhongguo);
481 1 Show_ChineseChar16(16,16,Zhongguo);
482 1 Show_ChineseChar16(16,32,Zhongguo);
483 1 Show_ChineseChar16(16,40,Zhongguo);
484 1 Show_ChineseChar16(32,31,Zhongguo);
485 1 Show_ChineseChar16(80,31,Zhongguo);
486 1
487 1 Show_EnglishChar16(50,0,Eight);
488 1 Show_EnglishChar16(50,16,Eight);
489 1 Show_EnglishChar16(50,31,Eight);
C51 COMPILER V8.08 MAIN 03/09/2008 16:59:57 PAGE 9
490 1
491 1 Show_ChineseChar12(65,0,Zhongguo12);
492 1 Show_ChineseChar12(65,12,Zhongguo12);
493 1 Show_ChineseChar12(65,31,Zhongguo12);
494 1
495 1 Show_EnglishChar12(80,0,Five);
496 1 Show_EnglishChar12(80,12,Five);
497 1 Show_EnglishChar12(80,25,Five);
498 1
499 1 Line(10,10,100,60);
500 1 Draw_Point(20,50);
501 1 Circle(50,30,25);
502 1 Clear_Point(70,32);
503 1
504 1
505 1 EA=1;
506 1
507 1 //LCD_Delay(255); //Delay
508 1
509 1 while(1)
510 1 {
511 2
512 2
513 2 // gotoxy(0,0);
514 2 // Display_LCD_NumberAB(2);
515 2 // gotoxy(0,2);
516 2 // Display_LCD_NumberB(5);
517 2 // gotoxy(5,4);
518 2 // Display_LCD_string(Zhongguo,2);
519 2 // gotoxy(64,4);
520 2 // Display_LCD_Data(digit[1]);
521 2 // gotoxy(72,4);
522 2 // Display_LCD_Data(digit[2]);
523 2 }
524 1 }
525
526 //-----------------------------------------------------------------------------
527
528
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 3964 ----
CONSTANT SIZE = 474 ----
XDATA SIZE = 1024 ----
PDATA SIZE = ---- ----
DATA SIZE = 2 46
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -