//
// LCD.c
// is the detail of how to use LCD 1602A on TX-1C platform
// the common end of them is negative.
// ------> Usage, only for parameter "display_mode"
#define LCD_DISPLAY_DEFAULT 0x0E
#define LCD_DISPLAY_ON 0x0C
#define LCD_CURSOR_ON 0x0A
#define LCD_CURSOR_FLASH 0x09
// Usage, only for parameter "cursor_movement"
#define LCD_CURSOR_MOVE_DEFAULT 0x06
extern void LCD__show_char( unsigned char content, unsigned char LnSeq, unsigned char ColSeq );
extern void LCD__display( unsigned char content_LtoR[], unsigned char LnSeq, unsigned char ColSeq );
extern void LCD__clear_screen( );
extern unsigned char LCD__get_cursor__line_serial( );
extern unsigned char LCD__get_cursor__column_serial( );
extern void LCD__display_mode__toggle( unsigned char display_mode, unsigned char cursor_movement );
extern void LCD__cursor_move( unsigned char ln_serial, unsigned char col_serial );
// ** !!! NOTICE !!! this library will affect "P0.0" to "P0.7", "P2.6", "P2.7", "P3.4", "P3.5" ports
// Add functions ( both inline and separate ):
// "LCD__PORT_EN__HIGH_PULZE",
// "LCD__check_and_initialize",
// "LCD__write_command",
// "LCD__write_data",
// "LCD__show_char" ** extern
// "LCD__display" ** extern
// "LCD__clear_screen" ** extern
// "LCD__get_cursor__line_serial" ** extern
// "LCD__get_cursor__column_serial" ** extern
// "LCD__cursor_mode_toggle" ** extern
// "LCD__cursor_move" ** extern
// "LCD_1602A_initialize"
// on 03:15 PM 28/JUN/2017 (UTC+8)
//
//***********************************************************************************************************
//***********************************************************************************************************
//***********************************************************************************************************
//
// ** !!! NOTICE !!! **
// The current version of LCD Library is not ready to cooperate with Roll Screen ops !!!!!!!
//
//***********************************************************************************************************
//***********************************************************************************************************
//***********************************************************************************************************
#include <reg52.h>
#include "TX-1C.h"
// Function prototype needed
// LCD__INTERNAL_IMPLEMENTATION
void LCD_1602A_initialize(); // Mind this crucial guy~!
//
// Mind!! Serial or Sequence number = ID number + 1
unsigned char LCD_GLOBAL__current_screen_cursor__line_id = 0x00;
unsigned char LCD_GLOBAL__current_screen_cursor__column_id = 0x00;
unsigned char LCD_GLOBAL__FLAG__is_LCD_initialized = 0;
unsigned char LCD_GLOBAL__FLAG__is_LCD_data_pointer_autoincrement_plus = 1;
#define LCD__PORT_RS__DATA 1
#define LCD__PORT_RS__COMMAND 0
//#define LCD__PORT_RW__READ 1 // This is cancelled by TX-1C because Port 5 RW is forced to be 0
//#define LCD__PORT_RW__WRITE 0 // This is cancelled by TX-1C because Port 5 RW is forced to be 0
// ------------------------------------------------------------------------------
// TX-1C Platform is USB powered(weak), so we need to disable the Digit Cubes first.
sbit dula = P2^6; // 1st 74HC573, select which to show on cubes.
sbit wela = P2^7; // 2nd 74HC573, select what to show on cubes.
sbit lcden = P3^4; // LCD Port 6 EN: Enable, need pulze.
sbit lcdrs = P3^5; // LCD Port 4 RS: select data/command, please use macro
///////////////////////////////////////////////////////////////////////////////////////
// Inline Give EN a High Pulze, long enough to let LCD "1602A" be available
// Approximately 5ms
// LCD__INTERNAL_IMPLEMENTATION
#define LCD__PORT_EN__HIGH_PULZE(); { lcden=1; delay(5); lcden=0;}
///////////////////////////////////////////////////////////////////////////////////////
// Inline Give LCD commands.
// LCD__INTERNAL_IMPLEMENTATION
#define LCD__check_and_initialize(); { if ( !LCD_GLOBAL__FLAG__is_LCD_initialized ) LCD_1602A_initialize();}
///////////////////////////////////////////////////////////////////////////////////////
// Inline Give LCD commands.
// LCD__INTERNAL_IMPLEMENTATION
#define LCD__write_command( com_id );\
{\
unsigned char temp_P0 = P0;\
lcdrs = LCD__PORT_RS__COMMAND;\
P0 = com_id;\
delay(5);\
LCD__PORT_EN__HIGH_PULZE();\
P0 = temp_P0;\
}
///////////////////////////////////////////////////////////////////////////////////////
// Inline Give LCD data.
// LCD__INTERNAL_IMPLEMENTATION
#define LCD__write_data( num );\
{\
unsigned char temp_P0 = P0;\
lcdrs = LCD__PORT_RS__DATA;\
P0 = num;\
delay(5);\
LCD__PORT_EN__HIGH_PULZE();\
P0 = temp_P0;\
}
///////////////////////////////////////////////////////////////////////////////////////
// LCD__show_char
//
// TODO: Single character display
// Param: @1: character to be shown
// @2: where to show, Line sequence 1st ~ 2nd limited, (= 1 to 2 ) decimally
// @3: where to show, column sequence 1st ~ 16th limited, (= 1 to 16 ) decimally
// Return: Nothing.
//
// Note! '~' cannot be displayed !!!!
// *** ---> !!! Side Effect: Unknown or Non-existing
///////////////////////////////////////////////////////////////////////////////////////
extern void LCD__show_char( unsigned char content, unsigned char LnSeq, unsigned char ColSeq )
{
LCD__check_and_initialize( );
// TODO: Security Check: if access violation ? if so, abort current ops.
if ( !content || !( 1 <= LnSeq && 2 >= LnSeq) || !(1 <= ColSeq && 16>= ColSeq ) ) return ;
LCD__cursor_move( LnSeq, ColSeq );
LCD__write_data( content );
LCD_GLOBAL__current_screen_cursor__column_id++;
}
///////////////////////////////////////////////////////////////////////////////////////
// LCD__display
//
// TODO: auto-increment=plus display information
// Param: @1: The contents( left to right, '\0' terminated ) array to be displayed on cubes.
// @2: where to show, Line sequence 1st ~ 2nd limited, (= 1 to 2 ) decimally
// @3: where to show, column sequence 1st ~ 16th limited, (= 1 to 16 ) decimally
// Return: Nothing.
//
// Note! '~' cannot be displayed !!!!
// *** ---> !!! Side Effect: Unknown or Non-existing
///////////////////////////////////////////////////////////////////////////////////////
extern void LCD__display( unsigned char content_LtoR[], unsigned char LnSeq, unsigned char ColSeq )
{
unsigned char counter;
LCD__check_and_initialize( );
// TODO: Security Check: if access violation ? if so, abort current ops.
if ( !content_LtoR || !( 1 <= LnSeq && 2 >= LnSeq) || !(1 <= ColSeq && 16>= ColSeq ) ) return ;
LCD__cursor_move( LnSeq, ColSeq );
// TODO: write da
LCD.zip_1602a_单片机_液晶屏
版权申诉
66 浏览量
2022-09-20
23:12:37
上传
评论
收藏 3KB ZIP 举报
APei
- 粉丝: 63
- 资源: 1万+
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈