turing-smart-screen-python icon indicating copy to clipboard operation
turing-smart-screen-python copied to clipboard

Add date/time metrics

Open mathoudebine opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? If so, please describe the problem.
There is no entries in theme.yaml for date/time

Describe the feature / solution to your problem you'd like
Entries in theme.yaml to be able to display date and time on screen, with configurable format

Describe alternatives you've considered / and or tested
Using static_text entries but it is not updated at runtime

Environment:

  • Release 2.0.0-beta.1, feature/system-monitor branch
  • All OS with version [e.g. Windows 11, Ubuntu 22.04]
  • Python version > 3.7

mathoudebine avatar Aug 30 '22 20:08 mathoudebine

In addition to the date/time metrics, would love to see the Network In/Out if readily availalbe.

Why - this secondary monitor screen will be a nice addition to NAS system like Synology DS or other headless home theater PC(HTPC)

Currently using it on my Raspberry Pi 3B+ (running Retropie) however CPU temp is not supported

waynehuang85 avatar Sep 11 '22 01:09 waynehuang85

In addition to the date/time metrics, would love to see the Network In/Out if readily availalbe.

Why - this secondary monitor screen will be a nice addition to NAS system like Synology DS or other headless home theater PC(HTPC)

Currently using it on my Raspberry Pi 3B+ (running Retropie) however CPU temp is not supported

I love this idea, but it should probably be it's own feature request.

Nealtron avatar Sep 18 '22 13:09 Nealtron

@Nealtron and @waynehuang85 you can subscribe to this feature request for network metrics: https://github.com/mathoudebine/turing-smart-screen-python/issues/51

mathoudebine avatar Sep 19 '22 20:09 mathoudebine

Hi,

My purpose:

I used datetime.

In main.py, add:

scheduler.DateStats()

In scheduler.py, add:

@async_job("Date_Stats")
@schedule(timedelta(seconds=THEME_DATA['STATS']['DATE'].get("INTERVAL", None)).total_seconds())
def DateStats():
    # logger.debug("Refresh date stats")
    stats.Date.stats()

In stats.py, add:

class Date:
    @staticmethod
    def stats():
        date_now = datetime.datetime.now()

        if THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("SHOW", False):
            display.lcd.DisplayText(
                text=f"{date_now.day}-{date_now.month}-{date_now.year}",
                x=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("X", 0),
                y=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("Y", 0),
                font=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("FONT", "roboto-mono/RobotoMono-Regular.ttf"),
                font_size=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("FONT_SIZE", 10),
                font_color=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("FONT_COLOR", (0, 0, 0)),
                background_color=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("BACKGROUND_COLOR", (255, 255, 255)),
                background_image=get_full_path(THEME_DATA['PATH'],
                                               THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("BACKGROUND_IMAGE",
                                                                                               None))
            )

        if THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("SHOW", False):
            display.lcd.DisplayText(
                text=f"{date_now.strftime('%H:%M:%S')}",
                x=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("X", 0),
                y=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("Y", 0),
                font=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("FONT", "roboto-mono/RobotoMono-Regular.ttf"),
                font_size=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("FONT_SIZE", 10),
                font_color=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("FONT_COLOR", (0, 0, 0)),
                background_color=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("BACKGROUND_COLOR", (255, 255, 255)),
                background_image=get_full_path(THEME_DATA['PATH'],
                                               THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("BACKGROUND_IMAGE",
                                                                                                None))
            )

In your theme.yaml:

  DATE:
    # In seconds. Longer intervals cause this to refresh more slowly.
    # Setting to lower values will display near real time data,
    # but may cause significant CPU usage or the display not to update properly
    INTERVAL: 1
    DAY:
      TEXT:
        SHOW: True
        X: 4
        Y: 4
        FONT: roboto-mono/RobotoMono-Regular.ttf
        FONT_SIZE: 16
        FONT_COLOR: 53, 191, 92
        # BACKGROUND_COLOR: 0, 0, 0
        BACKGROUND_IMAGE: background.png
    HOUR:
      TEXT:
        SHOW: True
        X: 160
        Y: 4
        FONT: roboto-mono/RobotoMono-Regular.ttf
        FONT_SIZE: 16
        FONT_COLOR: 53, 191, 92
        # BACKGROUND_COLOR: 0, 0, 0
        BACKGROUND_IMAGE: background.png

Rollbacke avatar Oct 20 '22 09:10 Rollbacke

I created a pull request for it.

RussNelson avatar Oct 26 '22 18:10 RussNelson

Thanks @RussNelson ;)

Rollbacke avatar Oct 30 '22 08:10 Rollbacke

Implemented in #72

mathoudebine avatar Nov 06 '22 18:11 mathoudebine