void NoiseLevelSensor::run() { _buffer[_sample++] = analogRead(_sensorPin); if (_sample == _bufferSize) { _sample = 0; // Serial.print("window: "); // Serial.print(_window); // Serial.println("s"); // // Serial.print("max: "); // Serial.print(getVoltage(maximum(_buffer))); // Serial.println(" Volts"); // // Serial.print("min: "); // Serial.print(getVoltage(minimum(_buffer))); // Serial.println(" Volts"); // // Serial.print("avg: "); // Serial.print(getVoltage(average(_buffer))); // Serial.println(" Volts"); // // Serial.println(); // create a sensor reading and send it to the callback _callback(getReading(getValueString())); } }
// Read all the values and store into the device static void __srf08_read(SENSOR* sensor) { Devantech_SRF08* device = (Devantech_SRF08*)sensor; if(startReading(device)) { getReading(device); } }
IOReturn AppleLM8x::callPlatformFunction ( const OSSymbol *functionName, bool waitForFunction, void *param1, void *param2, void *param3, void *param4 ) { UInt32 reg = (UInt32)param1; SInt32 *value = (SInt32 *)param2; DLOG ( "AppleLM8x::callPlatformFunction(0x%x) %s %s %08lx %08lx %08lx %08lx\n", kLM8xAddr<<1, functionName->getCStringNoCopy(), waitForFunction ? "TRUE" : "FALSE", (UInt32)param1, (UInt32)param2, (UInt32)param3, (UInt32)param4 ); if (functionName->isEqualTo(sGetSensorValueSym) == TRUE) { IOReturn status; if (systemIsRestarting == TRUE) return(kIOReturnOffline); for(int i = 0; i < LUNtableElement; i++) { if(reg == LUNtable[i].SubAddress) { status = getReading((UInt8)LUNtable[i].SubAddress, value); if(LUNtable[i].type == kTypeTemperature) { UInt8 reading = *value; *value = ( ( ( ( SInt8 ) reading ) << 16 ) * LUNtable[i].ConversionMultiple ); } if(LUNtable[i].type == kTypeADC) *value = (UInt32)(*value * LUNtable[i].ConversionMultiple); if(LUNtable[i].type == kTypeVoltage) *value = (UInt32)(*value * LUNtable[i].ConversionMultiple); return status; } } } return (super::callPlatformFunction(functionName, waitForFunction, param1, param2, param3, param4)); }
void FloorMatSensor::run() { // take a snapshot of the mat snapshot(); // count people on the mat int n = countPeople(); // create a sensor reading and send it to the callback _callback(getReading(getValueString(n))); }
float TemperatureSensor::getCelsius() { float voltage = (getReading() / 1024.f) * 5.f; float temperature = (voltage - .5f) * 100.f; return temperature; }