📄 lcd.lst
字号:
236 api_s8GetFont16x16BMP(0, TRUE);
237
C51 COMPILER V7.50 LCD 07/17/2008 14:38:50 PAGE 5
238 while(*str != '\0') {
239 if(n >= lcd_max_str)
240 return;
241
242 if(fontsize == FONTSIZE_8x8) {
243 if(lcd_putc_8x8(x, y, *str++)) {
244 x += 6;
245 n++;
246 }
247 }
248 else
249 {
250 if((fontsize == FONTSIZE_8x16) ||
251 (fontsize == FONTSIZE_HYPER && r1 != 1 && *str <= 0x80))
252 {
253 if(lcd_putc_8x16(x, y, *str++))
254 {
255 x += 8;
256 n++;
257 }
258 continue;
259 }
260 r1 = api_s8GetFont16x16BMP(*str++, FALSE);
261 if(r1 == 0)
262 {
263 if(lcd_putc_16x16(x, y, 0))
264 {
265 x += 16;
266 n += 2;
267 }
268 }
269 }
270 }
271 }
272
273 void lcd_puts_unicode(UINT8 x, UINT8 y, UINT16 *str, UINT8 fontsize)
274 {
275 UINT8 data n;
276 n = 0;
277 while(*str != '\0')
278 {
279 if(n >= lcd_max_str)
280 return;
281
282 if(fontsize == FONTSIZE_8x8)
283 {
284 if(lcd_putc_8x8(x, y, *str++))
285 {
286 x += 6;
287 n++;
288 }
289 }
290 else {
291 if((fontsize == FONTSIZE_8x16) ||
292 (fontsize == FONTSIZE_HYPER && *str <= 0x80))
293 {
294 if(lcd_putc_8x16(x, y, *str++))
295 {
296 x += 8;
297 n++;
298 }
299 continue;
C51 COMPILER V7.50 LCD 07/17/2008 14:38:50 PAGE 6
300 }
301 if(lcd_putc_16x16(x, y, *str++))
302 {
303 x += 16;
304 n += 2;
305 }
306 }
307 }
308 }
309
310 void lcd_clear(void)
311 {
312 UINT8 i;
313
314 lcd_set_rw_area(0, 0, XRES, YRES);
315
316 memset(pixel_buf, 0x0, sizeof(pixel_buf));
317
318 for(i = 0; i < YRES; i++)
319 lcd_put_data((UINT16)pixel_buf, XRES << 1);
320 }
321 void lcd_clear_word(void)
322 {
323 UINT8 i;
324
325 lcd_set_rw_area(50, 74, 54, 80);
326
327 memset(pixel_buf, 0xF77F, sizeof(pixel_buf));
328
329 for(i = 96; i < 102; i++)
330 lcd_put_data((UINT16)pixel_buf, XRES << 1);
331 }
332
333 void lcd_set_brightness(UINT8 v)
334 {
335 #if 1
336 api_vLcdPinSelect();
337 writec(0x2a);
338 writec(0xce+v); //90 0xde c8
339 delay(20);
340 writec(0x2b);
341 writec(0x44+v); //90 0x54 c8
342 api_vLcdPinRecover();
343 #else
api_vLcdPinSelect();
writec(0x2a);
writec(v*8); //90 0xde c8
delay(20);
writec(0x2b);
writec(v*8); //90 0x54 c8
api_vLcdPinRecover();
#endif
352 }
353
354 void lcd_init(void)
355 {
356 // CDIR = 1;
357 // Print("LCD Init\n");
358 api_vLcdInit(LCM_INTERFACE_8080);
359 api_vLcdPinSelect();
360 bLCD_PIN_RESET = 0;
361 delay(100);
C51 COMPILER V7.50 LCD 07/17/2008 14:38:50 PAGE 7
362 bLCD_PIN_RESET = 1;
363
364 delay(100);
365 //-------------------------------------------------
366 writec(0x2C);
367 delay(20);
368 //-------------------------------------------------
369 writec(0x02);
370 writec(0x01);
371 delay(20);
372 //-------------------------------------------------
373 writec(0x26);
374 writec(0x01);
375 delay(20);
376 writec(0x26);
377 writec(0x09);
378 delay(20);
379 writec(0x26);
380 writec(0x0b);
381 delay(20);
382 writec(0x26);
383 writec(0x0f);
384 delay(20);
385 //------------------------------------------------
386 writec(0x10);
387 writec(0x23); // 21,25
388 delay(5);
389 //-------------------------------------------------
390 writec(0x20);
391 writec(0x03); //20
392 delay(20);
393 //-------------------------------------------------
394 writec(0x22);
395 writec(0x11);
396 delay(5);
397 //------------------------------------------------
398 writec(0x24);
399 writec(0x11); //00
400 delay(20);
401 //-------------------------------------------------
402 writec(0x28);
403 writec(0x01);
404 delay(20);
405 /*******************对比度调节****************/
406 writec(0x2a);
407 writec(0xde); //90 0xde c8
408 delay(20);
409 writec(0x2b);
410 writec(0x54); //90 0x54 c8
411 delay(10);
412 /***************************************************/
413 writec(0x30);
414 writec(0x09); //0b
415 delay(20);
416 //------------------------------------------------
417 writec(0x32);
418 writec(0x0E);
419 delay(20);
420 //-----------------------------------------------
421 writec(0x34);
422 writec(0x08);//0d
423 delay(20);
C51 COMPILER V7.50 LCD 07/17/2008 14:38:50 PAGE 8
424 //-------------------------------------------------
425 writec(0x36);
426 writec(0x00);
427 delay(20);
428 /*********************显示模式******************/
429 writec(0x40);
430 writec(0x00);//显示模式08和 00相反 竖屏
431 writec(0x10);
432 writec(0x22);//扫描方式22和26相反 横屏
433 delay(20);
434 /****************************************************/
435 writec(0x43);
436 writec(0x00);
437 writec(0x7F);
438 delay(20);
439 //------------------------------------------------
440 writec(0x42);
441 writec(0x00);
442 writec(0x9F);
443 delay(20);
444 //------------------------------------------------
445 writec(0x53);
446 writec(0x00);
447 delay(20);
448
449
450
451
452
453 //-------------------------------------------------
454 writec(0xEB);
455 delay(20);
456 //-------------------------------------------------
457 writec(0x45);
458 writec(0x00);
459 //-------------------------------------------------
460 writec(0x55);
461 writec(0x00);
462 delay(20);
463 //------------------------------------------------
464 writec(0x5A);
465 writec(0x00);
466 delay(20);
467
468
469
470 //------------------------------------------------
471 writec(0x51);
472 delay(40);
473
474 api_vLcdPinRecover();
475 lcd_set_brightness(10);
476 }
477
C51 COMPILATION COMPLETE. 2 WARNING(S), 1 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -