Skip to content

Commit de6544a

Browse files
committed
update libraries J..M
1 parent d13cd04 commit de6544a

File tree

78 files changed

+2301
-916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2301
-916
lines changed

libraries/LineFormatter/LineFormatter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
//
22
// FILE: LineFormatter.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
4+
// VERSION: 0.1.1
55
// PURPOSE: Simpe positioning wrapper class for Serial
66
// DATE: 2020-05-14
77
// URL: https://github.com/RobTillaart/LineFormatter
88
//
99
// HISTORY:
1010
// 0.1.0 2020-05-14 initial version
11+
// 0.1.1 2020-06-19 fix library.json
1112
//
1213

1314

libraries/LineFormatter/LineFormatter.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
//
33
// FILE: LineFormatter.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.1.0
5+
// VERSION: 0.1.1
66
// PURPOSE: Simpe positioning wrapper class for Serial
77
// DATE: 2020-05-14
88
// URL: https://github.com/RobTillaart/LineFormatter
99
//
10-
// HISTORY:
11-
// 0.1.0 2020-05-14 initial version
12-
//
1310

1411
#include "Arduino.h"
1512
#include "Print.h"

libraries/LineFormatter/library.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/LineFormatter.git"
1717
},
18-
"version":"0.1.0",
18+
"version":"0.1.1",
1919
"frameworks": "arduino",
20-
"platforms": "*",
21-
"export": {
22-
"include": "LineFormatter"
23-
}
20+
"platforms": "*"
2421
}

libraries/LineFormatter/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=LineFormatter
2-
version=0.1.0
2+
version=0.1.1
33
author=Rob Tillaart <rob.tillaart@gmail.com>
44
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
55
sentence=Wrapper class for Serial to enhance layout of tabular data.

libraries/MAX31855/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2014-2020 Rob Tillaart
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

libraries/MAX31855/MAX31855.cpp

Lines changed: 142 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,184 @@
11
//
22
// FILE: MAX31855.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.10
5-
// PURPOSE: MAX31855 - Thermocouple
4+
// VERSION: 0.2.3
5+
// PURPOSE: Arduino library for MAX31855 chip for K type thermocouple
66
// DATE: 2014-01-01
7-
// URL: http://forum.arduino.cc/index.php?topic=208061
7+
// URL: https://github.com/RobTillaart/MAX31855_RT
88
//
99
// HISTORY:
10+
//
11+
// 0.2.3 2020-08-30 fix #8 support hardware SPI + example
12+
// 0.2.2 2020-08-30 fix#9 + fix failing examples + minor refactor
13+
// 0.2.1 2020-08-26 read rawData and STATUS_NO_COMMUNICATION recognition (thanks to FabioBrondo)
14+
// 0.2.0 2020-06-20 #pragma once; major refactor; removed pre 1.0 support; fix offset
1015
// 0.1.10 2019-07-31 add 3 inline functions to test errors + demo sketch
1116
// 0.1.9 2017-07-27 reverted double -> float (issue33)
1217
// 0.1.08 2015-12-06 replaced all temperature calls with one TCfactor + update demos.
1318
// 0.1.07 2015-12-06 updated TC factors from the MAX31855 datasheet
1419
// 0.1.06 2015-12-05 added support for other types of TC's (experimental)
1520
// 0.1.05 2015-07-12 refactor robust constructor
1621
// 0.1.04 2015-03-09 replaced float -> double (ARM support)
17-
// 0.1.03 fixed negative temperature
18-
// 0.1.02 added offset
19-
// 0.1.01 refactored speed/performance
20-
// 0.1.00 initial version.
21-
//
22-
// Released to the public domain
22+
// 0.1.03 2014-01-24 fixed negative temperature
23+
// 0.1.02 2014-01-03 added offset
24+
// 0.1.01 2014-01-02 refactored speed/performance
25+
// 0.1.00 2014-01-02 initial version.
2326
//
2427

28+
2529
#include "MAX31855.h"
2630

31+
32+
MAX31855::MAX31855(const uint8_t cs)
33+
{
34+
_cs = cs;
35+
_hwSPI = true;
36+
37+
_offset = 0;
38+
_SC = K_TC;
39+
_status = STATUS_NOREAD;
40+
_temperature = -999;
41+
_internal = -999;
42+
}
43+
2744
MAX31855::MAX31855(const uint8_t sclk, const uint8_t cs, const uint8_t miso)
2845
{
29-
_sclk = sclk;
30-
_cs = cs;
31-
_miso = miso;
32-
_offset = 0;
33-
_TCfactor = K_TC;
34-
_status = STATUS_NOREAD;
35-
_temperature = -999;
36-
_internal = -999;
46+
_sclk = sclk;
47+
_cs = cs;
48+
_miso = miso;
49+
_hwSPI = false;
50+
51+
_offset = 0;
52+
_SC = K_TC;
53+
_status = STATUS_NOREAD;
54+
_temperature = -999;
55+
_internal = -999;
3756
}
3857

3958
void MAX31855::begin()
4059
{
41-
pinMode(_cs, OUTPUT);
42-
digitalWrite(_cs, HIGH);
43-
60+
pinMode(_cs, OUTPUT);
61+
digitalWrite(_cs, HIGH);
62+
if (_hwSPI)
63+
{
64+
SPI.begin();
65+
delay(1);
66+
}
67+
else
68+
{
4469
pinMode(_sclk, OUTPUT);
4570
pinMode(_miso, INPUT);
71+
}
4672
}
4773

74+
4875
uint8_t MAX31855::read()
4976
{
50-
uint32_t value = _read();
51-
52-
// process status bit 0-2
53-
_status = value & 0x0007;
54-
value >>= 3;
55-
56-
// reserved bit 3
57-
value >>= 1;
58-
59-
// process internal bit 4-15
60-
_internal = (value & 0x07FF) * 0.0625;
61-
if (value & 0x0800)
62-
{
63-
_internal = -128 + _internal; // fix neg temp
64-
}
65-
value >>= 12;
66-
67-
// Fault bit ignored as we have the 3 status bits
68-
// _fault = value & 0x01;
69-
value >>= 1;
77+
// return value of _read()
78+
// BITS DESCRIPTION
79+
// ----------------------
80+
// 00 - 02 STATUS
81+
// 03 RESERVED
82+
// 04 - 15 INTERNAL
83+
// 16 FAULT-BIT
84+
// 17 RESERVED
85+
// 18 - 30 TEMPERATURE (RAW)
86+
// 31 SIGN
87+
uint32_t value = _read();
88+
89+
if (value == 0xFFFFFFFF) // needs a pull up on miso pin to work properly!
90+
{
91+
// bit 3 and bit 17 should always be 0 - P10 datasheet
92+
_status = STATUS_NO_COMMUNICATION;
93+
return _status;
94+
}
7095

71-
// reserved bit 17
72-
value >>= 1;
73-
74-
// process temperature bit 18-30 + sign bit = 31
75-
_temperature = (value & 0x1FFF) * 0.25;
76-
if (value & 0x2000) // negative flag
77-
{
78-
_temperature = -2048 + _temperature; // fix neg temp
79-
}
80-
if (_offset != 0) _temperature += _offset;
96+
_lastRead = millis();
8197

98+
// process status bit 0-2
99+
_status = value & 0x0007;
100+
if (_status != STATUS_OK)
101+
{
82102
return _status;
103+
}
104+
105+
value >>= 3;
106+
107+
// reserved bit 3, always 0
108+
value >>= 1;
109+
110+
// process internal bit 4-15
111+
_internal = (value & 0x07FF) * 0.0625;
112+
// negative flag set ?
113+
if (value & 0x0800)
114+
{
115+
_internal = -128 + _internal;
116+
}
117+
value >>= 12;
118+
119+
// Fault bit ignored as we have the 3 status bits
120+
// _fault = value & 0x01;
121+
value >>= 1;
122+
123+
// reserved bit 17, always 0
124+
value >>= 1;
125+
126+
// process temperature bit 18-30 + sign bit = 31
127+
_temperature = (value & 0x1FFF) * 0.25;
128+
// negative flag set ?
129+
if (value & 0x2000)
130+
{
131+
_temperature = -2048 + _temperature;
132+
}
133+
return _status;
83134
}
84135

85-
// TODO: optimize performance by direct port manipulation?
136+
86137
uint32_t MAX31855::_read(void)
87138
{
88-
uint32_t value = 0;
89-
90-
digitalWrite(_cs, LOW);
91-
139+
_rawData = 0;
140+
digitalWrite(_cs, LOW);
141+
if (_hwSPI)
142+
{
143+
SPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0));
144+
for (uint8_t i = 0; i < 4; i++)
145+
{
146+
_rawData <<= 8;
147+
_rawData += SPI.transfer(0);
148+
}
149+
SPI.endTransaction();
150+
}
151+
else
152+
{
92153
for (int8_t i = 31; i >= 0; i--)
93154
{
94-
value <<= 1;
95-
digitalWrite(_sclk, LOW);
96-
// delayMicroseconds(1); // DUE
97-
if ( digitalRead(_miso) ) value += 1;
98-
digitalWrite(_sclk, HIGH);
99-
// delayMicroseconds(1); // DUE
155+
_rawData <<= 1;
156+
digitalWrite(_sclk, LOW);
157+
// delayMicroseconds(1); // DUE
158+
if ( digitalRead(_miso) ) _rawData++;
159+
digitalWrite(_sclk, HIGH);
160+
// delayMicroseconds(1); // DUE
100161
}
162+
}
163+
digitalWrite(_cs, HIGH);
164+
return _rawData;
165+
}
101166

102-
digitalWrite(_cs, HIGH);
103-
104-
return value;
167+
float MAX31855::getTemperature()
168+
{
169+
// offset needs to be added after multiplication TCfactor
170+
// not before otherwise offset will be larger / smaller
171+
// default behavior
172+
if (_SC == K_TC) return _temperature + _offset;
173+
174+
// EXPERIMENTAL OTHER THERMOCOUPLES
175+
// in practice this works also for K_TC but is way slower..
176+
// 1: reverse calculate the Voltage measured
177+
float Vout = K_TC * (_temperature - _internal); // PAGE 8 datasheet
178+
179+
// 2: from Voltage to corrected temperature using the Seebeck Coefficient
180+
float _temp = Vout / _SC + _internal;
181+
return _temp;
105182
}
106183

107-
// END OF FILE
184+
// -- END OF FILE --

0 commit comments

Comments
 (0)