// Printing specification (16×16 dot matrix), the printer executes the microcontroller n-dot paper moving instruction: 0x1B-0x4A-n. Move forward n dot lines, the value of n is between 1-255.
// Set the n-dot line spacing: 0x1B-0x31-n. The value of n is between 0-255,
// When using the ESC/K command to print dot matrix graphics, usually set n=0. When printing text, usually set n=3.
//-----------------------Function declaration--------------------------------------------------------
#include"stdio.h"
#include"absacc.h"
#include"reg51.h"
//-----------------------LCD interface pin declaration---------------------------------------------------------
sbit STB=P3^0; //Output, read data at the rising edge of the data strobe trigger pulse.
sbit BUSY=P3^1; //Input, "high" means the printer is "busy" and cannot receive data. sbit ACK=
P3^2; //Input, the "low" level of the acknowledge pulse indicates that the data has been received and is ready to receive the next data.
sbit ERR=P3^3; //Input, pull up to "high" level through a resistor, indicating that the printer has no fault.
sbit SEL=P3^4; //Input, pull up to "high" level through a resistor, indicating that the printer is online.
#define DATA_OUT P1 //P1 is the data port
bit printer_ERR=0; //Printer fault flag: 0 means normal, 1 means fault
bit printer_online=1; //Printer first flag: 1 means online, 0 means offline
#define check_ERR() printer_ERR=~ERR //Check if the printer has an error
#define check_online() printer_online=SEL //Check if the printer is online
//-----------------------Define each command word--------------------------------------------------------
#define printer_init() SEND_2BYTE(0x1B,0x40) //Initialize the printer
#define enter_hangzimode() SEND_2BYTE(0x1C,0x26) //Enter Chinese character printing command: 0x1C-0x26.
#define exit_hangzimode() SEND_2BYTE(0x1C,0x2E) //Exit Chinese character printing command: 0x1C-0x2E.
#define setting_LARGEhz() SEND_2BYTE(0x1C,0x0E) //The printed Chinese characters will be doubled in the horizontal direction, and the vertical direction will not be changed.
#define cancel_LARGEhz() SEND_2BYTE(0x1C,0x14) //Cancel double-width printing of Chinese characters:.
#define select_muster1() SEND_2BYTE(0x1B,0x36) //Select character set 1:.
#define select_muster2() SEND_2BYTE(0x1B-0x37) //Select character set 2:.
#define change_row() SEND_BYTE(0x0A) //Line break:.
#define change_page() SEND_BYTE(0xOC) //Page break:.
#define made_CZtable() SEND_BYTE(0x0B) //Execute vertical table making: 0x0B.
#define made_SPtable() SEND_BYTE(0x09) //Execute horizontal table making: 0x0B.
#define setting_rowLG() SEND_BYTE(0x0E) //Double width printing in a row: 0x0E.
#define cancel_rowLG() SEND_BYTE(0x14) //Cancel double width printing in a row: 0x14.
#define renew_char_set() SEND_2BYTE(0x1B,0x3A) //Restore characters in the character set: 0x1B-0x3A.
#define enter() SEND_BYTE(0x0D) //Enter: 0x0D.
#define delete_row() SEND_BYTE(0x18) //Delete a row: 0x18.
#define delete_byte() SEND_BYTE(0x7F) //Delete a byte: 0x7F.
#define execute_NULL() SEND_BYTE(00) //(4) NULL: 00.
//Set Chinese character dot matrix printing specifications (16×16 dot matrix): 0x1C-0x69-n
//Set Chinese character dot matrix: n=0, 16×16 dot matrix
//n=1, 8×16 dot matrix?
//n=2, 16×8 dot matrix
//n=3, 8×8 dot matrix.
#define setting_HZmode(n) SEND_2BYTE(0x1C,0x69);SEND_BYTE(n)
//Execute n-dot paper walking: 0x1B-0x4A-n. Go forward n dot rows, the value of n is in the range of 1-255.
#define goahead_nrow(n) SEND_2BYTE(0x1B,0x4A);SEND_BYTE(n)
//Set n-dot line spacing: 0x1B-0x31-n. The value of n is between 0 and 255.
//When using the ESC/K command to print dot matrix graphics, n=0 is usually set. When printing text, n=3 is usually set.
#define setting_rowgap(n) SEND_2BYTE(0x1B,0x31);SEND_BYTE(n)
//--------------------------------------------------------------------------------------------------
// Function name: SEND_BYTE
// Entry parameter: ndata
// Function function: Send 1BYTE data
//--------------------------------------------------------------------------------------------------
void SEND_BYTE(unsigned char ndata)
{
STB=1;
while(BUSY);
DATA_OUT=ndata;
STB=0;
STB=1;
}
Previous article:Principles of Hardware Circuit Design for Single Chip Microcomputer Application System
Next article:STC MCU IO pin damage dynamic self-test program
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- LM358 board test results are different from simulation
- [NXP Rapid IoT Review] Easy to use
- MSP430F5438A Wireless Upgrade
- Those who work on 48V systems should take a look: This company's latest solution is worth a look. At least 9 of its devices are in a car.
- EEWORLD University Hall----Gate drive considerations for low frequency and DC operation
- How can cadence simulation achieve a pulse source with two different pulse widths in one cycle?
- Modbus Communication Protocol
- Xunwei 3399 development board adds target detection technology-RKSSD-compiler
- Share: TMS320F28335 project development record 9_28335 interrupt system
- The main functions of the engineering safety black box have been completed