public Temperature(IModuleBoardBridge bridge) : base(bridge) { var info = bridge.lookupModuleInfo(TEMPERATURE); byte i = 0; sensors = new List <ISensor>(); tempDataTypes = new List <DataTypeBase>(); foreach (byte it in info.extra) { var dataType = new TemperatureFloatData(i); tempDataTypes.Add(dataType); switch (it) { case (byte)SensorType.NrfSoc: sensors.Add(new TemperatureSensor(SensorType.NrfSoc, dataType, bridge)); break; case (byte)SensorType.ExtThermistor: sensors.Add(new ExternalThermistor(dataType, bridge)); break; case (byte)SensorType.BoschEnv: sensors.Add(new TemperatureSensor(SensorType.BoschEnv, dataType, bridge)); break; case (byte)SensorType.PresetThermistor: sensors.Add(new TemperatureSensor(SensorType.PresetThermistor, dataType, bridge)); break; } i++; } }
public void Read(byte pullup = 255, byte pulldown = 255, ushort delay = 0) { var info = bridge.lookupModuleInfo(GPIO); if (info.revision >= REVISION_ENHANCED_ANALOG) { analogDataType.read(bridge, new byte[] { pullup, pulldown, (byte)(delay / 4), 255 }); } else { analogDataType.read(bridge); } }
public Gpio(IModuleBoardBridge bridge) : base(bridge) { var info = bridge.lookupModuleInfo(GPIO); pins = new List <IPin>(); byte pin = 0; foreach (byte it in info.extra) { pins.Add(new GpioPin(it, pin, bridge)); pin++; } }
public PatternEditor Delay(ushort delay) { if (bridge.lookupModuleInfo(Module.LED).revision >= REVISION_LED_DELAYED) { command[15] = (byte)((delay >> 8) & 0xff); command[14] = (byte)(delay & 0xff); } else { command[15] = 0; command[14] = 0; } return(this); }
public Settings(IModuleBoardBridge bridge) : base(bridge) { var info = bridge.lookupModuleInfo(SETTINGS); if (info.revision >= DISCONNECTED_EVENT_REVISION) { disconnectDummyProducer = new IntegralDataType(SETTINGS, DISCONNECT_EVENT, new DataAttributes(new byte[] { }, 0, 0, false)); } if (info.revision >= BATTERY_REVISION) { batteryState = new BatteryStateDataType(); } if (info.revision >= CHARGE_STATUS_REVISION && (info.extra.Length > 0 && (info.extra[0] & 0x1) == 0x1)) { powerStatus = new IntegralDataType(SETTINGS, POWER_STATUS, new DataAttributes(new byte[] { 1 }, 1, 0, false)); } if (info.revision >= CHARGE_STATUS_REVISION && (info.extra.Length > 0 && (info.extra[0] & 0x2) == 0x2)) { chargeStatus = new IntegralDataType(SETTINGS, CHARGE_STATUS, new DataAttributes(new byte[] { 1 }, 1, 0, false)); } }
internal string CreateIdentifier(IModuleBoardBridge bridge) { string myIdentifier = null; switch ((Module)eventConfig[0]) { case SWITCH: myIdentifier = "switch"; break; case ACCELEROMETER: { var module = bridge.GetModule <IAccelerometer>(); if (module is AccelerometerMma8452q) { myIdentifier = AccelerometerMma8452q.createIdentifier(this); } else if (module is AccelerometerBmi160) { myIdentifier = AccelerometerBmi160.createIdentifier(this); } else if (module is AccelerometerBma255) { myIdentifier = AccelerometerBosch.createIdentifier(this); } else { myIdentifier = null; } break; } case TEMPERATURE: myIdentifier = string.Format("temperature[{0}]", eventConfig[2]); break; case GPIO: myIdentifier = Gpio.createIdentifier(this); break; case DATA_PROCESSOR: myIdentifier = DataProcessor.createIdentifier(this, bridge.GetModule <IDataProcessor>() as DataProcessor, bridge.getFirmware(), bridge.lookupModuleInfo(DATA_PROCESSOR).revision); break; case SERIAL_PASSTHROUGH: myIdentifier = SerialPassthrough.createIdentifier(this); break; case SETTINGS: myIdentifier = Settings.createIdentifier(this); break; case BAROMETER: myIdentifier = BarometerBosch.createIdentifier(this); break; case GYRO: myIdentifier = attributes.length() > 2 ? "angular-velocity" : string.Format("angular-velocity[{0}]", (attributes.offset >> 1)); break; case AMBIENT_LIGHT: myIdentifier = "illuminance"; break; case MAGNETOMETER: myIdentifier = attributes.length() > 2 ? "magnetic-field" : string.Format("magnetic-field[{0}]", (attributes.offset >> 1)); break; case HUMIDITY: myIdentifier = "relative-humidity"; break; case COLOR_DETECTOR: myIdentifier = attributes.length() > 2 ? "color" : string.Format("color[{0}]", (attributes.offset >> 1)); break; case PROXIMITY: myIdentifier = "proximity"; break; case SENSOR_FUSION: myIdentifier = SensorFusionBosch.createIdentifier(this); break; } if (myIdentifier == null) { throw new InvalidOperationException("Cannot create identifier string for data type: " + Util.arrayToHexString(eventConfig)); } return((input != null && !input.eventConfig.SequenceEqual(eventConfig) ? input.CreateIdentifier(bridge) + ":" : "") + myIdentifier); }
public Timer(IModuleBoardBridge bridge) : base(bridge) { activeTasks = new ScheduledTask[bridge.lookupModuleInfo(TIMER).extra[0]]; }