#!/usr/bin/env python
# coding=utf-8

# clear && python3 /home/scripts_python/test_03.py

import os, sys
from PIL import Image
import time
import math


def rgb2hex(color):
    """Converts a list or tuple of color to an RGB string

    Args:
        color (list|tuple): the list or tuple of integers (e.g. (127, 127, 127))

    Returns:
        str:  the rgb string
    """
    return f"#{''.join(f'{hex(c)[2:].upper():0>2}' for c in color)}"


diagramme_T_HR   = Image.open("/home/scripts_python/diagramme_confort_T_HR.bmp")
diagramme_pixels = diagramme_T_HR.load()


AQCM05_TEMP_avec_filtre = 20.0
AQCM05_HUMI_avec_filtre = 40

for i in range (1,49) :

	AQCM05_HUMI_avec_filtre = 2 * i
	x = int( ( AQCM05_TEMP_avec_filtre - 13.0 ) * 600/15 )
	y = int( ( 100.0 - AQCM05_HUMI_avec_filtre ) * 400/100 )
	couleur = diagramme_pixels[x,y]
	couleur_str = rgb2hex(couleur)

	print( AQCM05_TEMP_avec_filtre, AQCM05_HUMI_avec_filtre, couleur_str )
