GY-63_MS5611/libraries/AtomicWeight/AtomicWeight.h

61 lines
1.3 KiB
C
Raw Normal View History

2022-12-30 11:29:07 -05:00
#pragma once
//
// FILE: AtomicWeight.h
// AUTHOR: Rob Tillaart
// DATE: 2022-03-09
2023-01-02 07:02:36 -05:00
// VERSION: 0.1.3
2022-12-30 11:29:07 -05:00
// PURPOSE: Arduino library for atomic weights
// URL: https://github.com/RobTillaart/AtomicWeight
#include "Arduino.h"
2023-01-02 07:02:36 -05:00
#define ATOMIC_WEIGHT_LIB_VERSION (F("0.1.3"))
2022-12-30 11:29:07 -05:00
/////////////////////////////////////////////////////////////////////////
//
2022-12-31 12:30:42 -05:00
// PERIODIC TABLE OF ELEMENTS Class
2022-12-30 11:29:07 -05:00
//
class PTOE
{
public:
2023-01-02 07:02:36 -05:00
PTOE(const uint8_t size = 118); // all by default
2022-12-31 11:38:51 -05:00
uint8_t size();
2023-01-02 07:02:36 -05:00
uint8_t electrons(const uint8_t el);
uint8_t neutrons(const uint8_t el);
uint8_t protons(const uint8_t el);
2022-12-30 11:29:07 -05:00
2023-01-02 07:02:36 -05:00
// weight of one atom
float weight(const uint8_t el);
2022-12-30 11:29:07 -05:00
2023-01-02 07:02:36 -05:00
// if (el != NULL) weights one element in a formula, e.g el == "H"
// if (el == NULL) weights the whole formula
float weight(const char * formula, const char * el = NULL);
// mass percentage of one element in a formula.
float massPercentage(const char * formula, const char * el);
2022-12-30 11:29:07 -05:00
2023-01-02 07:02:36 -05:00
char * name(const uint8_t el);
2022-12-31 12:30:42 -05:00
uint8_t find(const char * abbrev);
2022-12-30 11:29:07 -05:00
// DEBUG
2022-12-31 11:38:51 -05:00
float weightFactor();
2022-12-30 11:29:07 -05:00
private:
uint8_t _size;
const float _weightFactor = 1.0 / 222.909;
2022-12-31 12:30:42 -05:00
2023-01-02 07:02:36 -05:00
// if (el == NULL) ==> whole weight otherwise only of element.
float _weight(char sep, const char * el);
2022-12-31 12:30:42 -05:00
char *p; // for _weight().
2022-12-30 11:29:07 -05:00
};
// -- END OF FILE --