Hello,
I am facing bug (probably), when fonts are displayed not so bright on my ESPhome e-paper displays.
In same time, how you can see, horizontal line is displayed correctly in full black color.
The only difference is that line is made with for it.line()
, and icons and text is displayed with it.print()
Since I am making this line 4px high by drawing 4 lines i tried:
- Put 4
it.print()
on top of each other - Setting
COLOR_ON
forit.printf()
function
But nothing helps. What can cause such problem?
Thank you in advance for any help.
If anyone is interested, here is full code. I am going in the future write post about some solutions I used in here
esphome:
name: display_eink
platform: ESP32
board: esp32dev
on_boot:
priority: 600
then:
- deep_sleep.prevent: deep_sleep_1
wifi:
ssid: "-"
password: "-"
fast_connect: true
# Enable fallback hotspot (captive portal) in case wifi connection fails
# ap:
# ssid: "Display Eink Fallback Hotspot"
# password: "-"
captive_portal:
# mqtt:
# broker: 192.168.0.195
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "-"
ota:
password: "-"
#web_server:
# port: 80
deep_sleep:
run_duration: 5min
sleep_duration: 10min
id: deep_sleep_1
time:
- platform: homeassistant
id: homeassistant_time
binary_sensor:
- platform: homeassistant
name: "Sleep Enabled"
id: sleep_enabled
entity_id: input_boolean.e_paper_display_sleep_enable
internal: true
on_state:
then:
- component.update: main_display
- if:
condition:
binary_sensor.is_on: sleep_enabled
then:
- component.update: main_display
- deep_sleep.enter: deep_sleep_1
text_sensor:
- platform: homeassistant
name: "weather_home_hourly"
id: weather_home_hourly
entity_id: weather.gismeteo
internal: true
- platform: homeassistant
name: "eink_weather_day1_icon"
id: eink_weather_day1_icon
entity_id: sensor.eink_weather_day1_icon
internal: true
- platform: homeassistant
name: "eink_weather_day2_icon"
id: eink_weather_day2_icon
entity_id: sensor.eink_weather_day2_icon
internal: true
- platform: homeassistant
name: "eink_weather_day3_icon"
id: eink_weather_day3_icon
entity_id: sensor.eink_weather_day3_icon
internal: true
sensor:
- platform: adc
pin: 34
attenuation: 11db
name: "Battery"
id: battery
update_interval: 15s
internal: false
- platform: homeassistant
name: "Outside Temperature"
id: outside_temperature
entity_id: sensor.outside_sensor_temperature
internal: true
icon: "mdi:weather-sunny"
- platform: homeassistant
name: "Living Room Temperature"
id: living_room_temperature
entity_id: sensor.living_room_temperature
internal: true
- platform: homeassistant
name: "Living Room Humidity"
id: living_room_humidity
entity_id: sensor.living_room_humidity
internal: true
- platform: homeassistant
name: "Kitchen Temperature"
id: kitchen_temperature
entity_id: sensor.kitchen_temperature
internal: true
- platform: homeassistant
name: "Kitchen Humidity"
id: kitchen_humidity
entity_id: sensor.kitchen_humidity
internal: true
- platform: homeassistant
name: "Bedroom Temperature"
id: bedroom_temperature
entity_id: sensor.bedroom_temperature
internal: true
- platform: homeassistant
name: "Bedroom Humidity"
id: bedroom_humidity
entity_id: sensor.bedroom_humidity
internal: true
- platform: homeassistant
name: "Bathroom Temperature"
id: bathroom_temperature
entity_id: sensor.bathroom_temperature_2
internal: true
- platform: homeassistant
name: "Bathroom Humidity"
id: bathroom__humidity
entity_id: sensor.bathroom_humidity
internal: true
- platform: homeassistant
name: "eink_weather_day1_temp_max"
id: eink_weather_day1_temp_max
entity_id: sensor.eink_weather_day1_temp_max
internal: true
- platform: homeassistant
name: "eink_weather_day1_temp_min"
id: eink_weather_day1_temp_min
entity_id: sensor.eink_weather_day1_temp_min
internal: true
- platform: homeassistant
name: "eink_weather_day2_temp_max"
id: eink_weather_day2_temp_max
entity_id: sensor.eink_weather_day2_temp_max
internal: true
- platform: homeassistant
name: "eink_weather_day2_temp_min"
id: eink_weather_day2_temp_min
entity_id: sensor.eink_weather_day2_temp_min
internal: true
- platform: homeassistant
name: "eink_weather_day3_temp_max"
id: eink_weather_day3_temp_max
entity_id: sensor.eink_weather_day3_temp_max
internal: true
- platform: homeassistant
name: "eink_weather_day3_temp_min"
id: eink_weather_day3_temp_min
entity_id: sensor.eink_weather_day3_temp_min
internal: true
- platform: homeassistant
name: "Ping Pong"
id: ping_pong
entity_id: input_text.ping
internal: true
on_value:
then:
- component.update: main_display
- if:
condition:
binary_sensor.is_on: sleep_enabled
then:
- deep_sleep.enter: deep_sleep_1
# text_sensor:
# - platform: homeassistant
# name: "Ping Pong"
# id: ping_pong
# entity_id: input_text.ping
# internal: true
font:
- file: "OpenSans-SemiBold.ttf"
id: main_font
size: 35
- file: "OpenSans-SemiBold.ttf"
id: outside_font
size: 100
- file: "OpenSans-SemiBold.ttf"
id: humidity_font
size: 50
- file: "OpenSans-SemiBold.ttf"
id: big_font
size: 70
- file: "OpenSans-SemiBold.ttf"
id: text_font
size: 40
- file: "OpenSans-SemiBold.ttf"
id: date_font
size: 30
- file: "OpenSans-SemiBold.ttf"
id: weather_font_minmax
size: 40
glyphs: "-°0123456789/"
- file: 'materialdesignicons-webfont.ttf'
id: icon_font_weather_big
size: 100
glyphs:
- "\U000F0590" # weather-cloudy
- "\U000F0F2F" # weather-cloudy-alert
- "\U000F0E6E" # weather-cloudy-arrow-right
- "\U000F0591" # weather-fog
- "\U000F0592" # weather-hail
- "\U000F0F30" # weather-hazy
- "\U000F0898" # weather-hurricane
- "\U000F0593" # weather-lightning
- "\U000F067E" # weather-lightning-rainy
- "\U000F0594" # weather-night
- "\U000F0F31" # weather-night-partly-cloudy
- "\U000F0595" # weather-partly-cloudy
- "\U000F0F32" # weather-partly-lightning
- "\U000F0F33" # weather-partly-rainy
- "\U000F0F34" # weather-partly-snowy
- "\U000F0F35" # weather-partly-snowy-rainy
- "\U000F0596" # weather-pouring
- "\U000F0597" # weather-rainy
- "\U000F0598" # weather-snowy
- "\U000F0F36" # weather-snowy-heavy
- "\U000F067F" # weather-snowy-rainy
- "\U000F0599" # weather-sunny
- "\U000F0F37" # weather-sunny-alert
- "\U000F14E4" # weather-sunny-off
- "\U000F059A" # weather-sunset
- "\U000F059B" # weather-sunset-down
- "\U000F059C" # weather-sunset-up
- "\U000F0F38" # weather-tornado
- "\U000F059D" # weather-windy
- "\U000F059E" # weather-windy-variant
- file: 'materialdesignicons-webfont.ttf'
id: icon_font_weather_middle
size: 100
glyphs:
- "\U000F0590" # weather-cloudy
- "\U000F0F2F" # weather-cloudy-alert
- "\U000F0E6E" # weather-cloudy-arrow-right
- "\U000F0591" # weather-fog
- "\U000F0592" # weather-hail
- "\U000F0F30" # weather-hazy
- "\U000F0898" # weather-hurricane
- "\U000F0593" # weather-lightning
- "\U000F067E" # weather-lightning-rainy
- "\U000F0594" # weather-night
- "\U000F0F31" # weather-night-partly-cloudy
- "\U000F0595" # weather-partly-cloudy
- "\U000F0F32" # weather-partly-lightning
- "\U000F0F33" # weather-partly-rainy
- "\U000F0F34" # weather-partly-snowy
- "\U000F0F35" # weather-partly-snowy-rainy
- "\U000F0596" # weather-pouring
- "\U000F0597" # weather-rainy
- "\U000F0598" # weather-snowy
- "\U000F0F36" # weather-snowy-heavy
- "\U000F067F" # weather-snowy-rainy
- "\U000F0599" # weather-sunny
- "\U000F0F37" # weather-sunny-alert
- "\U000F14E4" # weather-sunny-off
- "\U000F059A" # weather-sunset
- "\U000F059B" # weather-sunset-down
- "\U000F059C" # weather-sunset-up
- "\U000F0F38" # weather-tornado
- "\U000F059D" # weather-windy
- "\U000F059E" # weather-windy-variant
- file: 'materialdesignicons-webfont.ttf'
id: little_icon_font
size: 40
glyphs:
- "\U000F04B3" # mdi-sleep-off
- "\U000F0E0A" # mdi-water-outline
- "\U000F058C" # mdi-water
- file: 'materialdesignicons-webfont.ttf'
id: icon_font_main
size: 70
glyphs:
- "\U000F0766" # mdi-circle-outline
- "\U000F0A9E" #
- "\U000F0A9F" #
- "\U000F0AA0" #
- "\U000F0AA1" #
- "\U000F0AA2" #
- "\U000F0AA3" #
- "\U000F0AA4" #
- "\U000F0AA5" # mdi-circle-slice-8
- "\U000F04B9" # mdi-sofa
- "\U000F1319" # mdi-kettle-steam
- "\U000F02E3" # mdi-bed
- "\U000F09A0" # mdi-shower
spi:
clk_pin: 13
mosi_pin: 14
display:
- platform: waveshare_epaper
id: main_display
cs_pin: 15
busy_pin: 25
reset_pin: 26
dc_pin: 27
#model: 4.20in
model: 7.50inV2
#update_interval: 10min
#update_interval: 7s
update_interval: never
rotation: 270°
lambda: |-
int pointer = 0;
int sectionHeight = 100;
int afterLineHeight = 0;
int bigFontHeight = 70;
int humidityFontHeight = 50;
//range make_range(int lower, int upper) {
// if(upper < lower) {
// return std::make_pair(upper,lower);
// }
// return std::make_pair(lower,upper);
//}
std::map<int, std::string> humidity_icons_map {
{ 0, "\U000F0766" },
{ 1, "\U000F0766" },
{ 2, "\U000F0766" },
{ 3, "\U000F0766" },
{ 4, "\U000F0766" },
{ 5, "\U000F0766" },
{ 6, "\U000F0766" },
{ 7, "\U000F0766" },
{ 8, "\U000F0766" },
{ 9, "\U000F0766" },
{ 10, "\U000F0A9E" },
{ 11, "\U000F0A9E" },
{ 12, "\U000F0A9E" },
{ 13, "\U000F0A9E" },
{ 14, "\U000F0A9E" },
{ 15, "\U000F0A9E" },
{ 16, "\U000F0A9E" },
{ 17, "\U000F0A9E" },
{ 18, "\U000F0A9E" },
{ 19, "\U000F0A9E" },
{ 20, "\U000F0A9F" },
{ 21, "\U000F0A9F" },
{ 22, "\U000F0A9F" },
{ 23, "\U000F0A9F" },
{ 24, "\U000F0A9F" },
{ 25, "\U000F0A9F" },
{ 26, "\U000F0A9F" },
{ 27, "\U000F0A9F" },
{ 28, "\U000F0A9F" },
{ 29, "\U000F0A9F" },
{ 30, "\U000F0A9F" },
{ 31, "\U000F0AA0" },
{ 32, "\U000F0AA0" },
{ 33, "\U000F0AA0" },
{ 34, "\U000F0AA0" },
{ 35, "\U000F0AA0" },
{ 36, "\U000F0AA0" },
{ 37, "\U000F0AA0" },
{ 38, "\U000F0AA0" },
{ 39, "\U000F0AA0" },
{ 40, "\U000F0AA0" },
{ 41, "\U000F0AA0" },
{ 42, "\U000F0AA0" },
{ 43, "\U000F0AA0" },
{ 44, "\U000F0AA1" },
{ 45, "\U000F0AA1" },
{ 46, "\U000F0AA1" },
{ 47, "\U000F0AA1" },
{ 48, "\U000F0AA1" },
{ 49, "\U000F0AA1" },
{ 50, "\U000F0AA1" },
{ 51, "\U000F0AA1" },
{ 52, "\U000F0AA1" },
{ 53, "\U000F0AA1" },
{ 54, "\U000F0AA1" },
{ 55, "\U000F0AA1" },
{ 56, "\U000F0AA1" },
{ 57, "\U000F0AA2" },
{ 58, "\U000F0AA2" },
{ 59, "\U000F0AA2" },
{ 60, "\U000F0AA2" },
{ 61, "\U000F0AA2" },
{ 62, "\U000F0AA2" },
{ 63, "\U000F0AA2" },
{ 64, "\U000F0AA2" },
{ 65, "\U000F0AA2" },
{ 66, "\U000F0AA2" },
{ 67, "\U000F0AA2" },
{ 68, "\U000F0AA2" },
{ 69, "\U000F0AA2" },
{ 70, "\U000F0AA3" },
{ 71, "\U000F0AA3" },
{ 72, "\U000F0AA3" },
{ 73, "\U000F0AA3" },
{ 74, "\U000F0AA3" },
{ 75, "\U000F0AA3" },
{ 76, "\U000F0AA3" },
{ 77, "\U000F0AA3" },
{ 78, "\U000F0AA3" },
{ 79, "\U000F0AA3" },
{ 80, "\U000F0AA3" },
{ 81, "\U000F0AA4" },
{ 82, "\U000F0AA4" },
{ 83, "\U000F0AA4" },
{ 84, "\U000F0AA4" },
{ 85, "\U000F0AA4" },
{ 86, "\U000F0AA4" },
{ 87, "\U000F0AA4" },
{ 88, "\U000F0AA4" },
{ 89, "\U000F0AA4" },
{ 90, "\U000F0AA4" },
{ 91, "\U000F0AA4" },
{ 92, "\U000F0AA4" },
{ 93, "\U000F0AA4" },
{ 94, "\U000F0AA4" },
{ 95, "\U000F0AA4" },
{ 96, "\U000F0AA5" },
{ 97, "\U000F0AA5" },
{ 98, "\U000F0AA5" },
{ 99, "\U000F0AA5" },
{ 100, "\U000F0AA5" },
};
std::map<std::string, std::string> weather_icon_map
{
{"cloudy", "\U000F0590"},
{"cloudy-alert", "\U000F0F2F"},
{"cloudy-arrow-right", "\U000F0E6E"},
{"fog", "\U000F0591"},
{"hail", "\U000F0592"},
{"hazy", "\U000F0F30"},
{"hurricane", "\U000F0898"},
{"lightning", "\U000F0593"},
{"lightning-rainy", "\U000F067E"},
{"night", "\U000F0594"},
{"clear-night", "\U000F0594"},
{"night-partly-cloudy", "\U000F0F31"},
{"partly-cloudy", "\U000F0595"},
{"partlycloudy", "\U000F0595"},
{"partly-lightning", "\U000F0F32"},
{"partly-rainy", "\U000F0F33"},
{"partly-snowy", "\U000F0F34"},
{"partly-snowy-rainy", "\U000F0F35"},
{"pouring", "\U000F0596"},
{"rainy", "\U000F0597"},
{"snowy", "\U000F0598"},
{"snowy-heavy", "\U000F0F36"},
{"snowy-rainy", "\U000F067F"},
{"sunny", "\U000F0599"},
{"sunny-alert", "\U000F0F37"},
{"sunny-off", "\U000F14E4"},
{"sunset", "\U000F059A"},
{"sunset-down", "\U000F059B"},
{"sunset-up", "\U000F059C"},
{"tornado", "\U000F0F38"},
{"windy", "\U000F059D"},
{"windy-variant", "\U000F059E"},
};
// EXAMPLE_FROM_PHOTO_STARTS
it.print(0, 0, id(icon_font_weather_middle), TextAlign::TOP_LEFT, weather_icon_map[id(weather_home_hourly).state].c_str());
it.printf(it.get_width(), -30, id(outside_font), TextAlign::TOP_RIGHT, "%.1f°C", id(outside_temperature).state);
pointer += 100;
it.line(0, pointer + 4, it.get_width(), pointer + 4);
it.line(0, pointer + 5, it.get_width(), pointer + 5);
it.line(0, pointer + 6, it.get_width(), pointer + 6);
it.line(0, pointer + 7, it.get_width(), pointer + 7);
it.print(it.get_width()/6, pointer, id(icon_font_weather_big), TextAlign::TOP_CENTER, weather_icon_map[id(eink_weather_day1_icon).state].c_str());
it.print(it.get_width()/6 * 3, pointer, id(icon_font_weather_big), COLOR_ON, TextAlign::TOP_CENTER, weather_icon_map[id(eink_weather_day2_icon).state].c_str());
it.print(it.get_width()/6 * 5, pointer, id(icon_font_weather_big), TextAlign::TOP_CENTER, weather_icon_map[id(eink_weather_day3_icon).state].c_str());
it.print(it.get_width()/6 * 5, pointer, id(icon_font_weather_big), TextAlign::TOP_CENTER, weather_icon_map[id(eink_weather_day3_icon).state].c_str());
it.print(it.get_width()/6 * 5, pointer, id(icon_font_weather_big), TextAlign::TOP_CENTER, weather_icon_map[id(eink_weather_day3_icon).state].c_str());
it.print(it.get_width()/6 * 5, pointer, id(icon_font_weather_big), TextAlign::TOP_CENTER, weather_icon_map[id(eink_weather_day3_icon).state].c_str());
it.print(it.get_width()/6 * 5, pointer, id(icon_font_weather_big), TextAlign::TOP_CENTER, weather_icon_map[id(eink_weather_day3_icon).state].c_str());
pointer += 140;
it.printf(it.get_width()/6, pointer, id(weather_font_minmax), TextAlign::BOTTOM_CENTER, "%.0f°/%.0f°", id(eink_weather_day1_temp_min).state, id(eink_weather_day1_temp_max).state);
it.printf(it.get_width()/6 * 3, pointer, id(weather_font_minmax), COLOR_ON, TextAlign::BOTTOM_CENTER, "%.0f°/%.0f°", id(eink_weather_day2_temp_min).state, id(eink_weather_day2_temp_max).state);
it.printf(it.get_width()/6 * 5, pointer, id(weather_font_minmax), TextAlign::BOTTOM_CENTER, "%.0f°/%.0f°", id(eink_weather_day3_temp_min).state, id(eink_weather_day3_temp_max).state);
it.printf(it.get_width()/6 * 5, pointer, id(weather_font_minmax), TextAlign::BOTTOM_CENTER, "%.0f°/%.0f°", id(eink_weather_day3_temp_min).state, id(eink_weather_day3_temp_max).state);
it.printf(it.get_width()/6 * 5, pointer, id(weather_font_minmax), TextAlign::BOTTOM_CENTER, "%.0f°/%.0f°", id(eink_weather_day3_temp_min).state, id(eink_weather_day3_temp_max).state);
it.printf(it.get_width()/6 * 5, pointer, id(weather_font_minmax), TextAlign::BOTTOM_CENTER, "%.0f°/%.0f°", id(eink_weather_day3_temp_min).state, id(eink_weather_day3_temp_max).state);
it.printf(it.get_width()/6 * 5, pointer, id(weather_font_minmax), TextAlign::BOTTOM_CENTER, "%.0f°/%.0f°", id(eink_weather_day3_temp_min).state, id(eink_weather_day3_temp_max).state);
//it.line(0, pointer + 4, it.get_width(), pointer + 4);
//it.line(0, pointer + 5, it.get_width(), pointer + 5);
//it.line(0, pointer + 6, it.get_width(), pointer + 6);
it.line(0, pointer + 7, it.get_width(), pointer + 7);
// EXAMPLE_FROM_PHOTO_ENDS
// LOGO
it.print(0, pointer + sectionHeight/2, id(icon_font_main), TextAlign::CENTER_LEFT, "\U000F04B9");
// HUMIDITY
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(icon_font_main), TextAlign::CENTER, humidity_icons_map[id(living_room_humidity).state].c_str());
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(little_icon_font), COLOR_OFF, TextAlign::CENTER, "\U000F058C");
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(little_icon_font), TextAlign::CENTER, "\U000F0E0A");
// TEMPERATURE
it.printf(it.get_width(), pointer, id(big_font), TextAlign::TOP_RIGHT, "%.1f°C", id(living_room_temperature).state);
pointer += sectionHeight;
it.line(0, pointer, it.get_width(), pointer);
// LOGO
it.print(0, pointer + sectionHeight/2, id(icon_font_main), TextAlign::CENTER_LEFT, "\U000F1319");
// HUMIDITY
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(icon_font_main), TextAlign::CENTER, humidity_icons_map[id(kitchen_humidity).state].c_str());
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(little_icon_font), COLOR_OFF, TextAlign::CENTER, "\U000F058C");
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(little_icon_font), TextAlign::CENTER, "\U000F0E0A");
// TEMPERATURE
it.printf(it.get_width(), pointer, id(big_font), TextAlign::TOP_RIGHT, "%.1f°C", id(kitchen_temperature).state);
pointer += sectionHeight;
it.line(0, pointer, it.get_width(), pointer);
// LOGO
it.print(0, pointer + sectionHeight/2, id(icon_font_main), TextAlign::CENTER_LEFT, "\U000F02E3");
// HUMIDITY
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(icon_font_main), TextAlign::CENTER, humidity_icons_map[id(bedroom_humidity).state].c_str());
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(little_icon_font), COLOR_OFF, TextAlign::CENTER, "\U000F058C");
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(little_icon_font), TextAlign::CENTER, "\U000F0E0A");
// TEMPERATURE
it.printf(it.get_width(), pointer, id(big_font), TextAlign::TOP_RIGHT, "%.1f°C", id(bedroom_temperature).state);
pointer += sectionHeight;
it.line(0, pointer, it.get_width(), pointer);
// LOGO
it.print(0, pointer + sectionHeight/2, id(icon_font_main), TextAlign::CENTER_LEFT, "\U000F09A0");
// HUMIDITY
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(icon_font_main), TextAlign::CENTER, humidity_icons_map[id(bathroom__humidity).state].c_str());
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(little_icon_font), COLOR_OFF, TextAlign::CENTER, "\U000F058C");
it.print(it.get_width()/2 - 50, pointer + sectionHeight/2, id(little_icon_font), TextAlign::CENTER, "\U000F0E0A");
// TEMPERATURE
it.printf(it.get_width(), pointer, id(big_font), TextAlign::TOP_RIGHT, "%.1f°C", id(bathroom_temperature).state);
pointer += sectionHeight;
it.line(0, pointer, it.get_width(), pointer);
pointer += 30;
it.strftime(it.get_width()/2, pointer, id(date_font), TextAlign::TOP_CENTER, "%B %d", id(homeassistant_time).now());
it.strftime(it.get_width()/2, pointer + 45, id(date_font), TextAlign::TOP_CENTER, "%A", id(homeassistant_time).now());
it.strftime(it.get_width(), it.get_height(), id(date_font), TextAlign::BOTTOM_RIGHT, "%H:%M:%S", id(homeassistant_time).now());
if (!id(sleep_enabled).state) {
it.print(0, it.get_height(), id(little_icon_font), TextAlign::BOTTOM_LEFT, "\U000F04B3");
}
Edit: Added two extra comments in code: EXAMPLE_FROM_PHOTO_STARTS and EXAMPLE_FROM_PHOTO_ENDS if someone really want to look into code, they will help navigate to problem example part