当前位置:网站首页>Blue Bridge Cup SCM digital tube skills
Blue Bridge Cup SCM digital tube skills
2022-07-02 03:37:00 【Super 561】
How to use nixie tube
1 How to use the nixie tube with the key switch interface to display the switch interface
Method : Define a variable to display the display interface ; Press the key to change the value of the variable ; So as to switch the display interface .
#include <STC15F2K60S2.H>
void Device_ctrl(unsigned char p2date,unsigned char p0date)// Latch control function
{
P0=p0date;
P2=(P2&0X1F)|p2date;
P2&=0X1F;
}
unsigned char smg_count;
unsigned char smg_display[8];
unsigned char smg_du[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};// Common anode segment code
unsigned char display_mode;// Interface display
void smg_show()
{
unsigned int i;
Device_ctrl(0xc0,0);
Device_ctrl(0xe0,~smg_display[i]);
Device_ctrl(0xc0,0x01<<i);
i=(i+1)%8;
}
void smg_process()
{
if(smg_count>3)
{
smg_count=0;
if(display_mode==0)// Show the first interface
{
smg_display[0]=smg_du[0];
smg_display[1]=smg_du[1];
smg_display[2]=smg_du[2];
smg_display[3]=smg_du[3];
smg_display[4]=smg_du[4];
smg_display[5]=smg_du[5];
smg_display[6]=smg_du[6];
smg_display[7]=smg_du[7];
}
if(display_mode==1)// Display the second interface
{
smg_display[0]=smg_du[1];
smg_display[1]=smg_du[2];
smg_display[2]=smg_du[3];
smg_display[3]=smg_du[4];
smg_display[4]=smg_du[5];
smg_display[5]=smg_du[6];
smg_display[6]=smg_du[7];
smg_display[7]=smg_du[8];
}
}
}
unsigned char trig_btn;
unsigned char con_btn;
unsigned int key_count;
void key_btn()// Key scan function
{
unsigned char readdate=P3^0xff;
trig_btn=readdate&(con_btn^0xff);
con_btn=readdate;
}
void key_process()// Key handling functions
{
if(key_count>10)// Scan the keys every ten milliseconds
{
key_count=0;
key_btn();
if(trig_btn==0x08)// Key s4
{
display_mode++;
if(display_mode==2)// Switch interface 0 1
{
display_mode=0;
}
}
}
}
void Timer2Init() //1 millisecond @12.000MHz
{
AUXR &= 0xFB; // Timer clock 12T Pattern
T2L = 0x18; // Set initial value of timing
T2H = 0xFC; // Set initial value of timing
AUXR |= 0x10; // Timer 2 Start timing
IE2|=0x04;
EA=1;
}
void main()
{
Timer2Init();
Device_ctrl(0x80,0xff);
while(1)
{
smg_process();
key_process();
}
}
void service_timer2() interrupt 12
{
smg_count++;
key_count++;
smg_show();
}2 How to make the nixie tube data turn on and off in one second
Set a one second timer in the timer ; Then use a flag bit to display , If you let the nixie tube light up in one second, it will go out in one second .
#include <STC15F2K60S2.H>
void Device_ctrl(unsigned char p2date,unsigned char p0date)
{
P0=p0date;
P2=(P2&0X1F)|p2date;
P2&=0X1F;
}
unsigned char smg_count;
unsigned char smg_display[8];
unsigned char smg_du[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char display_mode;
void smg_show()
{
unsigned int i;
Device_ctrl(0xc0,0);
Device_ctrl(0xe0,~smg_display[i]);
Device_ctrl(0xc0,0x01<<i);
i=(i+1)%8;
}
bit smg_blink;
void smg_process()
{
if(smg_count>3)
{
smg_count=0;
if(smg_blink)
{
smg_display[0]=smg_du[0];
smg_display[1]=smg_du[1];
smg_display[2]=smg_du[2];
smg_display[3]=smg_du[3];
smg_display[4]=smg_du[4];
smg_display[5]=smg_du[5];
smg_display[6]=smg_du[6];
smg_display[7]=smg_du[7];
}
else
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=0x00;
smg_display[4]=0x00;
smg_display[5]=0x00;
smg_display[6]=0x00;
smg_display[7]=0x00;
}
}
}
void Timer2Init() //1 millisecond @12.000MHz
{
AUXR &= 0xFB; // Timer clock 12T Pattern
T2L = 0x18; // Set initial value of timing
T2H = 0xFC; // Set initial value of timing
AUXR |= 0x10; // Timer 2 Start timing
IE2|=0x04;
EA=1;
}
void main()
{
Timer2Init();// Timer initialization
Device_ctrl(0x80,0xff);
while(1)
{
smg_process();
}
}
void service_timer2() interrupt 12// Timer uses function
{
unsigned int time_count;// Timer timing variable
time_count++;
if(time_count>1000)// Timed for a second
{
time_count=0;
smg_blink=!smg_blink;
}
smg_count++;
smg_show();
}3 The nixie tube displays useful data , Off if not displayed .
Method : Judge according to the ten hundreds and thousands
#include <STC15F2K60S2.H>
void Device_ctrl(unsigned char p2date,unsigned char p0date)
{
P0=p0date;
P2=(P2&0X1F)|p2date;
P2&=0X1F;
}
unsigned char smg_count;
unsigned char smg_display[8];
unsigned char smg_du[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char display_mode;
unsigned int number=12345;
void smg_show()
{
unsigned int i;
Device_ctrl(0xc0,0);
Device_ctrl(0xe0,~smg_display[i]);
Device_ctrl(0xc0,0x01<<i);
i=(i+1)%8;
}
void smg_process()
{
if(smg_count>3)
{
smg_count=0;
if(number>9999)// If it is greater than 9999
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=smg_du[number/10000];
smg_display[4]=smg_du[number/1000%10];
smg_display[5]=smg_du[number/100%10];
smg_display[6]=smg_du[number/10%10];
smg_display[7]=smg_du[number%10];
}
else if(number>999) // If it is greater than 999
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=0x00;
smg_display[4]=smg_du[number/1000%10];
smg_display[5]=smg_du[number/100%10];
smg_display[6]=smg_du[number/10%10];
smg_display[7]=smg_du[number%10];
}
else if(number>99)// If it is greater than 99
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=0x00;
smg_display[4]=0x00;
smg_display[5]=smg_du[number/100%10];
smg_display[6]=smg_du[number/10%10];
smg_display[7]=smg_du[number%10];
}
else if(number>9)// If it is greater than 9
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=0x00;
smg_display[4]=0x00;
smg_display[5]=0x00;
smg_display[6]=smg_du[number/10%10];
smg_display[7]=smg_du[number%10];
}
else
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=0x00;
smg_display[4]=0x00;
smg_display[5]=0x00;
smg_display[6]=0x00;
smg_display[7]=smg_du[number%10];
}
}
}
void Timer2Init() //1 millisecond @12.000MHz
{
AUXR &= 0xFB; // Timer clock 12T Pattern
T2L = 0x18; // Set initial value of timing
T2H = 0xFC; // Set initial value of timing
AUXR |= 0x10; // Timer 2 Start timing
IE2|=0x04;
EA=1;
}
void main()
{
Timer2Init();// Timer initialization
Device_ctrl(0x80,0xff);
while(1)
{
smg_process();
}
}
void service_timer2() interrupt 12// Timer uses function
{
smg_count++;
smg_show();
}边栏推荐
- 焱融看 | 混合雲時代下,如何制定多雲策略
- PHP array processing
- 焱融看 | 混合云时代下,如何制定多云策略
- 微信小程序中 在xwml 中使用外部引入的 js进行判断计算
- Global and Chinese markets for infant care equipment, 2022-2028: Research Report on technology, participants, trends, market size and share
- VS2010插件NuGet
- JS generate random numbers
- Detailed explanation of the difference between Verilog process assignment
- Which of PMP and software has the highest gold content?
- Kotlin基础学习 15
猜你喜欢

JIT deep analysis

高性能 低功耗Cortex-A53核心板 | i.MX8M Mini

How to establish its own NFT market platform in 2022

蓝桥杯单片机省赛第八届

蓝桥杯单片机省赛第六届

Learn PWN from CTF wiki - ret2shellcode

Kubernetes cluster storageclass persistent storage resource core concept and use
![[yolo3d]: real time detection of end-to-end 3D point cloud input](/img/5e/f17960d302f663db75ad82ae0fd70f.jpg)
[yolo3d]: real time detection of end-to-end 3D point cloud input

Exchange rate query interface

Screenshot literacy tool download and use
随机推荐
Comment élaborer une stratégie nuageuse à l'ère des nuages mixtes
Basic syntax of unity script (7) - member variables and instantiation
leetcode-1380. Lucky number in matrix
halcon图像矫正
The page in H5 shows hidden execution events
傅里叶级数
In depth analysis of C language - variable error prone knowledge points # dry goods inventory #
aaaaaaaaaaaaa
Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
Kotlin basic learning 13
aaaaaaaaaaaaa
数据库文件逻辑结构形式指的是什么
Learn PWN from CTF wiki - ret2shellcode
Docker installs canal and MySQL for simple testing and implementation of redis and MySQL cache consistency
Screenshot literacy tool download and use
VS2010插件NuGet
Kotlin basic learning 15
Kotlin basic learning 16
PY3, PIP appears when installing the library, warning: ignoring invalid distribution -ip
PY3 link MySQL