Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystem
max6675_2.cpp
- Committer:
- BoostNori
- Date:
- 2020-03-19
- Revision:
- 0:d68d5418c985
File content as of revision 0:d68d5418c985:
#include <mbed.h> #include "max6675_2.h" max6675_2::max6675_2(SPI& _spi_2, PinName _ncs_2) : spi_2(_spi_2), ncs_2(_ncs_2) { } float max6675_2::read_temp_2() { short value_2 = 0; float temp_2 = 0; uint8_t highByte_2=0; uint8_t lowByte_2=0; select_2(); wait(.25); //This delay is needed else it does'nt seem to update the temp highByte_2 = spi_2.write(0); lowByte_2 = spi_2.write(0); deselect_2(); if (lowByte_2 & (1<<2)) { error("No Probe"); } else { value_2 = (highByte_2 << 5 | lowByte_2>>3); } temp_2 = (value_2*0.25); // Multiply the value by 0.25 to get temp in ˚C or // * (9.0/5.0)) + 32.0; // Convert value to ˚F (ensure proper floats!) return temp_2; } void max6675_2::select_2() { ncs_2 = 0; } void max6675_2::deselect_2() { ncs_2 = 1; }