当前位置:网站首页>[a complete human-computer interface program framework]
[a complete human-computer interface program framework]
2022-06-27 13:37:00 【weixin_ forty-eight million two hundred and thirteen thousand e】
The program functions are as follows :
(1) The first four digits of the nixie tube can be switched 3 A window ,1-XX,2-YY,3-ZZ,XX,YY,ZZ Represent the 3 Editable data Gu8SetDate_1,Gu8SetDate_2,Gu8SetDate_3, Data range 0-99;
(2) Key 1 There are short press and long press functions . Long press and hold the third or fourth digital tube to flash , Short press again to switch between three or four nixie tubes ; Press and hold again without flashing , Show 3 One of the windows , Short press to switch between the three windows ;
(3) Key 2, Accumulate under flashing conditions
(4) Key 3, Decrease in turn under flashing conditions
Full screen update and local update are used in window switching .( This framework is worth studying )
#include "REG52.H"
#define KEY_FILTER_TIME 25 // Button “ Short press ” and “ wave filtering ” Of “ Stabilization time ”
#define KEY_LONG_TIME 500 // Button “ Long press ” and “ wave filtering ” Of “ Stabilization time ”
#define SCAN_TIME 1
#define VOICE_TIME 50
#define BLINK_TIME 250 // The interval of time when the nixie tube flickers
void T0_time();
void SystemInitial(void) ;
void Delay(unsigned long u32DelayTime) ;
void PeripheralInitial(void) ;
void KeyScan(void);
void KeyTask(void);
void VoiceScan(void);
void DisplayScan(void);
void DisplayTask(void); // Task functions displayed on the upper layer
void Wd1(void); // window 1 Show function
void Wd2(void); // window 2 Show function
void Wd3(void); // window 3 Show function
void PartUpdate(unsigned char u8Part); // A local variable corresponding to the local selection updates the display output
void BeepOpen(void);
void BeepClose(void);
sbit KEY_INPUT1=P3^4; // Three buttons
sbit KEY_INPUT2=P3^5;
sbit KEY_INPUT3=P3^6;
sbit P0_0=P0^0; // Common end of six nixie tubes
sbit P0_1=P0^1;
sbit P0_2=P0^2;
sbit P0_3=P0^3;
sbit P0_4=P0^4;
sbit P0_5=P0^5;
sbit beep=P2^3;// Buzzer
sbit dula=P2^6;
sbit wela=P2^7;// Control the segment selection and bit selection of the two latches of the nixie tube
// Digital tube conversion table
code unsigned char Cu8DigTable[]=
{
0x3f, //0 Serial number 0
0x06, //1 Serial number 1
0x5b, //2 Serial number 2
0x4f, //3 Serial number 3
0x66, //4 Serial number 4
0x6d, //5 Serial number 5
0x7d, //6 Serial number 6
0x07, //7 Serial number 7
0x7f, //8 Serial number 8
0x6f, //9 Serial number 9
0x00, // No display Serial number 10
0x40, // Horizontal bar - Serial number 11
};
volatile unsigned char vGu8ScanTimerFlag=0;
volatile unsigned int vGu16ScanTimerCnt=0;
volatile unsigned char vGu8BeepTimerFlag=0;
volatile unsigned int vGu16BeepTimerCnt=0;
volatile unsigned char vGu8BlinkTimerFlag=0; // A timer with a flashing digital tube
volatile unsigned int vGu16BlinkTimerCnt=0;
unsigned char Gu8SetData_3=0; // SCM internal No 3 Editable parameters , At the window 3
unsigned char Gu8SetData_2=0; // SCM internal No 2 Editable parameters , At the window 2
unsigned char Gu8SetData_1=0; // SCM internal No 1 Editable parameters , At the window 1
/* Note one : * In the program framework of man-machine interface , There is often a need to “ position ” To edit some data , This situation * It's actually... First “ Data to be edited ” Break down into several “ position ” Temporary intermediate , Then display and edit these “ position ” * Temporary intermediate , After editing , And then put these “ position ” Temporary intermediate individuals are merged into a complete data assignment to * “ Data to be edited ”. following Gu8EditData_2 and Gu8EditData_1 Namely “ position ” Intermediate variables of temporary intermediate individuals . */
unsigned char Gu8EditData_2=0; // The... From the left is displayed correspondingly 3 Bit digital tube “ position ” data , It's the intermediate variable .
unsigned char Gu8EditData_1=0; // The... From the left is displayed correspondingly 4 Bit digital tube “ position ” data , It's the intermediate variable .
unsigned char Gu8Wd=1; // Window select variables . The fulcrum of human-computer interaction program framework . After initializing the power on, the... Will be displayed 1 A window .
unsigned char Gu8WdUpdate=1; // Full screen update variables . Initialize to 1 The display will be updated once the whole screen is turned on .
unsigned char Gu8Part=0; // Local selection variables .0 It means that no data is selected under the current window .
unsigned char Gu8PartUpdate_1=0; // Local 1 Update variables for ,
unsigned char Gu8PartUpdate_2=0; // Local 2 Update variables for
volatile unsigned char vGu8Display_Righ_4=1; // From the left 1 Bit initialization display window “1”
volatile unsigned char vGu8Display_Righ_3=11; // From the left 2 Bit initialization display bar “-”
volatile unsigned char vGu8Display_Righ_2=0; // From the left 3 Bit initialization display value “0”
volatile unsigned char vGu8Display_Righ_1=0; // From the left 4 Bit initialization display value “0”
// Don't show decimal
volatile unsigned char vGu8Display_Righ_Dot_4=0;
volatile unsigned char vGu8Display_Righ_Dot_3=0;
volatile unsigned char vGu8Display_Righ_Dot_2=0;
volatile unsigned char vGu8Display_Righ_Dot_1=0;
volatile unsigned char vGu8KeySec=0;
void main()
{
SystemInitial();
Delay(10000);
PeripheralInitial();
while(1)
{
KeyTask(); // The task function of the key
DisplayTask(); // The upper task function of nixie tube display
}
}
void PartUpdate(unsigned char u8Part) // A local variable corresponding to the local selection updates the display output
{
switch(u8Part)
{
case 1:
Gu8PartUpdate_1=1;
break;
case 2:
Gu8PartUpdate_2=1;
break;
}
}
void KeyTask(void) // The task function of the key
{
if(0==vGu8KeySec)
{
return;
}
switch(vGu8KeySec)
{
case 1: //K1 Button “ Short press ”, have “ Switch windows ” and “ Switch local ” The dual function of .
if(0==Gu8Part) // be in “ No flicker ” When , yes “ Switch windows ”
{
switch(Gu8Wd) // Under a window
{
case 1: // At the window 1 Next
Gu8Wd=2; // Switch to window 2
Gu8EditData_2=Gu8SetData_2/10%10; //“ Data to be edited ” Break down into intermediate individuals
Gu8EditData_1=Gu8SetData_2/1%10; //“ Data to be edited ” Break down into intermediate individuals
Gu8WdUpdate=1; // Full screen update
break;
case 2: // At the window 2 Next
Gu8Wd=3; // Switch to window 3
Gu8EditData_2=Gu8SetData_3/10%10; //“ Data to be edited ” Break down into intermediate individuals
Gu8EditData_1=Gu8SetData_3/1%10; //“ Data to be edited ” Break down into intermediate individuals
Gu8WdUpdate=1; // Full screen update
break;
case 3: // At the window 3 Next
Gu8Wd=1; // Switch to window 1
Gu8EditData_2=Gu8SetData_1/10%10; //“ Data to be edited ” Break down into intermediate individuals
Gu8EditData_1=Gu8SetData_1/1%10; //“ Data to be edited ” Break down into intermediate individuals
Gu8WdUpdate=1; // Full screen update
break;
}
}
else // be in “ Flash mode ” When , yes “ Switch local ”
{
PartUpdate(Gu8Part); // Update the part before switching .
Gu8Part++; // Switch local
if(Gu8Part>2)
{
Gu8Part=1;
}
PartUpdate(Gu8Part); // Update the part after switching .
}
vGu8BeepTimerFlag=0;
vGu16BeepTimerCnt=VOICE_TIME; // The buzzer sounds “ drop ” A sound
vGu8BeepTimerFlag=1;
vGu8KeySec=0;
break;
case 2: // Increment key K2
switch(Gu8Wd) // Under a window
{
case 1: // At the window 1 Next
case 2: // At the window 2 Next , window 2 And the window 1 The code is exactly the same , So you can share
case 3: // At the window 3 Next , window 3 And the window 1 The code is exactly the same , So you can share
switch(Gu8Part) // Local selection of secondary fulcrum
{
case 1: // Local 1 To be selected , Stands for... From the left 3 Bit nixie tube is selected .
Gu8EditData_2++; // edit “ ten ” The intermediate variable of the individual
if(Gu8EditData_2>9)
{
Gu8EditData_2=9;
}
PartUpdate(Gu8Part); // The current local update display is output to the nixie tube
break;
case 2: // Local 2 To be selected , Stands for... From the left 4 Bit nixie tube is selected .
Gu8EditData_1++; // edit “ bits ” The intermediate variable of the individual
if(Gu8EditData_1>9)
{
Gu8EditData_1=9;
}
PartUpdate(Gu8Part); // The current local update display is output to the nixie tube
break;
}
break;
}
vGu8BeepTimerFlag=0;
vGu16BeepTimerCnt=VOICE_TIME; // The buzzer sounds “ drop ” A sound
vGu8BeepTimerFlag=1;
vGu8KeySec=0;
break;
case 3: // Decrement key K3
switch(Gu8Wd) // Under a window
{
case 1: // At the window 1 Next
case 2: // At the window 2 Next , window 2 And the window 1 The code is exactly the same , So you can share
case 3: // At the window 3 Next , window 3 And the window 1 The code is exactly the same , So you can share
switch(Gu8Part) // Local selection of secondary fulcrum
{
case 1: // Local 1 To be selected , Stands for... From the left 3 Bit nixie tube is selected .
if(Gu8EditData_2>0)
{
Gu8EditData_2--; // edit “ ten ” The intermediate variable of the individual
}
PartUpdate(Gu8Part); // The current local update display is output to the nixie tube
break;
case 2: // Local 2 To be selected , Stands for... From the left 4 Bit nixie tube is selected .
if(Gu8EditData_1>0)
{
Gu8EditData_1--; // edit “ bits ” The intermediate variable of the individual
}
PartUpdate(Gu8Part); // The current local update display is output to the nixie tube
break;
}
break;
}
vGu8BeepTimerFlag=0;
vGu16BeepTimerCnt=VOICE_TIME; // The buzzer sounds “ drop ” A sound
vGu8BeepTimerFlag=1;
vGu8KeySec=0;
break;
case 4: //K1 Button “ Long press ”, With entry and exit “ Flash mode ” The function of .“ sign out ” Implication “ determine ”
switch(Gu8Wd) // Under a window
{
case 1: // At the window 1 Next
if(0==Gu8Part) // be in “ No flicker ” When , Will enter the “ Flash mode ”
{
Gu8EditData_2=Gu8SetData_1/10%10; // The first “ Data to be edited ” Break down into intermediate individuals
Gu8EditData_1=Gu8SetData_1/1%10; // The first “ Data to be edited ” Break down into intermediate individuals
Gu8Part=1; // Get into “ Flash mode ”, from “ Local 1” Start blinking
}
else // be in “ Flash mode ” When , Will exit to “ No flicker ”, Implication “ determine ” function
{
Gu8SetData_1=Gu8EditData_2*10+Gu8EditData_1; // Merge and restore individual data
Gu8Part=0; // sign out “ Flash mode ”
Gu8WdUpdate=1; // Full screen update
}
break;
case 2: // At the window 2 Next
if(0==Gu8Part) // be in “ No flicker ” When , Will enter the “ Flash mode ”
{
Gu8EditData_2=Gu8SetData_2/10%10; // The first “ Data to be edited ” Break down into intermediate individuals
Gu8EditData_1=Gu8SetData_2/1%10; // The first “ Data to be edited ” Break down into intermediate individuals
Gu8Part=1; // Get into “ Flash mode ”, from “ Local 1” Start blinking
}
else // be in “ Flash mode ” When , Will exit to “ No flicker ”, Implication “ determine ” function
{
Gu8SetData_2=Gu8EditData_2*10+Gu8EditData_1; // Merge and restore individual data
Gu8Part=0; // sign out “ Flash mode ”
Gu8WdUpdate=1; // Full screen update
}
break;
case 3: // At the window 3 Next
if(0==Gu8Part) // be in “ No flicker ” When , Will enter the “ Flash mode ”
{
Gu8EditData_2=Gu8SetData_3/10%10; // The first “ Data to be edited ” Break down into intermediate individuals
Gu8EditData_1=Gu8SetData_3/1%10; // The first “ Data to be edited ” Break down into intermediate individuals
Gu8Part=1; // Get into “ Flash mode ”, from “ Local 1” Start blinking
}
else // be in “ Flash mode ” When , Will exit to “ No flicker ”, Implication “ determine ” function
{
Gu8SetData_3=Gu8EditData_2*10+Gu8EditData_1; // Merge and restore individual data
Gu8Part=0; // sign out “ Flash mode ”
Gu8WdUpdate=1; // Full screen update
}
break;
}
vGu8BeepTimerFlag=0;
vGu16BeepTimerCnt=VOICE_TIME; // The buzzer sounds “ drop ” A sound
vGu8BeepTimerFlag=1;
vGu8KeySec=0;
break;
}
}
void DisplayTask(void) // The upper task function of nixie tube display
{
switch(Gu8Wd) // Select by window Gu8Wd As a fulcrum , To execute the corresponding window display function . Use again switch sentence
{
case 1:
Wd1(); // window 1 Show function
break;
case 2:
Wd2(); // window 2 Show function
break;
case 3:
Wd3(); // window 3 Show function
break;
}
}
void Wd1(void) // window 1 Show function
{
// Intermediate variables to be borrowed , Used to split data bits .
static unsigned char Su8Temp_4,Su8Temp_3,Su8Temp_2,Su8Temp_1; // Intermediate variables to be borrowed
static unsigned char Su8BlinkFlag=0; // Intermediate variable for switching between two states
if(1==Gu8WdUpdate) // If you need a full screen update
{
Gu8WdUpdate=0; // Clear in time , Just update the display once , Avoid constantly updating the display
Su8Temp_4=1; // From the left 1 Digital tube , Display window “1”, It belongs to static data , rise “ decorate ” effect .
Su8Temp_3=11; // From the left 2 Digital tube , Show horizontal bar “-”, It belongs to static data , rise “ decorate ” effect .
vGu8Display_Righ_4=Su8Temp_4; // The data to be displayed in the transition is driven by the underlying variables
vGu8Display_Righ_3=Su8Temp_3; // The data to be displayed in the transition is driven by the underlying variables
// Do not display any decimal point , It belongs to static data , rise “ decorate ” effect , Code that is scanned only once after switching windows .
vGu8Display_Righ_Dot_4=0;
vGu8Display_Righ_Dot_3=0;
vGu8Display_Righ_Dot_2=0;
vGu8Display_Righ_Dot_1=0;
Gu8PartUpdate_1=1; // Local 1 Update display
Gu8PartUpdate_2=1 ;// Local 2 Update display
}
if(1==Gu8PartUpdate_1) // Local 1 Update display
{
Gu8PartUpdate_1=0; // Clear in time , Just update the display once , Avoid constantly updating the display
Su8Temp_2=Gu8EditData_2; // Show “ ten ” A temporary intermediary of , It belongs to dynamic data .
vGu8Display_Righ_2=Su8Temp_2; // The data to be displayed in the transition is driven by the underlying variables
}
if(1==Gu8PartUpdate_2) // Local 2 Update display
{
Gu8PartUpdate_2=0; // Clear in time , Just update the display once , Avoid constantly updating the display
Su8Temp_1=Gu8EditData_1; // Show “ bits ” A temporary intermediary of , It belongs to dynamic data .
vGu8Display_Righ_1=Su8Temp_1; // The data to be displayed in the transition is driven by the underlying variables
}
if(0==vGu16BlinkTimerCnt) // The timer of a selected nixie tube flickers
{
vGu8BlinkTimerFlag=0;
vGu16BlinkTimerCnt=BLINK_TIME; // Reset the timer timing
vGu8BlinkTimerFlag=1;
switch(Gu8Part) // A part is selected , Then it flickers and jumps
{
case 1:
if(0==Su8BlinkFlag) // Judgment of switching between two states
{
Su8BlinkFlag=1;
Su8Temp_2=10; // From the left 3 A display “ No display ”(10 Does not show )
}
else
{
Su8BlinkFlag=0;
Su8Temp_2=Gu8EditData_2; // Show “ ten ” A temporary intermediary of , It belongs to dynamic data .
}
break;
case 2:
if(0==Su8BlinkFlag) // Judgment of switching between two states
{
Su8BlinkFlag=1;
Su8Temp_1=10; // From the left 4 A display “ No display ”(10 Does not show )
}
else
{
Su8BlinkFlag=0;
Su8Temp_1=Gu8EditData_1; // Show “ bits ” A temporary intermediary of , It belongs to dynamic data .
}
break;
default: // When they are not selected
Su8Temp_2=Gu8EditData_2; // Show “ ten ” A temporary intermediary of , It belongs to dynamic data .
Su8Temp_1=Gu8EditData_1; // Show “ bits ” A temporary intermediary of , It belongs to dynamic data .
break;
}
vGu8Display_Righ_2=Su8Temp_2; // The data to be displayed in the transition is driven by the underlying variables
vGu8Display_Righ_1=Su8Temp_1; // The data to be displayed in the transition is driven by the underlying variables
}
}
void Wd2(void) // window 2 Show function
{
// Intermediate variables to be borrowed , Used to split data bits .
static unsigned char Su8Temp_4,Su8Temp_3,Su8Temp_2,Su8Temp_1; // Intermediate variables to be borrowed
static unsigned char Su8BlinkFlag=0; // Intermediate variable for switching between two states
if(1==Gu8WdUpdate) // If you need a full screen update
{
Gu8WdUpdate=0; // Clear in time , Just update the display once , Avoid constantly updating the display
Su8Temp_4=2; // From the left 1 Digital tube , Display window “2”, It belongs to static data , rise “ decorate ” effect .
Su8Temp_3=11; // From the left 2 Digital tube , Show horizontal bar “-”, It belongs to static data , rise “ decorate ” effect .
vGu8Display_Righ_4=Su8Temp_4; // The data to be displayed in the transition is driven by the underlying variables
vGu8Display_Righ_3=Su8Temp_3; // The data to be displayed in the transition is driven by the underlying variables
// Do not display any decimal point , It belongs to static data , rise “ decorate ” effect , Code that is scanned only once after switching windows .
vGu8Display_Righ_Dot_4=0;
vGu8Display_Righ_Dot_3=0;
vGu8Display_Righ_Dot_2=0;
vGu8Display_Righ_Dot_1=0;
Gu8PartUpdate_1=1; // Local 1 Update display
Gu8PartUpdate_2=1 ;// Local 2 Update display
}
if(1==Gu8PartUpdate_1) // Local 1 Update display
{
Gu8PartUpdate_1=0; // Clear in time , Just update the display once , Avoid constantly updating the display
Su8Temp_2=Gu8EditData_2; // Show “ ten ” A temporary intermediary of , It belongs to dynamic data .
vGu8Display_Righ_2=Su8Temp_2; // The data to be displayed in the transition is driven by the underlying variables
}
if(1==Gu8PartUpdate_2) // Local 2 Update display
{
Gu8PartUpdate_2=0; // Clear in time , Just update the display once , Avoid constantly updating the display
Su8Temp_1=Gu8EditData_1; // Show “ bits ” A temporary intermediary of , It belongs to dynamic data .
vGu8Display_Righ_1=Su8Temp_1; // The data to be displayed in the transition is driven by the underlying variables
}
if(0==vGu16BlinkTimerCnt) // The timer of a selected nixie tube flickers
{
vGu8BlinkTimerFlag=0;
vGu16BlinkTimerCnt=BLINK_TIME; // Reset the timer timing
vGu8BlinkTimerFlag=1;
switch(Gu8Part) // A part is selected , Then it flickers and jumps
{
case 1:
if(0==Su8BlinkFlag) // Judgment of switching between two states
{
Su8BlinkFlag=1;
Su8Temp_2=10; // From the left 3 A display “ No display ”(10 Does not show )
}
else
{
Su8BlinkFlag=0;
Su8Temp_2=Gu8EditData_2; // Show “ ten ” A temporary intermediary of , It belongs to dynamic data .
}
break;
case 2:
if(0==Su8BlinkFlag) // Judgment of switching between two states
{
Su8BlinkFlag=1;
Su8Temp_1=10; // From the left 4 A display “ No display ”(10 Does not show )
}
else
{
Su8BlinkFlag=0;
Su8Temp_1=Gu8EditData_1; // Show “ bits ” A temporary intermediary of , It belongs to dynamic data .
}
break;
default: // When they are not selected
Su8Temp_2=Gu8EditData_2; // Show “ ten ” A temporary intermediary of , It belongs to dynamic data .
Su8Temp_1=Gu8EditData_1; // Show “ bits ” A temporary intermediary of , It belongs to dynamic data .
break;
}
vGu8Display_Righ_2=Su8Temp_2; // The data to be displayed in the transition is driven by the underlying variables
vGu8Display_Righ_1=Su8Temp_1; // The data to be displayed in the transition is driven by the underlying variables
}
}
void Wd3(void) // window 3 Show function
{
// Intermediate variables to be borrowed , Used to split data bits .
static unsigned char Su8Temp_4,Su8Temp_3,Su8Temp_2,Su8Temp_1; // Intermediate variables to be borrowed
static unsigned char Su8BlinkFlag=0; // Intermediate variable for switching between two states
if(1==Gu8WdUpdate) // If you need a full screen update
{
Gu8WdUpdate=0; // Clear in time , Just update the display once , Avoid constantly updating the display
Su8Temp_4=3; // From the left 1 Digital tube , Display window “3”, It belongs to static data , rise “ decorate ” effect .
Su8Temp_3=11; // From the left 2 Digital tube , Show horizontal bar “-”, It belongs to static data , rise “ decorate ” effect .
vGu8Display_Righ_4=Su8Temp_4; // The data to be displayed in the transition is driven by the underlying variables
vGu8Display_Righ_3=Su8Temp_3; // The data to be displayed in the transition is driven by the underlying variables
// Do not display any decimal point , It belongs to static data , rise “ decorate ” effect , Code that is scanned only once after switching windows .
vGu8Display_Righ_Dot_4=0;
vGu8Display_Righ_Dot_3=0;
vGu8Display_Righ_Dot_2=0;
vGu8Display_Righ_Dot_1=0;
Gu8PartUpdate_1=1; // Local 1 Update display
Gu8PartUpdate_2=1 ;// Local 2 Update display
}
if(1==Gu8PartUpdate_1) // Local 1 Update display
{
Gu8PartUpdate_1=0; // Clear in time , Just update the display once , Avoid constantly updating the display
Su8Temp_2=Gu8EditData_2; // Show “ ten ” A temporary intermediary of , It belongs to dynamic data .
vGu8Display_Righ_2=Su8Temp_2; // The data to be displayed in the transition is driven by the underlying variables
}
if(1==Gu8PartUpdate_2) // Local 2 Update display
{
Gu8PartUpdate_2=0; // Clear in time , Just update the display once , Avoid constantly updating the display
Su8Temp_1=Gu8EditData_1; // Show “ bits ” A temporary intermediary of , It belongs to dynamic data .
vGu8Display_Righ_1=Su8Temp_1; // The data to be displayed in the transition is driven by the underlying variables
}
if(0==vGu16BlinkTimerCnt) // The timer of a selected nixie tube flickers
{
vGu8BlinkTimerFlag=0;
vGu16BlinkTimerCnt=BLINK_TIME; // Reset the timer timing
vGu8BlinkTimerFlag=1;
switch(Gu8Part) // A part is selected , Then it flickers and jumps
{
case 1:
if(0==Su8BlinkFlag) // Judgment of switching between two states
{
Su8BlinkFlag=1;
Su8Temp_2=10; // From the left 3 A display “ No display ”(10 Does not show )
}
else
{
Su8BlinkFlag=0;
Su8Temp_2=Gu8EditData_2; // Show “ ten ” A temporary intermediary of , It belongs to dynamic data .
}
break;
case 2:
if(0==Su8BlinkFlag) // Judgment of switching between two states
{
Su8BlinkFlag=1;
Su8Temp_1=10; // From the left 4 A display “ No display ”(10 Does not show )
}
else
{
Su8BlinkFlag=0;
Su8Temp_1=Gu8EditData_1; // Show “ bits ” A temporary intermediary of , It belongs to dynamic data .
}
break;
default: // When they are not selected
Su8Temp_2=Gu8EditData_2; // Show “ ten ” A temporary intermediary of , It belongs to dynamic data .
Su8Temp_1=Gu8EditData_1; // Show “ bits ” A temporary intermediary of , It belongs to dynamic data .
break;
}
vGu8Display_Righ_2=Su8Temp_2; // The data to be displayed in the transition is driven by the underlying variables
vGu8Display_Righ_1=Su8Temp_1; // The data to be displayed in the transition is driven by the underlying variables
}
}
void KeyScan(void) // The driver scanning function at the bottom of the key , In the timer interrupt function
{
static unsigned char Su8KeyShortFlag=0; // Key “ Short press ” Trigger flag
static unsigned char Su8KeyLock1;
static unsigned int Su16KeyCnt1;
static unsigned char Su8KeyLock2;
static unsigned int Su16KeyCnt2;
static unsigned char Su8KeyLock3;
static unsigned int Su16KeyCnt3;
if(0!=KEY_INPUT1)
{
Su8KeyLock1=0;
Su16KeyCnt1=0;
if(1==Su8KeyShortFlag)
{
Su8KeyShortFlag=0;
vGu8KeySec=1; // Trigger K1 Of “ Short press ”
}
}
else if(0==Su8KeyLock1)
{
Su16KeyCnt1++;
if(Su16KeyCnt1>=KEY_FILTER_TIME)
{
Su8KeyShortFlag=1;
}
if(Su16KeyCnt1>=KEY_LONG_TIME)
{
Su8KeyLock1=1;
Su8KeyShortFlag=0;
vGu8KeySec=4; // Trigger K1 Of “ Long press ”
}
}
if(0!=KEY_INPUT2)
{
Su8KeyLock2=0;
Su16KeyCnt2=0;
}
else if(0==Su8KeyLock2)
{
Su16KeyCnt2++;
if(Su16KeyCnt2>=KEY_FILTER_TIME)
{
Su8KeyLock2=1;
vGu8KeySec=2;
}
}
if(0!=KEY_INPUT3)
{
Su8KeyLock3=0;
Su16KeyCnt3=0;
}
else if(0==Su8KeyLock3)
{
Su16KeyCnt3++;
if(Su16KeyCnt3>=KEY_FILTER_TIME)
{
Su8KeyLock3=1;
vGu8KeySec=3;
}
}
}
void DisplayScan(void) // The drive scanning function at the bottom of the nixie tube , In the timer interrupt function
{
static unsigned char Su8GetCode;
static unsigned char Su8ScanStep=1;
if(0==vGu16ScanTimerCnt)
{
dula=1;
P0=0x00;
dula=0;
wela=1;
P0_0=1;
P0_1=1;
P0_2=1;
P0_3=1;
P0_4=1;
P0_5=1;
wela=0;
switch(Su8ScanStep)
{
case 1:
Su8GetCode=Cu8DigTable[vGu8Display_Righ_4];
if(1==vGu8Display_Righ_Dot_4)
{
Su8GetCode=Su8GetCode|0x80;
}
dula=1;
P0=Su8GetCode;
dula=0;
wela=1;
P0_0=0;
P0_1=1;
P0_2=1;
P0_3=1;
P0_4=1;
P0_5=1;
wela=0;
break;
case 2:
Su8GetCode=Cu8DigTable[vGu8Display_Righ_3];
if(1==vGu8Display_Righ_Dot_3)
{
Su8GetCode=Su8GetCode|0x80;
}
dula=1;
P0=Su8GetCode;
dula=0;
wela=1;
P0_0=1;
P0_1=0;
P0_2=1;
P0_3=1;
P0_4=1;
P0_5=1;
wela=0;
break;
case 3:
Su8GetCode=Cu8DigTable[vGu8Display_Righ_2];
if(1==vGu8Display_Righ_Dot_2)
{
Su8GetCode=Su8GetCode|0x80;
}
dula=1;
P0=Su8GetCode;
dula=0;
wela=1;
P0_0=1;
P0_1=1;
P0_2=0;
P0_3=1;
P0_4=1;
P0_5=1;
wela=0;
break;
case 4:
Su8GetCode=Cu8DigTable[vGu8Display_Righ_1];
if(1==vGu8Display_Righ_Dot_1)
{
Su8GetCode=Su8GetCode|0x80;
}
dula=1;
P0=Su8GetCode;
dula=0;
wela=1;
P0_0=1;
P0_1=1;
P0_2=1;
P0_3=0;
P0_4=1;
P0_5=1;
wela=0;
break;
}
Su8ScanStep++;
if(Su8ScanStep>4)
{
Su8ScanStep=1;
}
vGu8ScanTimerFlag=0;
vGu16ScanTimerCnt=SCAN_TIME;
vGu8ScanTimerFlag=1;
}
}
void VoiceScan(void) // Buzzer drive function
{
static unsigned char Su8Lock=0;
if(1==vGu8BeepTimerFlag&&vGu16BeepTimerCnt>0)
{
if(0==Su8Lock)
{
Su8Lock=1;
BeepOpen();
}
else
{
vGu16BeepTimerCnt--;
if(0==vGu16BeepTimerCnt)
{
Su8Lock=0;
BeepClose();
}
}
}
}
void BeepOpen(void)
{
beep=0;
}
void BeepClose(void)
{
beep=1;
}
void T0_time() interrupt 1
{
VoiceScan(); // Buzzer drive function
KeyScan(); // The driver scanning function at the bottom of the key
DisplayScan(); // The drive scanning function at the bottom of the nixie tube
if(1==vGu8ScanTimerFlag&&vGu16ScanTimerCnt>0)
{
vGu16ScanTimerCnt--; // Decreasing software timer
}
if(1==vGu8BlinkTimerFlag&&vGu16BlinkTimerCnt>0) // A timer with a flashing digital tube
{
vGu16BlinkTimerCnt--; // Decreasing software timer
}
TH0=0xfc;
TL0=0x66;
}
void SystemInitial(void)
{
dula=1;
P0=0x00;
dula=0;
wela=1;
P0_0=1;
P0_1=1;
P0_2=1;
P0_3=1;
P0_4=1;
P0_5=1;
dula=0;
TMOD=0x01;
TH0=0xfc;
TL0=0x66;
EA=1;
ET0=1;
TR0=1;
}
void Delay(unsigned long u32DelayTime)
{
for(;u32DelayTime>0;u32DelayTime--);
}
void PeripheralInitial(void)
{
}
边栏推荐
猜你喜欢

Axi bus
![[dynamic programming] - Knapsack Problem](/img/27/c48284f15e3f80305d7ce7c02d4378.png)
[dynamic programming] - Knapsack Problem

Privacy computing fat offline prediction

IJCAI 2022 | greatly improve the effect of zero sample learning method with one line of code. Nanjing Institute of Technology & Oxford proposed the plug and play classifier module

With the advent of the era of Internet of everything, Ruijie released a scenario based wireless zero roaming scheme

爱可可AI前沿推介(6.27)

每日刷题记录 (六)

hue新建账号报错解决方案

每日刷題記錄 (六)

Axi bus
随机推荐
Intranet learning notes (8)
MySQL index and its classification
面试官:Redis的共享对象池了解吗?
Read a poem
ZABBIX supports nail alarm
PLM还能怎么用?
IJCAI 2022 | 用一行代码大幅提升零样本学习方法效果,南京理工&牛津提出即插即用分类器模块
Today's sleep quality record 78 points
《预训练周刊》第51期:重构预训练、零样本自动微调、一键调用OPT
Summary of basic usage of command line editor sed
Embedded development: embedded foundation callback function
Deploy redis sentinel mode using bitnamiredis Sentinel
MySQL 索引及其分类
scrapy
[weekly replay] the 81st biweekly match of leetcode
On the complexity of software development and the way to improve its efficiency
POSIX AIO -- glibc 版本异步 IO 简介
Vs debugging skills
新华三的千亿企业梦,还得靠吃ICT老本来实现?
Good luck today