mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
80 lines
2.8 KiB
C
80 lines
2.8 KiB
C
/*********************************************************************************************************************
|
||
* COPYRIGHT NOTICE
|
||
* Copyright (c) 2020,<2C><><EFBFBD>ɿƼ<C9BF>
|
||
* All rights reserved.
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>QQȺ<51><C8BA><EFBFBD><EFBFBD>Ⱥ<EFBFBD><C8BA>824575535
|
||
*
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC><EFBFBD><EFBFBD>У<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>;<EFBFBD><CDBE>
|
||
* <20><>ӭ<EFBFBD><D3AD>λʹ<CEBB>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>뱣<EFBFBD><EBB1A3><EFBFBD><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC>İ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*
|
||
* @file FUN
|
||
* @company <09>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC><EFBFBD><EFBFBD><EFBFBD>˾
|
||
* @author <09><><EFBFBD>ɿƼ<C9BF>(QQ3184284598)
|
||
* @version <09>鿴doc<6F><63>version<6F>ļ<EFBFBD> <20>汾˵<E6B1BE><CBB5>
|
||
* @Software ADS v1.2.2
|
||
* @Target core TC264D
|
||
* @Taobao https://seekfree.taobao.com/
|
||
* @date 2020-3-23
|
||
********************************************************************************************************************/
|
||
|
||
|
||
|
||
#include "SEEKFREE_FUN.h"
|
||
|
||
|
||
//-------------------------------------------------------------------------------------------------------------------
|
||
// @brief <20><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
|
||
// @param dat <09><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
|
||
// @return int <09><><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>ֵ
|
||
// Sample usage: dat = myabs(dat);//<2F><>dat<61><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
//-------------------------------------------------------------------------------------------------------------------
|
||
int myabs(int dat)
|
||
{
|
||
if(dat>=0) return dat;
|
||
else return -dat;
|
||
}
|
||
|
||
|
||
//-------------------------------------------------------------------------------------------------------------------
|
||
// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
||
// @param t <09><>ʱʱ<CAB1><CAB1>
|
||
// @return void
|
||
// Sample usage:
|
||
//-------------------------------------------------------------------------------------------------------------------
|
||
void my_delay(long t)
|
||
{
|
||
while(t--);
|
||
}
|
||
|
||
|
||
//-------------------------------------------------------------------------------------------------------------------
|
||
// @brief <20><EFBFBD>
|
||
// @param x <09><><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// @param y <09><EFBFBD><DEB7><EFBFBD>Χ(<28><><EFBFBD>ݻᱻ<DDBB><E1B1BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-y<><79>+y֮<79><D6AE>)
|
||
// @return float <09><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// Sample usage: float dat = limit(500,300);//<2F><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-300<30><30>+300֮<30><D6AE> <20><><EFBFBD>˷<EFBFBD><CBB7>صĽ<D8B5><C4BD><EFBFBD><EFBFBD><EFBFBD>300
|
||
//-------------------------------------------------------------------------------------------------------------------
|
||
float limit(float x, int32 y)
|
||
{
|
||
if(x>y) return (float)y;
|
||
else if(x<-y) return (float)(-y);
|
||
else return x;
|
||
}
|
||
|
||
|
||
//-------------------------------------------------------------------------------------------------------------------
|
||
// @brief ˫<><CBAB><EFBFBD><EFBFBD>
|
||
// @param x <09><><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// @param a <09><EFBFBD><DEB7><EFBFBD>Χ<EFBFBD><CEA7><EFBFBD>߽<EFBFBD>
|
||
// @param b <09><EFBFBD><DEB7><EFBFBD>Χ<EFBFBD>ұ߽<D2B1>
|
||
// @return float <09><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// Sample usage: int16 dat = limit_ab(500,-300<30><30>400);//<2F><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-300<30><30>+400֮<30><D6AE> <20><><EFBFBD>˷<EFBFBD><CBB7>صĽ<D8B5><C4BD><EFBFBD><EFBFBD><EFBFBD>400
|
||
//-------------------------------------------------------------------------------------------------------------------
|
||
int16 limit_ab(int16 x, int16 a, int16 b)
|
||
{
|
||
if(x<a) x = a;
|
||
if(x>b) x = b;
|
||
return x;
|
||
}
|
||
|