Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Use Terminus TTF font by default #8

Open
boltronics opened this issue Nov 13, 2024 · 1 comment
Open

Suggestion: Use Terminus TTF font by default #8

boltronics opened this issue Nov 13, 2024 · 1 comment

Comments

@boltronics
Copy link

Terminus TTF can easily be dropped into the project. It is very clean at size 12, and can be fetched here. It looks much nicer to my eyes over the ones that are included.

20241114_013524-cropped

@boltronics
Copy link
Author

The above was done by editing oled.py as follows:

# ...

font = {
    # ...
    '12': ImageFont.truetype('fonts/TerminusMono-Bold.ttf', 12),
    # ...
}

# ...

def gen_pages(pages):
    if pages == None:
        pages = [0, 1, 2]
    result = {}
    if 0 in pages:
        result[0] = [
            {'xy': (0, -2), 'text': misc.get_info('cpu'), 'fill': 255, 'font': font['12']},
            {'xy': (0, 10), 'text': misc.get_info('men'), 'fill': 255, 'font': font['12']},
            {'xy': (0, 21), 'text': misc.get_info('ip'), 'fill': 255, 'font': font['12']},
        ]
    # ...

# ...

using my branch from here.

I also made minor adjustments to the commands in misc.py to get the text nicely aligned and consistent:

# ...

cmds = {
    'blk': "lsblk | awk '{print $1}'",
    'up': "echo Uptime: `uptime | sed 's/.*up \\([^,]*\\), .*/\\1/'`",
    'temp': "cat /sys/class/thermal/thermal_zone0/temp",
    'ip': "hostname -I | awk '{printf \"IP:  %s\", $1}'",
    'cpu': "uptime | awk '{printf \"CPU: %.2f\", $(NF-2)}'",
    'men': "free -m | awk 'NR==2{printf \"RAM: %s/%sMB\", $3,$2}'",
    'disk': "df -h | awk '$NF==\"/\"{printf \"Disk: %d/%dGB %s\", $3,$2,$5}'"
}

# ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant