2021-12-09 09:05:02 -05:00
|
|
|
//
|
|
|
|
// FILE: map2colour_faucet.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: map2colour demo
|
|
|
|
// URL: https://github.com/RobTillaart/map2colour
|
|
|
|
|
|
|
|
|
2022-10-20 05:58:00 -04:00
|
|
|
// demo simulates a temperature of a faucet mapped upon 2 colours.
|
|
|
|
// blue = cold, black is middle, red is hot
|
2021-12-09 09:05:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
#include "map2colour.h"
|
|
|
|
|
|
|
|
|
|
|
|
map2colour mct;
|
|
|
|
|
2022-10-20 05:58:00 -04:00
|
|
|
// values must be 7 elements in increasing order.
|
2021-12-09 09:05:02 -05:00
|
|
|
float values[7] = { 0, 10, 15, 25, 40, 100, 125 };
|
|
|
|
uint32_t faucet[7] =
|
|
|
|
{
|
|
|
|
M2C_BLUE, M2C_BLUE, M2C_BLACK, M2C_BLACK, M2C_RED, M2C_RED, M2C_RED
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
2022-10-20 05:58:00 -04:00
|
|
|
Serial.print("MAP2COLOUR_LIB_VERSION: ");
|
|
|
|
Serial.println(MAP2COLOUR_LIB_VERSION);
|
|
|
|
Serial.println();
|
2021-12-09 09:05:02 -05:00
|
|
|
|
|
|
|
mct.begin(values, faucet);
|
|
|
|
|
|
|
|
for (int i = -20; i < 125; i++)
|
|
|
|
{
|
|
|
|
uint32_t rgb = mct.map2RGB(i);
|
|
|
|
Serial.print(i);
|
|
|
|
Serial.print("\t");
|
|
|
|
Serial.println(rgb, HEX);
|
|
|
|
}
|
|
|
|
Serial.println();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -- END OF FILE --
|