/*
 * @Date: 2025-07-04 13:05:34
 * @Author: mypx
 * @LastEditors: mypx mypx_coder@163.com
 * @LastEditTime: 2025-07-10 16:14:16
 * @FilePath: pt100x.h
 * @Description: 
 * Copyright (c) 2025 by mypx, All Rights Reserved.
 */
#ifndef __PT100X_H__
#define __PT100X_H__
#include <math.h>
// Enum type for PT sensor types
typedef enum
{
    PT100  = 0,
    PT1000 = 1,
} PtType;

/**
 * @brief Calculate the temperature based on the resistance value of a PT100 
 *        platinum resistor (precise calculation).
 * @param resistance Measured resistance value (Ω).
 * @param ptType Type of the PT sensor (PT100 or PT1000).
 * @return Temperature value (°C), returns NaN if the resistance value is invalid.
 */
double pt_precise_temperature(double resistance, PtType ptType);

/**
 * @brief Calculate the temperature based on the resistance value of a PT100 platinum resistor 
 * (engineering approximation).
 * @param resistance Measured resistance value (Ω).
 * @param type Type of the PT sensor (PT100 or PT1000).
 * @return Temperature value (°C).
 */
double pt_approximate_temperature(double resistance, PtType type);

float pt_temperature_to_resistance(double t, PtType type);

#endif /* __PT100_H__ */
