mendhak / waveshare-epaper-display

At-a-glance dashboard for Raspberry Pi with a Waveshare ePaper 7.5 Inch HAT. Date/Time, Weather, Alerts, Google/Outlook Calendar
https://code.mendhak.com/raspberrypi-epaper-dashboard/
452 stars 67 forks source link

Weather description #92

Closed Silvanfelix closed 1 hour ago

Silvanfelix commented 10 hours ago

How can I add another line for the description? I managed to get the language to german, but now the description is too long. I changed the max_lines=3 but it still only shoes two lines. Where do I need to change the code aswell?

ef format_weather_description(weather_description): if len(weather_description) < 20: return {1: weather_description, 2: '', 3: ''}

splits = textwrap.fill(weather_description, 20, break_long_words=False,
                       max_lines=3, placeholder='...').split('\n')
weather_dict = {1: splits[0]}
weather_dict[2] = splits[1] if len(splits) > 1 else ''
return weather_dict
mendhak commented 8 hours ago

Try this:

def format_weather_description(weather_description):
    if len(weather_description) < 20:
        return {1: weather_description, 2: '', 3: ''}

    splits = textwrap.fill(weather_description, 20, break_long_words=False,
                           max_lines=3, placeholder='...').split('\n')
    weather_dict = {1: splits[0]}
    weather_dict[2] = splits[1] if len(splits) > 1 else ''
    weather_dict[3] = splits[2] if len(splits) > 2 else ''
    return weather_dict

You'll need to add the third line here: https://github.com/mendhak/waveshare-epaper-display/blob/ab8a65751deac617fbfb4f2bc41996e46b2838b5/screen-weather-get.py#L172

And also in the SVG layout file.

Silvanfelix commented 5 hours ago

image

Is it the screen-output-weather.svg file or which file do you mean, to edit the layout?

mendhak commented 5 hours ago

By default it should be screen-template.1.svg but if you picked any other LAYOUT variable from here, then the corresponding number. eg if you did SCREEN_LAYOUT=2, then edit screen-template.2.svg.

Silvanfelix commented 1 hour ago

It worked perfect thanks a lot

mendhak commented 1 hour ago

Very good!