Enviro+ code modification help needed

I want to change the scale used from 0.1 vertically per pixel / dot to 1.0 per pixel / dot on the LCD. Code I’m using is at bottom of post.

I have two 0.96 SPI Color LCD’s running a modified Enviro+ all in one mini python example file. One shows the temperature graph (the one shown on the display on the product page) and the other showing the Humidity graph. Data comes from a BME280 breakout. That all works fine with the stock data reading intervals. The graphs respond quickly to blowing on the BME280.
Now for my issue. I would like to increase the time between readings so the display is showing an Hour or Two Hours of data across the full width of the display. That I can do, and it works great for Pressure. The Barometric pressure changes very slowly over time so a long graph is needed to spot a trend, rising or falling.
With the temperature and pressure that doesn’t work so well because they can change by a bigger amount in a short period of time. This causes a messy plot up and down that’s hard to follow.
Each vertical dot on the display represents a 0.1 change. That’s a spread of 6 degrees C or 6 MB. I want to change that so each dot is a 1.0 change instead of 0.1.
I have no idea how to do that and still have it show the correct value in text across the top of the screen.

 # Displays data and text on the 0.96" LCD
def display_text2(variable, data, unit):
    # Maintain length of list
    values[variable] = values[variable][1:] + [data]
    # Scale the values for the variable between 0 and 1
    vmin = min(values[variable])
    vmax = max(values[variable])
    colours = [(v - vmin + 1) / (vmax - vmin + 1) for v in values[variable]]
    # Format the variable name and value
    message = "{}:{:.0f}{}".format(variable[:11],data,unit)
    logging.info(message)
    draw.rectangle((0, 0, WIDTH, HEIGHT), (255, 255, 255))
    for i in range(len(colours)):
        # Convert the values to colours from red to blue
        colour = (1.0 - colours[i]) * 0.6
        r, g, b = [int(x * 255.0) for x in colorsys.hsv_to_rgb(colour, 1.0, 1.0)]
        # Draw a 1-pixel wide rectangle of colour
        draw.rectangle((i, top_pos, i + 1, HEIGHT), (r, g, b))
        # Draw a line graph in black
        line_y = HEIGHT - (top_pos + (colours[i] * (HEIGHT - top_pos))) + top_pos
        draw.rectangle((i, line_y, i + 1, line_y + 1), (0, 0, 0))
    # Write the text at the top in black
    draw.text((0, 0), message, font=font, fill=(0, 0, 0))
    disp2.display(img)
    if mode == 1:
        mode %= len(variables)
        last_page = time.time()
        # variable = "Humidity"
        unit = "%"
        data = bme280.get_humidity()
        display_text2(variables[mode], data, unit)
        mode = 0

The full file is as follows, at some point I’m going to add a third Display on SPI1. I would welcome any suggestions on how to simplify the code. I have at best average Python skills. I’d also really like to get rid of the Mode part, as I’m not using the light and proximity sensor, I’m not switching modes on one screen. Any time I have tried to strip that out I break things.

#!/usr/bin/env python3

import time
import colorsys
import os
import sys
import ST7735
import RPi.GPIO as GPIO
import logging

from sys import exit
from bme280 import BME280
from subprocess import PIPE, Popen
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
from fonts.ttf import RobotoMedium as UserFont

def Shutdown(channel):  
    os.system("sudo shutdown now -P")
    time.sleep(30)

GPIO.setmode(GPIO.BCM)  
GPIO.setwarnings(False)
GPIO.setup(26, GPIO.IN, pull_up_down = GPIO.PUD_UP)

GPIO.add_event_detect(26, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)

logging.basicConfig(
    format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
    level=logging.INFO,
    datefmt='%Y-%m-%d %H:%M:%S')

logging.info("""all-in-one.py - Displays readings from all of Enviro plus' sensors
Press Ctrl+C to exit!
""")

# BME280 temperature/pressure/humidity sensor
bme280 = BME280()

# Create ST7735 LCD display class
disp1 = ST7735.ST7735(
    port=0,
    cs=0, 
    dc=9,
    backlight=6, 
    rotation=90,
    spi_speed_hz=10000000
)

disp2 = ST7735.ST7735(
    port=0,
    cs=1, 
    dc=9,
    backlight=12, 
    rotation=90,
    spi_speed_hz=10000000
)

#disp3 = ST7735.ST7735(
#    port=1,
#    cs=0, 
#    dc=19,
#    backlight=16, 
#    rotation=90,
#    spi_speed_hz=10000000
#)

# Initialize display
disp1.begin()

WIDTH = disp1.width
HEIGHT = disp1.height
# Initialize display

disp2.begin()

WIDTH = disp2.width
HEIGHT = disp2.height


# Set up canvas and font
img = Image.new('RGB', (WIDTH, HEIGHT), color=(0, 0, 0))
draw = ImageDraw.Draw(img)
path = os.path.dirname(os.path.realpath(__file__))
font_size = 20
font = ImageFont.truetype(UserFont, font_size)

message = ""

# The position of the top bar
top_pos = 25


# Displays data and text on the 0.96" LCD
def display_text1(variable, data, unit):
    # Maintain length of list
    values[variable] = values[variable][1:] + [data]
    # Scale the values for the variable between 0 and 1
    vmin = min(values[variable])
    vmax = max(values[variable])
    colours = [(v - vmin + 1) / (vmax - vmin + 1) for v in values[variable]]
    # Format the variable name and value
    message = "{}:{:.0f}{}".format(variable[:11],data,unit)
    logging.info(message)
    draw.rectangle((0, 0, WIDTH, HEIGHT), (255, 255, 255))
    for i in range(len(colours)):
        # Convert the values to colours from red to blue
        colour = (1.0 - colours[i]) * 0.6
        r, g, b = [int(x * 255.0) for x in colorsys.hsv_to_rgb(colour, 1.0, 1.0)]
        # Draw a 1-pixel wide rectangle of colour
        draw.rectangle((i, top_pos, i + 1, HEIGHT), (r, g, b))
        # Draw a line graph in black
        line_y = HEIGHT - (top_pos + (colours[i] * (HEIGHT - top_pos))) + top_pos
        draw.rectangle((i, line_y, i + 1, line_y + 1), (0, 0, 0))
    # Write the text at the top in black
    draw.text((0, 0), message, font=font, fill=(0, 0, 0))
    disp1.display(img)

# Displays data and text on the 0.96" LCD
def display_text2(variable, data, unit):
    # Maintain length of list
    values[variable] = values[variable][1:] + [data]
    # Scale the values for the variable between 0 and 1
    vmin = min(values[variable])
    vmax = max(values[variable])
    colours = [(v - vmin + 1) / (vmax - vmin + 1) for v in values[variable]]
    # Format the variable name and value
    message = "{}:{:.0f}{}".format(variable[:11],data,unit)
    logging.info(message)
    draw.rectangle((0, 0, WIDTH, HEIGHT), (255, 255, 255))
    for i in range(len(colours)):
        # Convert the values to colours from red to blue
        colour = (1.0 - colours[i]) * 0.6
        r, g, b = [int(x * 255.0) for x in colorsys.hsv_to_rgb(colour, 1.0, 1.0)]
        # Draw a 1-pixel wide rectangle of colour
        draw.rectangle((i, top_pos, i + 1, HEIGHT), (r, g, b))
        # Draw a line graph in black
        line_y = HEIGHT - (top_pos + (colours[i] * (HEIGHT - top_pos))) + top_pos
        draw.rectangle((i, line_y, i + 1, line_y + 1), (0, 0, 0))
    # Write the text at the top in black
    draw.text((0, 0), message, font=font, fill=(0, 0, 0))
    disp2.display(img)
    

last_page = 0
light = 1

# Create a values dict to store the data
variables = ["Temperature",
             "Humidity",
             "Pressure"]

values = {}

for v in variables:
    values[v] = [1] * WIDTH

# The main loop

mode = 0
F = 1

while True:

    if F >= 161:
        time.sleep(5)
    elif F < 161:
        F = F + 1  
    
    if mode == 0:
        mode %= len(variables)
        last_page = time.time()
        # variable = "Temperature"
        unit = "C"
        data = bme280.get_temperature()
        display_text1(variables[mode], data, unit)
        mode = 1

    if mode == 1:
        mode %= len(variables)
        last_page = time.time()
        # variable = "Humidity"
        unit = "%"
        data = bme280.get_humidity()
        display_text2(variables[mode], data, unit)
        mode = 0
        
#    if mode == 2:
#        mode %= len(variables)
#        last_page = time.time()
#        # variable = "Pressure"
#        unit = "mb"
#        data = bme280.get_pressure()
#        display_text3(variables[mode], data, unit)
#        mode = 0

@gadgetoid @sandyjmacdonald