⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.cpp

📁 SimpleGraphicOperatingSystem 32位图形化操作系统 多进程 支持FAT32 详见www.sgos.net.cn
💻 CPP
字号:
#include <OsDef.h>
#include <System.h>
#include <Api.h>	//Sgos api

namespace System{
    static int timerNum = 0;
    static TimerProcedure procedures[MAX_PROCEDURE];

    bool Timer::SetTimer( TimerProcedure proc, int ms )
    {
        if( timerNum==MAX_PROCEDURE )
        {
            return -1;
        }
        procedures[timerNum] = proc;
        KSetTimer( timerNum, ms );
        timerNum++;
    }

    //Del
    bool Timer::DelTimer( TimerProcedure proc )
    {
        for( int i=0; i<timerNum; i++ )
        {
            if( procedures[i] == proc )
            {
                KDelTimer( i );
                timerNum--;
                procedures[i] = procedures[timerNum];
                procedures[timerNum] = ( TimerProcedure )0;
            }
        }
    }

    //switch and run
    int Timer::Switch( int i )
    {
        if ( procedures[i] )
            procedures[i]();
        else
            DPRINT("ERROR");
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -