The program originated from a competition project of my team. The project file is a large project with a lot of content written by other team members. It is not easy for me to post it directly, so I had to capture a small module I wrote and put it up for everyone to share.
This program can mainly realize the two functions of "arbitrary image display" and "arbitrary video playback". The data is transmitted through the serial port (baud rate 4800, Bluetooth or USB are OK). Of course, the data sent can only be the processed image modulus data. (LCD driver is st7920)
After power-on, the following image is displayed directly:
Send 53 FF (sent in hexadecimal) to use the preset for displaying a single image. Then send the modulo data through the serial port to display the image in real time.
After displaying the image, send 01 0E to jump back to the ready state (if you cannot exit, send 01 0E in a timed loop).
If you send 53 53 in the ready state, you can play the video stream. At this time, just send the frame-by-frame modulo code of the video stream through the serial port.
The attached compressed file contains the Bad Apple BIN file I made for your reference.
Since my crystal oscillator is 12MHz, the baud rate is set to 4800, and the actual playback speed is 1 frame/second. You can also change the timer parameters to increase the baud rate.
After the video is finished playing, send 01 0E in the same loop to return to the ready state.
The main function code is shown below, and the other codes are in the attachment.
#include
typedef unsigned int u16; //declare and define data types
typedef unsigned char u8;
#define tbuf 25
u8 RX_buffer[tbuf]={0}; //global string array, serial port receive buffer, used to record information sent by Bluetooth serial port
u8 RX_num=0; //number of characters received by Bluetooth
u8 RX_value=0; //value returned after Bluetooth function processing
#include "delay service.h"
#include "driver of LCD12864.h"
#include "bluetooth.h"
#include "resource.h"
void init()
{
SCON=0X50; //set to working mode 1
TMOD=0X20; //set counter working mode 2
PCON=0X80; //double the baud rate
TH1=0XF3; //set the initial value of the counter, note that the baud rate is 4800
TL1=0XF3;
ES=1; //Open receive interrupt
EA=1; //Open total interrupt
TR1=1; //Open counter
}
void main()
{
init(); //Infrared, Bluetooth initialization
Initialization(); //LCD initialization
Screen_Clear();
while(1)
{
unsigned char j=0,k=0,l=0,m_flag=0;
RX_buffer[1]=0;
Write_Instruction(0x01);
Display_Text(0x80,text16);
Display_Text(0x98,text15);
while(RX_buffer[1]==0);//Condition to jump out of this mode
Write_Instruction(0x01);
if(RX_buffer[1]==0xFF) //Send 0x53 0xXX (XX means any, except 01, FF) for default video playback mode, send 0x53 0xFF for picture display mode
{
m_flag=1;
}
RX_num=1;
while((RX_buffer[1] != 0x01) || (RX_buffer[2] != 0x0E))//Send 0x01 0x0E Exit
{
while((j != 32) || (l != 1))
{
Write_Instruction(0x36);
while(RX_num != 17);
if((RX_buffer[1]==0x01) && (RX_buffer[2])==0x0E) break;
if((l==0) && (j==32))
{
l=1;
j=0;
}
Write_Instruction(0x80+j);
if(l==0)
{
Write_Instruction(0x80);
}
else
{
Write_Instruction(0x88);
}
for(k=1;k<17;k++)
{
Write_Data(RX_buffer[k]);
}
j++;
RX_num=1;
}
if(m_flag==1)
{
RX_buffer[1]=0x01;
RX_buffer[2]=0x0E;
}
j=0;
l=0;
}
RX_num=0;//Receive array index points to instruction bit
RX_buffer[0]=0;
while(RX_buffer[0]==0);
Screen_Clear();
}
}
Previous article:STC15 serial port 1\serial port 2\serial port 3 and serial port 4 source code
Next article:ds1302 driver + lcd12864 serial display, using structure writing, more readable
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Modeling, Control and Digital Implementation of Switching Converters
- MSP430 FRAM Quality and Reliability
- There is a problem in using tlv5616, it's very strange
- The first time I drew a board, I couldn't burn the program into the JTAG after it was made. I cried
- How to generate a .txt file on CCS and burn it to MSP430
- Where can I find development information for the Samsung 4412 processor?
- TMS320C6678 memory access performance
- 4-digit LED digital display meter interfaced with PLC
- About Voltage Follower
- Advantages of combining TI analog devices with DSP