public Task<IoTTelemetry> GetData() { IoTTelemetry data = new IoTTelemetry(); data.ARDUINO_DIST = m_rnd.Next(1024); data.ARDUINO_LIGHT = m_rnd.Next(1024); data.GY_652_H = m_rnd.NextDouble() * 360; data.MCP3002_CH0 = m_rnd.Next(1024); data.MCP3002_CH1 = m_rnd.Next(1024); data.PCF8591_CH0 = m_rnd.Next(1024); data.PCF8591_CH1 = m_rnd.Next(1024); data.PCF8591_CH2 = m_rnd.Next(1024); data.PCF8591_CH3 = m_rnd.Next(1024); data.DeviceName = GetDeviceName() ; data.PIR = (m_rnd.Next(2) == 1) ? true : false; return Task.FromResult<IoTTelemetry>(data); }
public Task <IoTTelemetry> GetData() { IoTTelemetry data = new IoTTelemetry(); data.ARDUINO_DIST = m_rnd.Next(1024); data.ARDUINO_LIGHT = m_rnd.Next(1024); data.GY_652_H = m_rnd.NextDouble() * 360; data.MCP3002_CH0 = m_rnd.Next(1024); data.MCP3002_CH1 = m_rnd.Next(1024); data.PCF8591_CH0 = m_rnd.Next(1024); data.PCF8591_CH1 = m_rnd.Next(1024); data.PCF8591_CH2 = m_rnd.Next(1024); data.PCF8591_CH3 = m_rnd.Next(1024); data.DeviceName = GetDeviceName(); data.PIR = (m_rnd.Next(2) == 1) ? true : false; return(Task.FromResult <IoTTelemetry>(data)); }
public async Task <IoTTelemetry> GetData() { IoTTelemetry data = new IoTTelemetry(); data.DeviceName = GetDeviceName(); if (!m_init) { return(data); } byte[] wbuffer = new byte[] { 1, 2 }; byte[] rbuffer = new byte[8]; m_devArduino.Write(wbuffer); m_devArduino.Read(rbuffer); //Nie możemy tu pominąć "nadmiarowych" - wada "protokołu" data.ARDUINO_DIST = rbuffer[4] + (rbuffer[5] << 8); data.ARDUINO_LIGHT = rbuffer[6] + (rbuffer[7] << 8); //SPI m_spiDev.TransferFullDuplex(m_writeBufferCH0, m_readBuffer); data.MCP3002_CH0 = convertToInt(m_readBuffer); m_spiDev.TransferFullDuplex(m_writeBufferCH1, m_readBuffer); data.MCP3002_CH1 = convertToInt(m_readBuffer); //PIR data.PIR = (pinPIR.Read() == GpioPinValue.High); //Gyro data.GY_652_H = await readCompassHeading(); //i2cPCF8591 byte[] cmd = new byte[1] { 0x04 }; byte[] buf5 = new byte[5]; i2cPCF8591.Write(cmd); i2cPCF8591.Read(buf5); data.PCF8591_CH0 = buf5[1]; data.PCF8591_CH1 = buf5[2]; data.PCF8591_CH2 = buf5[3]; data.PCF8591_CH3 = buf5[4]; return(data); }
public async Task<IoTTelemetry> GetData() { IoTTelemetry data = new IoTTelemetry(); data.DeviceName = GetDeviceName(); if (!m_init) return data; byte[] wbuffer = new byte[] { 1, 2 }; byte[] rbuffer = new byte[8]; m_devArduino.Write(wbuffer); m_devArduino.Read(rbuffer); //Nie możemy tu pominąć "nadmiarowych" - wada "protokołu" data.ARDUINO_DIST = rbuffer[4] + (rbuffer[5] << 8); data.ARDUINO_LIGHT = rbuffer[6] + (rbuffer[7] << 8); //SPI m_spiDev.TransferFullDuplex(m_writeBufferCH0, m_readBuffer); data.MCP3002_CH0 = convertToInt(m_readBuffer); m_spiDev.TransferFullDuplex(m_writeBufferCH1, m_readBuffer); data.MCP3002_CH1 = convertToInt(m_readBuffer); //PIR data.PIR = (pinPIR.Read() == GpioPinValue.High); //Gyro data.GY_652_H = await readCompassHeading(); //i2cPCF8591 byte[] cmd = new byte[1] { 0x04 }; byte[] buf5 = new byte[5]; i2cPCF8591.Write(cmd); i2cPCF8591.Read(buf5); data.PCF8591_CH0 = buf5[1]; data.PCF8591_CH1 = buf5[2]; data.PCF8591_CH2 = buf5[3]; data.PCF8591_CH3 = buf5[4]; return data; }