private void Timer_Tick(object sender, EventArgs e) { try { adapter.Reset(); adapter.PutByte((int)Komande.SkipRom); adapter.PutByte((int)Komande.MeasureTemperature); adapter.Reset(); adapter.PutByte((int)Komande.SkipRom); adapter.PutByte((int)Komande.ReadRom); int rawTemperature = (UInt16)((UInt16)adapter.GetByte() | (UInt16)(adapter.GetByte() << 8)); double result = 1; if ((rawTemperature & 0x8000) > 0) { rawTemperature = (rawTemperature ^ 0xffff) + 1; result = -1; } result *= (6 * rawTemperature + rawTemperature / 4.0) / 100.0; ZapisiLog(result.ToString("N2") + " °C"); PosljiVPBI(result); } catch (Exception _ex) { ZapisiLog("NAPAKA: " + _ex.Message); ZapisiLog(_ex.StackTrace); } }
public int GetByte() { return(adapter.GetByte()); }