Add Eva's temp to color functions
This commit is contained in:
		
							parent
							
								
									ce0eefd81a
								
							
						
					
					
						commit
						49a5240c52
					
				@ -114,6 +114,67 @@ layout_t create_layout()
 | 
				
			|||||||
	return layout;
 | 
						return layout;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint8_t interpolation(int32_t arg) {
 | 
				
			||||||
 | 
						int32_t i32_val = arg * 256 / 1000;
 | 
				
			||||||
 | 
						uint8_t u8_val = (uint8_t)i32_val;
 | 
				
			||||||
 | 
						return u8_val;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					color_t temp_color(int32_t temp_raw) {
 | 
				
			||||||
 | 
						color_t col = { 0 };
 | 
				
			||||||
 | 
						if (temp_raw >= 3500)
 | 
				
			||||||
 | 
							col.r = 255;
 | 
				
			||||||
 | 
						else if (temp_raw < 3500 && temp_raw > 2500) {
 | 
				
			||||||
 | 
							int32_t diff = 3500 - temp_raw;
 | 
				
			||||||
 | 
							col.r = 255;
 | 
				
			||||||
 | 
							col.g = interpolation(diff);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (temp_raw == 2500) {
 | 
				
			||||||
 | 
							col.r = 255;
 | 
				
			||||||
 | 
							col.g = 255;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (temp_raw < 2500 && temp_raw > 1500) {
 | 
				
			||||||
 | 
							int32_t diff = temp_raw - 1500;
 | 
				
			||||||
 | 
							col.r = interpolation(diff);
 | 
				
			||||||
 | 
							col.g = 255;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (temp_raw == 1500)
 | 
				
			||||||
 | 
							col.g = 255;
 | 
				
			||||||
 | 
						else if (temp_raw < 1500 && temp_raw > 500) {
 | 
				
			||||||
 | 
							int32_t diff = 1500 - temp_raw;
 | 
				
			||||||
 | 
							col.g = 255;
 | 
				
			||||||
 | 
							col.b = interpolation(diff);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (temp_raw == 500) {
 | 
				
			||||||
 | 
							col.g = 255;
 | 
				
			||||||
 | 
							col.b = 255;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (temp_raw < 500 && temp_raw > -500) {
 | 
				
			||||||
 | 
							int32_t diff = temp_raw + 500;
 | 
				
			||||||
 | 
							col.g = interpolation(diff);
 | 
				
			||||||
 | 
							col.b = 255;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (temp_raw == -500)
 | 
				
			||||||
 | 
							col.b = 255;
 | 
				
			||||||
 | 
						else if (temp_raw < -500 && temp_raw > -1500) {
 | 
				
			||||||
 | 
							int32_t diff = -500 - temp_raw;
 | 
				
			||||||
 | 
							col.r = interpolation(diff);
 | 
				
			||||||
 | 
							col.b = 255;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (temp_raw <= -1500) {
 | 
				
			||||||
 | 
							col.r = 255;
 | 
				
			||||||
 | 
							col.b = 255;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return col;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int32_t last_temp_raw = 0;
 | 
				
			||||||
 | 
					uint32_t last_pressure_raw = 0;
 | 
				
			||||||
 | 
					uint32_t last_humidity_raw = 0;
 | 
				
			||||||
 | 
					int32_t last_temp2_raw = 0;
 | 
				
			||||||
 | 
					uint32_t last_pressure2_raw = 0;
 | 
				
			||||||
 | 
					uint32_t last_humidity2_raw = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void display_data(int32_t temp_raw, uint32_t pressure_raw, uint32_t humidity_raw,
 | 
					void display_data(int32_t temp_raw, uint32_t pressure_raw, uint32_t humidity_raw,
 | 
				
			||||||
		int32_t temp2_raw, uint32_t pressure2_raw, uint32_t humidity2_raw)
 | 
							int32_t temp2_raw, uint32_t pressure2_raw, uint32_t humidity2_raw)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -156,9 +217,9 @@ void display_data(int32_t temp_raw, uint32_t pressure_raw, uint32_t humidity_raw
 | 
				
			|||||||
	TFT_print("Aussen", layout.aussenLeft, layout.aussenBaseline);
 | 
						TFT_print("Aussen", layout.aussenLeft, layout.aussenBaseline);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	TFT_setFont(DEJAVU18_FONT, NULL);
 | 
						TFT_setFont(DEJAVU18_FONT, NULL);
 | 
				
			||||||
	tft_fg = TFT_RED;
 | 
						tft_fg = temp_color(temp_raw);
 | 
				
			||||||
	TFT_print(temp_str, layout.innenLeft, layout.tempBaseline);
 | 
						TFT_print(temp_str, layout.innenLeft, layout.tempBaseline);
 | 
				
			||||||
	tft_fg = TFT_YELLOW;
 | 
						tft_fg = temp_color(temp2_raw);
 | 
				
			||||||
	TFT_print(temp2_str, layout.aussenLeft, layout.tempBaseline);
 | 
						TFT_print(temp2_str, layout.aussenLeft, layout.tempBaseline);
 | 
				
			||||||
	tft_fg = TFT_WHITE;
 | 
						tft_fg = TFT_WHITE;
 | 
				
			||||||
	TFT_print(" C", layout.unitLeft, layout.tempBaseline);
 | 
						TFT_print(" C", layout.unitLeft, layout.tempBaseline);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user