
unit ram
{
	public link unit RS {}
	public link unit RW {}
	public link unit E {}
	
	command.RS = RS;
	command.RW = RW;
	command.E = E;
	command =
	#include "command.txt"


	//[i] interface_map map;
	public unit map
	{
		link int8 AreaNumber;
		link int16 LineNumber;
		link uint8 BackData;
		link uint8 ClearData;
		link int16 WTXN;
		link int16 RTXN;
		link [uint16*64] TBuffer;
		link void Clear() {}
		link void set_uint8( int16 Line, int16 area, uint16 d ) {}
		link uint16 get_uint8( int16 Line, int16 area ) {}
		public const int8 TYPE = 2;
	}
	map.AreaNumber = AreaNumber;
	map.LineNumber = LineNumber;
	map.BackData = BackData;
	map.ClearData = ClearData;
	map.WTXN = WTXN;
	map.RTXN = RTXN;
	map.TBuffer = TBuffer;
	map.set_uint8 = print_line;
	map.get_uint8 = get_uint16;
	map.Clear = clear;
	
	//[i] var_int8 AreaNumber;
	public const int8 AreaNumber = 8;
	//[i] var_int16 LineNumber;
	public const int16 LineNumber = 64;
	//[i] var_uint8 BackData;
	public uint8 BackData;
	//[i] var_uint8 ClearData;
	public uint8 ClearData;

	[uint16*64] TBuffer;
	int16 WTXN;
	int16 RTXN;
	//---------------------------------------------------
	//[i] function_void OS_init;
	public void OS_init()
	{
		command.OS_init();
		clear();
	}
	//---------------------------------------------------
	//清空
	//[i] function_void clear;
	public void clear()
	{
		uint8 addr = 0x80;
		loop( 32 ) {
			command.write_command( addr );
			command.write_command( 0x80 );
			loop( 32 ) {
				command.write_data( 0x00 );
			}
			addr + 1;
		}
	}
	//---------------------------------------------------
	//第 n 行显示
	//[i] function_void print_line int32 int32 int32;
	public void print_line( int16 y, int16 x, uint16 data )
	{
		if( x == WTXN ) {
			TBuffer[y] = data;
		}
		//先转换坐标
		if( y >= 32 ) {
			y - 32;
			x + 8;
		}
		command.write_command( 0x80 + (uint8)(uint)y );
		command.write_command( 0x80 + (uint8)(uint)x );
		command.write_data( data.8(uint8) ); //先发送高字节
		command.write_data( data.0(uint8) ); //再发送低字节
	}
	
	uint16 get_uint16( int16 y, int16 x )
	{
		//if( x == RTXN ) {
		//	return TBuffer[y];
		//}
		return 0;
	}
}












