- Added function to read out the display_buffer via USB-Serial - Added basic structure and files for later complete firmware (still in progress) - Added Doc folder with schematic in it - Added Python script and batch file to read out the display buffer and open the image in gimp
80 lines
1.8 KiB
C
80 lines
1.8 KiB
C
/*
|
|
* Hue.c
|
|
*
|
|
* Created: Sun Jan 29 2023 10:51:34
|
|
* Author Chris
|
|
*/
|
|
// ============================================================================================
|
|
// Includes
|
|
#include "Hue.h"
|
|
|
|
#include "Command_Definition.h"
|
|
|
|
|
|
// ============================================================================================
|
|
// Defines
|
|
|
|
|
|
// ============================================================================================
|
|
// Varables
|
|
|
|
|
|
// ============================================================================================
|
|
// Function Declarations
|
|
|
|
|
|
/*******************************************************************
|
|
Public Functions
|
|
*******************************************************************/
|
|
Pixel_Value Hue_Get_Color_From_Angle(int hue_angle)
|
|
{
|
|
LED_Data_t Result;
|
|
Result.Pixel = 0;
|
|
|
|
while(hue_angle < 0) {
|
|
hue_angle += 360;
|
|
}
|
|
|
|
hue_angle %= 360;
|
|
|
|
///////////
|
|
// Red //
|
|
///////////
|
|
if(hue_angle <=60 || hue_angle >= 300) {
|
|
Result.R = 255;
|
|
}
|
|
else if(hue_angle > 60 && hue_angle < 120) {
|
|
Result.R = (uint8_t)((255ul * (60ul-(hue_angle-60ul))) / 60ul);
|
|
}
|
|
else if(hue_angle > 240 && hue_angle < 300) {
|
|
Result.R = (uint8_t)((255ul * (hue_angle-240)) / 60ul);
|
|
}
|
|
|
|
///////////
|
|
// Green //
|
|
///////////
|
|
if(hue_angle >= 60 && hue_angle <= 180) {
|
|
Result.G = 255;
|
|
}
|
|
else if(hue_angle < 60) {
|
|
Result.G = (uint8_t)((255ul * hue_angle) / 60ul);
|
|
}
|
|
else if(hue_angle > 180 && hue_angle < 240) {
|
|
Result.G = (uint8_t)((255ul * (60ul-(hue_angle-180ul))) / 60ul);
|
|
}
|
|
|
|
///////////
|
|
// Blue //
|
|
///////////
|
|
if(hue_angle >= 180 && hue_angle <= 300) {
|
|
Result.B = 255;
|
|
}
|
|
else if(hue_angle > 120 && hue_angle < 180) {
|
|
Result.B = (uint8_t)((255ul * (hue_angle-120)) / 60ul);
|
|
}
|
|
else if(hue_angle > 300 && hue_angle < 360) {
|
|
Result.B = (uint8_t)((255ul * (60ul-(hue_angle-300ul))) / 60ul);
|
|
}
|
|
|
|
return Result.Pixel;
|
|
} |