stm32 hal 库 使用模板(1)——界面切换

        

#include "Pages.h"

uint8_t PagesNum = PAGE0;

void Page0Display(uint8_t Key)
{
    PagesNum = PAGE0;
    if (Key ==KEY1)
    {
        PagesNum = PAGE1;
    }
}

void Page1Display(uint8_t Key)
{
    PagesNum = PAGE1;
    if (Key == KEY1)
    {
        PagesNum = PAGE2;
}

void Page2Display(uint8_t Key)
{
    PagesNum = PAGE2;
    if (Key == KEY1)
    {
        PagesNum = PAGE3;
    }
}

void Page3Display(uint8_t Key)
{
    PagesNum = PAGE3;
    if(Key == KEY1)
    {
        PagesNum = PAGE4;
    }
}
void Page4Display(uint8_t Key)
{
    PagesNum = PAGE4;
    if (Key == KEY1)
    {
        PagesNum = PAGE0;
    }
}

void PagesDisplay(uint8_t Key)
{
    switch (PagesNum)//界面切换
    {
    case PAGE0:
        Page0Display(Key);
        break;
    case PAGE1:
        Page1Display(Key);
        break;
    case PAGE2:
        Page2Display(Key);
        break;
    case PAGE3:
        Page3Display(Key);
        break;
    case PAGE4:
        Page4Display(Key);
        break;
    default:
        break;
    }
}


 

#ifndef __PAGES_H
#define __PAGES_H

#include "main.h"
    

#define PAGE0 0
#define PAGE1 1
#define PAGE2 2
#define PAGE3 3
#define PAGE4 4


void PagesDisplay(uint8_t Key);
#endif
 

你可能感兴趣的:(单片机,学习,stm32)