void MPR121_t::setReleaseThreshold(unsigned char electrode, unsigned char val){ if(electrode>12 || !isInited()) return; // avoid out of bounds behaviour // this relies on the internal register map of the MPR121 setRegister(MPR121_E0RTH + (electrode<<1), val); }
unsigned char MPR121_t::getReleaseThreshold(unsigned char electrode){ if(electrode>12 || !isInited()) return(0xFF); // avoid out of bounds behaviour return(getRegister(MPR121_E0RTH+(electrode<<1))); // "255" issue is in here somewhere //return(51); }
int MPR121_t::getBaselineData(unsigned char electrode){ if(electrode>12 || !isInited()) return(0xFFFF); // avoid out of bounds behaviour return(baselineData[electrode]); }
bool MPR121_t::isNewRelease(unsigned char electrode){ if(electrode>12 || !isInited()) return(false); // avoid out of bounds behaviour return((getLastTouchData(electrode) == true) && (getTouchData(electrode) == false)); }
bool MPR121_t::getLastTouchData(unsigned char electrode){ if(electrode>12 || !isInited()) return false; // avoid out of bounds behaviour return((lastTouchData>>electrode)&1); }
void MPR121_t::stop(){ if(!isInited()) return; ECR_backup = getRegister(MPR121_ECR); // backup MPR121_ECR to restore when we enter run setRegister(MPR121_ECR, ECR_backup & 0xC0); // turn off all electrodes to stop }
void MPR121_t::run(){ if(!isInited()) return; setRegister(MPR121_ECR, ECR_backup); // restore backup to return to run mode }
int ofxKinectContext::numAvailable() { if(!isInited()) init(); return freenect_num_devices(kinectContext) - kinects.size(); }
int ofxKinectContext::numTotal() { if(!isInited()) init(); return freenect_num_devices(kinectContext); }