63 lines
1.2 KiB
C
Raw Normal View History

2021-12-04 21:32:57 +01:00
#pragma once
//
// FILE: map2colour.h
// AUTHOR: Rob Tillaart
2023-04-26 09:26:03 +02:00
// VERSION: 0.2.0
2021-12-04 21:32:57 +01:00
// PURPOSE: Arduino library for mapping a float to colour spectrum
// URL: https://github.com/RobTillaart/map2colour
#include "Arduino.h"
2023-04-26 09:26:03 +02:00
#include "m2c_colours.h"
2021-12-04 21:32:57 +01:00
2023-04-26 09:26:03 +02:00
#define MAP2COLOUR_LIB_VERSION (F("0.2.0"))
2023-02-21 17:01:58 +01:00
2021-12-04 21:32:57 +01:00
class map2colour
{
public:
2023-04-26 09:26:03 +02:00
map2colour(uint8_t size = 7);
~map2colour();
2021-12-04 21:32:57 +01:00
2023-04-26 09:26:03 +02:00
// values is an array of size values in ascending order
bool begin(float * values, uint32_t * colourMap = NULL);
uint8_t size();
2021-12-04 21:32:57 +01:00
uint32_t map2RGB(float value);
2021-12-09 15:05:02 +01:00
uint16_t map2_565(float value);
2021-12-04 21:32:57 +01:00
2021-12-09 15:05:02 +01:00
protected:
2023-04-26 09:26:03 +02:00
uint8_t _size;
2021-12-04 21:32:57 +01:00
float * _values;
2021-12-09 15:05:02 +01:00
2023-04-26 09:26:03 +02:00
uint8_t * _Red;
uint8_t * _Green;
uint8_t * _Blue;
2021-12-04 21:32:57 +01:00
};
2021-12-09 15:05:02 +01:00
/////////////////////////////////////////////////////////////////////////
//
2022-10-20 11:58:00 +02:00
// DERIVED CLASS
2021-12-09 15:05:02 +01:00
//
2022-10-20 11:58:00 +02:00
// FASTER + MORE RAM
2021-12-09 15:05:02 +01:00
//
class map2colourFast : public map2colour
{
public:
2023-04-26 09:26:03 +02:00
map2colourFast(uint8_t size = 7);
~map2colourFast();
// values is an array of size values in ascending order
2021-12-09 15:05:02 +01:00
bool begin(float * values, uint32_t * colourMap = NULL);
uint32_t map2RGB(float value);
uint16_t map2_565(float value);
2021-12-04 21:32:57 +01:00
2021-12-09 15:05:02 +01:00
private:
2023-04-26 09:26:03 +02:00
float * divFactor;
2021-12-09 15:05:02 +01:00
};
2023-02-21 17:01:58 +01:00
// -- END OF FILE --
2021-12-04 21:32:57 +01:00