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

📄 aptask.c

📁 加速度采集器。基于ATMega16L.AVRSTUIDIO4
💻 C
字号:
#include "ap89021.h"
#include "apTask.h"

#include "ap89021.h"
#include <iom16v.h>
#include <macros.h>
#include <avr/io.h>
#include <avr/pgmspace.h>


//interface
extern unsigned short currentImpact;
extern unsigned short impactCounter;
extern unsigned char currentImpactUpdated;


//Thresholds
#include "defSound.h"


void apTask(void)
{
	unsigned char sndNum,i;
 	 unsigned char apImpactUpdated = 0;
	 unsigned short apCurrentImpact;


	if(apIsBusy())
		return;

 	 //read interface!!!
	 CLI();
	 if(currentImpactUpdated&0x02)
	 {
	  currentImpactUpdated &= ~0x02;
	  apImpactUpdated = 1;
	  apCurrentImpact = currentImpact;
	 }
	 SEI();
	 
	 //Play sound
	 if (!apImpactUpdated)
	 	return;
	
	sndNum = 0xFF;	//No Sound
	for(i=0;i<NumThresholds;i++)
	{
		if(apCurrentImpact>=thresholdSetting[i])
			sndNum = i;
		else 
			break;
	}
	if(sndNum<NumThresholds)
		apPlay(sndNum);

}

⌨️ 快捷键说明

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