GY-63_MS5611/libraries/GAMMA/gamma.h

62 lines
1.1 KiB
C
Raw Normal View History

2021-01-29 06:31:58 -05:00
#pragma once
//
// FILE: gamma.h
// AUTHOR: Rob Tillaart
2022-07-26 07:16:03 -04:00
// VERSION: 0.3.0
2021-01-29 06:31:58 -05:00
// DATE: 2020-08-08
// PURPOSE: Arduino Library to efficiently hold a gamma lookup table
#include "Arduino.h"
2022-07-26 07:16:03 -04:00
#define GAMMA_LIB_VERSION (F("0.3.0"))
2021-12-18 11:16:37 -05:00
#define GAMMA_DEFAULT_SIZE 32
#define GAMMA_MAX_SIZE 256
2021-01-29 06:31:58 -05:00
class GAMMA
{
public:
2022-07-25 09:25:14 -04:00
GAMMA(uint16_t size = GAMMA_DEFAULT_SIZE);
~GAMMA();
// allocates memory
// sets default gamma = 2.8
2022-07-26 07:16:03 -04:00
// Returns false if allocation fails
bool begin();
2022-07-25 09:25:14 -04:00
// CORE
2022-07-26 07:16:03 -04:00
// Returns false if gamma <= 0
bool setGamma(float gamma);
2022-07-25 09:25:14 -04:00
float getGamma();
// access values with index operator
2022-07-26 07:16:03 -04:00
// index = 0 .. size
2022-07-25 09:25:14 -04:00
uint8_t operator[] (uint8_t index);
// META INFO
uint16_t size();
uint16_t distinct();
// DEBUG
2022-07-26 07:16:03 -04:00
bool dump(Stream *str = &Serial);
bool dumpArray(Stream *str = &Serial);
2021-01-29 06:31:58 -05:00
private:
uint8_t _shift = 0;
uint8_t _mask = 0;
uint16_t _size = 0;
uint8_t _interval = 0;
2022-07-26 07:16:03 -04:00
float _gamma = 1.0; // 1.0 == no gamma, linear.
2021-11-02 10:15:11 -04:00
uint8_t * _table = NULL;
2022-07-26 07:16:03 -04:00
float fastPow(float a, float b);
2021-01-29 06:31:58 -05:00
};
2021-11-02 10:15:11 -04:00
2021-01-29 06:31:58 -05:00
// -- END OF FILE --
2021-11-02 10:15:11 -04:00