Utilities for UnitColor.
More...
#include "../unit/unit_TCS3472x.hpp"
#include <cmath>
#include <tuple>
#include <cassert>
Go to the source code of this file.
|
| namespace | m5 |
| | Top level namespace of M5stack.
|
| |
|
|
float | m5::unit::tcs3472x::atime_to_ms (const uint8_t a) |
| | ATIME to ms.
|
| |
|
float | m5::unit::tcs3472x::wtime_to_ms (const uint8_t w, const bool wlong) |
| | WTIME and WLONG to ms.
|
| |
|
uint8_t | m5::unit::tcs3472x::ms_to_atime (const float ms) |
| | ms to ATIME
|
| |
|
std::tuple< uint8_t, bool > | m5::unit::tcs3472x::ms_to_wtime (const float ms) |
| | ms to WTIME and WLONG
|
| |
| float | m5::unit::tcs3472x::calculateLux (const uint16_t rawR, const uint16_t rawG, const uint16_t rawB, const uint16_t rawC, const float atime_ms, const Gain gc, const float dgf=DGF, const float coefR=R_Coef, const float coefG=G_Coef, const float coefB=B_Coef) |
| | Calculate Lux.
|
| |
| float | m5::unit::tcs3472x::calculateColorTemperature (const uint16_t rawR, const uint16_t rawG, const uint16_t rawB, const uint16_t rawC, const float coefCT=CT_Coef, const float offsetCT=CT_Offset) |
| | Calculate color temperature(degrees Kelvin)
|
| |
| uint16_t | m5::unit::tcs3472x::calculateSaturation (const uint8_t atime) |
| | Calculate Saturation.
|
| |
| uint16_t | m5::unit::tcs3472x::calculateSaturation (const float atime_ms) |
| | Calculate Saturation.
|
| |
| float | m5::unit::tcs3472x::calculateCRATIO (const uint16_t rawR, const uint16_t rawG, const uint16_t rawB, const uint16_t rawC) |
| | Calculate CRATIO.
|
| |
| float | m5::unit::tcs3472x::calculateCPL (const float atime_ms, const Gain gc, const float dgf=DGF) |
| | Calculate Counts per Lux (CPL)
|
| |
| float | m5::unit::tcs3472x::calculateMaxLux (const float atime_ms, const Gain gc, const float dgf=DGF) |
| | Calculate maximum Lux.
|
| |
| template<size_t Size = 256> |
| M5_UNIT_COLOR_UTILITY_UNIT_COLOR_UTILITY_CONSTEXPR std::array< uint8_t, Size > | m5::unit::tcs3472x::make_gamma_table (const float gamma=2.2f) |
| | Make gamma table.
|
| |
|
|
|
constexpr float | m5::unit::tcs3472x::GA {1.0f} |
| |
|
constexpr float | m5::unit::tcs3472x::DF {310.f} |
| |
|
constexpr float | m5::unit::tcs3472x::DGF {GA * DF} |
| |
|
constexpr float | m5::unit::tcs3472x::R_Coef {0.136f} |
| |
|
constexpr float | m5::unit::tcs3472x::G_Coef {1.0f} |
| |
|
constexpr float | m5::unit::tcs3472x::B_Coef {-0.444f} |
| |
|
constexpr float | m5::unit::tcs3472x::CT_Coef {3810.f} |
| |
|
constexpr float | m5::unit::tcs3472x::CT_Offset {1391.f} |
| |
|
|
constexpr float | m5::unit::tcs3472x::AT_NORMAL_FACTOR = 2.4f |
| |
|
constexpr float | m5::unit::tcs3472x::AT_NORMAL_MIN = AT_NORMAL_FACTOR |
| |
|
constexpr float | m5::unit::tcs3472x::AT_NORMAL_MAX = 256 * AT_NORMAL_FACTOR |
| |
|
constexpr float | m5::unit::tcs3472x::WT_NORMAL_FACTOR = AT_NORMAL_FACTOR |
| |
|
constexpr float | m5::unit::tcs3472x::WT_NORMAL_MIN = WT_NORMAL_FACTOR |
| |
|
constexpr float | m5::unit::tcs3472x::WT_NORMAL_MAX = 256 * WT_NORMAL_FACTOR |
| |
|
constexpr float | m5::unit::tcs3472x::WT_LONG_FACTOR = 2.4f * 12.f |
| |
|
constexpr float | m5::unit::tcs3472x::WT_LONG_MIN = WT_LONG_FACTOR |
| |
|
constexpr float | m5::unit::tcs3472x::WT_LONG_MAX = 256 * WT_LONG_FACTOR |
| |
◆ calculateColorTemperature()
| float m5::unit::tcs3472x::calculateColorTemperature |
( |
const uint16_t | rawR, |
|
|
const uint16_t | rawG, |
|
|
const uint16_t | rawB, |
|
|
const uint16_t | rawC, |
|
|
const float | coefCT = CT_Coef, |
|
|
const float | offsetCT = CT_Offset ) |
Calculate color temperature(degrees Kelvin)
- Parameters
-
| rawR | Raw red value |
| rawG | Raw green value |
| rawB | Raw blue value |
| rawC | Raw clear value |
| coefCT | Coefficient for the color temperature |
| offsetCT | Offset for the the color temperature |
- Returns
- Color temperature(degrees Kelvin)
◆ calculateCPL()
| float m5::unit::tcs3472x::calculateCPL |
( |
const float | atime_ms, |
|
|
const Gain | gc, |
|
|
const float | dgf = DGF ) |
Calculate Counts per Lux (CPL)
- Parameters
-
| atime_ms | integtation time(ms) |
| gc | Gain |
| dgf | Device and Glass Factor |
- Returns
- CPL
◆ calculateCRATIO()
| float m5::unit::tcs3472x::calculateCRATIO |
( |
const uint16_t | rawR, |
|
|
const uint16_t | rawG, |
|
|
const uint16_t | rawB, |
|
|
const uint16_t | rawC ) |
Calculate CRATIO.
- Parameters
-
| rawR | raw red value |
| rawG | raw green value |
| rawB | raw blue value |
| rawC | raw clear value |
- Returns
- CRATIO (0.0f - 1.0f) Guidelines for CRATIO and Light Source Correspondence
| Compare | Description |
| CRATIO < 0.1 | LED or fluorescent light |
| 0.1 <= CRATIO < 0.25 | Sunlight |
| 0.25 <0 CRATIO | Incandescent light |
◆ calculateLux()
| float m5::unit::tcs3472x::calculateLux |
( |
const uint16_t | rawR, |
|
|
const uint16_t | rawG, |
|
|
const uint16_t | rawB, |
|
|
const uint16_t | rawC, |
|
|
const float | atime_ms, |
|
|
const Gain | gc, |
|
|
const float | dgf = DGF, |
|
|
const float | coefR = R_Coef, |
|
|
const float | coefG = G_Coef, |
|
|
const float | coefB = B_Coef ) |
Calculate Lux.
- Parameters
-
| rawR | Raw red value |
| rawG | Raw green value |
| rawB | Raw blue value |
| rawC | Raw clear value |
| atime_ms | Integtation time(ms) |
| gc | Gain |
| dgf | Device and Glass Factor |
| coefR | Coefficient for the R channel |
| coefG | Coefficient for the G channel |
| coefB | Coefficient for the B channel |
- Returns
- Lux (lx)
◆ calculateMaxLux()
| float m5::unit::tcs3472x::calculateMaxLux |
( |
const float | atime_ms, |
|
|
const Gain | gc, |
|
|
const float | dgf = DGF ) |
|
inline |
Calculate maximum Lux.
- Parameters
-
| atime_ms | integtation time(ms) |
| gc | Gain |
| dgf | Device and Glass Factor |
- Returns
- Lux(lx)
◆ calculateSaturation() [1/2]
| uint16_t m5::unit::tcs3472x::calculateSaturation |
( |
const float | atime_ms | ) |
|
|
inline |
Calculate Saturation.
- Parameters
-
- Returns
- Saturation value
- Note
- Ripple saturation is also considered (in Analog)
◆ calculateSaturation() [2/2]
| uint16_t m5::unit::tcs3472x::calculateSaturation |
( |
const uint8_t | atime | ) |
|
Calculate Saturation.
- Parameters
-
- Returns
- Saturation value
- Note
- Ripple saturation is also considered (in Analog)
◆ make_gamma_table()
template<size_t Size = 256>
| M5_UNIT_COLOR_UTILITY_UNIT_COLOR_UTILITY_CONSTEXPR std::array< uint8_t, Size > m5::unit::tcs3472x::make_gamma_table |
( |
const float | gamma = 2.2f | ) |
|
Make gamma table.
- Template Parameters
-
- Parameters
-
- Returns
- std::array<uint8_t, Size> gamma table
- Note
- Make on compile time if it can