Diff
checker
テキスト
テキスト
画像
ドキュメント
Excel
フォルダ
Legal
Enterprise
デスクトップ
料金
ログイン
Diffchecker デスクトップのダウンロード
テキスト比較
2 つのテキスト ファイルの違いを見つける
ツール
履歴
ライブエディター
空白の変更を非表示
未変更行を折りたたむ
折り返しなし
レイアウト
分割
統合
比較精度
スマート
単語
文字
テキストスタイル
外観を変更
シンタックスハイライト
構文を選択
無視
テキスト変換
最初の差分へ移動
入力を編集
Diffchecker Desktop
Diffcheckerを実行する最も安全な方法。Diffchecker Desktopアプリを入手:あなたの差分はコンピューターから出ることはありません!
Desktopを入手
Untitled diff
作成日
2 年前
差分は期限切れになりません
クリア
エクスポート
共有
説明
29 削除
行
合計
削除
文字
合計
削除
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
127 行
すべてコピー
23 追加
行
合計
追加
文字
合計
追加
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
121 行
すべてコピー
/*
/*
This file is part of the Arduino_MKRTHERM library.
This file is part of the Arduino_MKRTHERM library.
Copyright (c) 2019 Arduino SA. All rights reserved.
Copyright (c) 2019 Arduino SA. All rights reserved.
This library is free software; you can redistribute it and/or
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
#include "MKRTHERM.h"
#include "MKRTHERM.h"
THERMClass::THERMClass(int cs, SPIClass& spi) :
THERMClass::THERMClass(int cs, SPIClass& spi) :
_cs(cs),
_cs(cs),
_spi(&spi),
_spi(&spi),
_spiSettings(4000000, MSBFIRST, SPI_MODE0)
_spiSettings(4000000, MSBFIRST, SPI_MODE0)
{
{
}
}
int THERMClass::begin()
int THERMClass::begin()
{
{
コピー
コピー済み
コピー
コピー済み
u
int32_t rawword;
int32_t rawword;
// Change uint32_t to int32_t
pinMode(_cs, OUTPUT);
pinMode(_cs, OUTPUT);
digitalWrite(_cs, HIGH);
digitalWrite(_cs, HIGH);
_spi->begin();
_spi->begin();
rawword = readSensor();
rawword = readSensor();
if (rawword == 0xFFFFFF) {
if (rawword == 0xFFFFFF) {
end();
end();
コピー
コピー済み
コピー
コピー済み
return 0;
return 0;
}
}
return 1;
return 1;
}
}
void THERMClass::end()
void THERMClass::end()
{
{
pinMode(_cs, INPUT);
pinMode(_cs, INPUT);
digitalWrite(_cs, LOW);
digitalWrite(_cs, LOW);
_spi->end();
_spi->end();
}
}
uint32_t THERMClass::readSensor()
uint32_t THERMClass::readSensor()
{
{
uint32_t read = 0x00;
uint32_t read = 0x00;
digitalWrite(_cs, LOW);
digitalWrite(_cs, LOW);
delayMicroseconds(1);
delayMicroseconds(1);
_spi->beginTransaction(_spiSettings);
_spi->beginTransaction(_spiSettings);
コピー
コピー済み
コピー
コピー済み
for (int i = 0; i < 4; i++) {
for (int i = 0; i < 4; i++) {
read <<= 8;
read <<= 8;
read |= _spi->transfer(0);
read |= _spi->transfer(0);
}
}
_spi->endTransaction();
_spi->endTransaction();
コピー
コピー済み
コピー
コピー済み
digitalWrite(_cs, HIGH);
digitalWrite(_cs, HIGH);
return read;
return read;
}
}
float THERMClass::readTemperature()
float THERMClass::readTemperature()
{
{
コピー
コピー済み
コピー
コピー済み
u
int32_t rawword;
int32_t rawword;
// Change uint32_t to int32_t
float celsius;
float celsius;
rawword = readSensor();
rawword = readSensor();
// Check for reading error
// Check for reading error
if (rawword & 0x7) {
if (rawword & 0x7) {
return NAN;
return NAN;
}
}
コピー
コピー済み
コピー
コピー済み
// The temperature is stored in the last 14
word's
bits
//
sendend
by the Thermocouple-to-Digital Converter
// The temperature is stored in the last 14
bits
if (rawword & 0x80000000) {
//
sent
by the Thermocouple-to-Digital Converter
// Negative value, drop the lower 18 bits and explicitly extend sign bits.
rawword >>
=
18
;
//
D
rop the lower 18 bits
rawword = 0xFFFFC000 | ((
rawword >>
18
) & 0x00003FFFF);
} else {
//
No need
for
manual sign extension, int32_t handles it
//
Positive value, just d
rop the lower 18 bits
.
rawword >>= 18;
}
//
multiply
for
the LSB value
celsius = rawword * 0.25f;
celsius = rawword * 0.25f;
return celsius;
return celsius;
}
}
float THERMClass::readReferenceTemperature()
float THERMClass::readReferenceTemperature()
{
{
uint32_t rawword;
uint32_t rawword;
float ref;
float ref;
rawword = readSensor();
rawword = readSensor();
コピー
コピー済み
コピー
コピー済み
//
i
gnore
first 4 FAULT bits
//
I
gnore
the
first 4 FAULT bits
rawword >>= 4;
rawword >>= 4;
コピー
コピー済み
コピー
コピー済み
// The cold junction reference temperature is stored in the first 11
word's
bits
// The cold junction reference temperature is stored in the first 11
bits
//
sendend
by the Thermocouple-to-Digital Converter
//
sent
by the Thermocouple-to-Digital Converter
rawword = rawword & 0x7FF;
rawword = rawword & 0x7FF;
コピー
コピー済み
コピー
コピー済み
//
c
heck
sign bit
and convert to negative value
.
//
C
heck
the
sign bit
and convert to negative value
if needed
.
if (rawword & 0x800) {
if (rawword & 0x800) {
コピー
コピー済み
コピー
コピー済み
ref = (0xF800 | (rawword & 0x7FF))
*
0.0625;
ref = (0xF800 | (rawword & 0x7FF))
*
0.0625;
} else {
} else {
コピー
コピー済み
コピー
コピー済み
//
m
ultiply
for
the LSB value
//
M
ultiply
by
the LSB value
ref = rawword * 0.0625f;
ref = rawword * 0.0625f;
}
}
return ref;
return ref;
}
}
THERMClass THERM;
THERMClass THERM;
保存された差分
原文
ファイルを開く
/* This file is part of the Arduino_MKRTHERM library. Copyright (c) 2019 Arduino SA. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "MKRTHERM.h" THERMClass::THERMClass(int cs, SPIClass& spi) : _cs(cs), _spi(&spi), _spiSettings(4000000, MSBFIRST, SPI_MODE0) { } int THERMClass::begin() { uint32_t rawword; pinMode(_cs, OUTPUT); digitalWrite(_cs, HIGH); _spi->begin(); rawword = readSensor(); if (rawword == 0xFFFFFF) { end(); return 0; } return 1; } void THERMClass::end() { pinMode(_cs, INPUT); digitalWrite(_cs, LOW); _spi->end(); } uint32_t THERMClass::readSensor() { uint32_t read = 0x00; digitalWrite(_cs, LOW); delayMicroseconds(1); _spi->beginTransaction(_spiSettings); for (int i = 0; i < 4; i++) { read <<= 8; read |= _spi->transfer(0); } _spi->endTransaction(); digitalWrite(_cs, HIGH); return read; } float THERMClass::readTemperature() { uint32_t rawword; float celsius; rawword = readSensor(); // Check for reading error if (rawword & 0x7) { return NAN; } // The temperature is stored in the last 14 word's bits // sendend by the Thermocouple-to-Digital Converter if (rawword & 0x80000000) { // Negative value, drop the lower 18 bits and explicitly extend sign bits. rawword = 0xFFFFC000 | ((rawword >> 18) & 0x00003FFFF); } else { // Positive value, just drop the lower 18 bits. rawword >>= 18; } // multiply for the LSB value celsius = rawword * 0.25f; return celsius; } float THERMClass::readReferenceTemperature() { uint32_t rawword; float ref; rawword = readSensor(); // ignore first 4 FAULT bits rawword >>= 4; // The cold junction reference temperature is stored in the first 11 word's bits // sendend by the Thermocouple-to-Digital Converter rawword = rawword & 0x7FF; // check sign bit and convert to negative value. if (rawword & 0x800) { ref = (0xF800 | (rawword & 0x7FF))*0.0625; } else { // multiply for the LSB value ref = rawword * 0.0625f; } return ref; } THERMClass THERM;
変更されたテキスト
ファイルを開く
/* This file is part of the Arduino_MKRTHERM library. Copyright (c) 2019 Arduino SA. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "MKRTHERM.h" THERMClass::THERMClass(int cs, SPIClass& spi) : _cs(cs), _spi(&spi), _spiSettings(4000000, MSBFIRST, SPI_MODE0) { } int THERMClass::begin() { int32_t rawword; // Change uint32_t to int32_t pinMode(_cs, OUTPUT); digitalWrite(_cs, HIGH); _spi->begin(); rawword = readSensor(); if (rawword == 0xFFFFFF) { end(); return 0; } return 1; } void THERMClass::end() { pinMode(_cs, INPUT); digitalWrite(_cs, LOW); _spi->end(); } uint32_t THERMClass::readSensor() { uint32_t read = 0x00; digitalWrite(_cs, LOW); delayMicroseconds(1); _spi->beginTransaction(_spiSettings); for (int i = 0; i < 4; i++) { read <<= 8; read |= _spi->transfer(0); } _spi->endTransaction(); digitalWrite(_cs, HIGH); return read; } float THERMClass::readTemperature() { int32_t rawword; // Change uint32_t to int32_t float celsius; rawword = readSensor(); // Check for reading error if (rawword & 0x7) { return NAN; } // The temperature is stored in the last 14 bits // sent by the Thermocouple-to-Digital Converter rawword >>= 18; // Drop the lower 18 bits // No need for manual sign extension, int32_t handles it celsius = rawword * 0.25f; return celsius; } float THERMClass::readReferenceTemperature() { uint32_t rawword; float ref; rawword = readSensor(); // Ignore the first 4 FAULT bits rawword >>= 4; // The cold junction reference temperature is stored in the first 11 bits // sent by the Thermocouple-to-Digital Converter rawword = rawword & 0x7FF; // Check the sign bit and convert to negative value if needed. if (rawword & 0x800) { ref = (0xF800 | (rawword & 0x7FF)) * 0.0625; } else { // Multiply by the LSB value ref = rawword * 0.0625f; } return ref; } THERMClass THERM;
違いを見つける