Skip to content

Commit

Permalink
update to bootworm
Browse files Browse the repository at this point in the history
Signed-off-by: yoyojacky <[email protected]>
  • Loading branch information
yoyojacky committed May 8, 2024
1 parent 63e2323 commit b03f413
Show file tree
Hide file tree
Showing 10 changed files with 498 additions and 166 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
# absminitowerkit
ABS mini tower kit 's driver and installation script.
## How to use it?##
* Download the repository to your Raspberry Pi (Current version 2024-3-15 bookworm 64bit)
### Install the driver ###
* Open a terminal and make sure your Raspberry Pi can access internet and Github site.
```bash
cd ~
git clone https://github.com/geeekpi/absminitowerkit.git
cd absminitowerkit/
./install_bookworm.sh
```
* It will `Reboot` Raspberry Pi `automatically`.
* Have fun!

### Uninstall the driver ###
* Open a terminal and execute the `uninstall.sh` script.
```bash
cd ~
cd absminitowerkit/
./uninstall.sh
```
##End##
If you want to create your own script, please check following location:
* 1. /etc/systemd/system/minitower_moodlight.service --- moodlight service file
* 2. /etc/systemd/system/minitower_oled.service --- OLED service file
* 3. /usr/local/minitower/demo_opts.py --- OLED display script's dependency file
* 4. /usr/local/minitower/sysinfo.py --- OLED display script
* 5. /usr/bin/moodlight --- /tmp/rpi_ws281x/build/test binary file
* 6. /boot/firmware/config.txt --- configuration of I2C: `dtparam=i2c_arm=on`
* 7. /home/$USER/Downloads/examples ---Demo codes from luma.examples

---
PS: please replace `$USER` to your own user name, we are using `pi` user by default. you can modify the `install_bookworm.sh` file in grant permission section.


If you want to install the driver manually, please check the `systemd_file` folder and `demo_code` folder.
Hope you like it and have a nice day!
##BYE##
66 changes: 66 additions & 0 deletions democ_code/demo_opts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2014-2022 Richard Hull and contributors
# See LICENSE.rst for details.

import sys
import logging

from luma.core import cmdline, error


# logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)-15s - %(message)s'
)
# ignore PIL debug messages
logging.getLogger('PIL').setLevel(logging.ERROR)


def display_settings(device, args):
"""
Display a short summary of the settings.
:rtype: str
"""
iface = ''
display_types = cmdline.get_display_types()
if args.display not in display_types['emulator']:
iface = f'Interface: {args.interface}\n'

lib_name = cmdline.get_library_for_display_type(args.display)
if lib_name is not None:
lib_version = cmdline.get_library_version(lib_name)
else:
lib_name = lib_version = 'unknown'

import luma.core
version = f'luma.{lib_name} {lib_version} (luma.core {luma.core.__version__})'

return f'Version: {version}\nDisplay: {args.display}\n{iface}Dimensions: {device.width} x {device.height}\n{"-" * 60}'


def get_device(actual_args=None):
"""
Create device from command-line arguments and return it.
"""
if actual_args is None:
actual_args = sys.argv[1:]
parser = cmdline.create_parser(description='luma.examples arguments')
args = parser.parse_args(actual_args)

if args.config:
# load config from file
config = cmdline.load_config(args.config)
args = parser.parse_args(config + actual_args)

# create device
try:
device = cmdline.create_device(args)
print(display_settings(device, args))
return device

except error.Error as e:
parser.error(e)
return None

Binary file added democ_code/moodlight
Binary file not shown.
29 changes: 7 additions & 22 deletions sysinfo.py → democ_code/sysinfo.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) 2014-2020 Richard Hull and contributors
# See LICENSE.rst for details.
# PYTHON_ARGCOMPLETE_OK


import os
import sys
Expand All @@ -18,12 +14,6 @@


def bytes2human(n):
"""
>>> bytes2human(10000)
'9K'
>>> bytes2human(100001221)
'95M'
"""
symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
prefix = {}
for i, s in enumerate(symbols):
Expand All @@ -38,35 +28,29 @@ def bytes2human(n):
def cpu_usage():
# load average
av1, av2, av3 = os.getloadavg()
return "Ld:%.1f %.1f %.1f " % (av1, av2, av3)
return "Ld:%.1f %.1f %.1f" % (av1, av2, av3)


def uptime_usage():
# uptime, Ip
uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time())
# uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time())
ip = sp.getoutput("hostname -I").split(' ')[0]
return "Up: %s,IP:%s" % (uptime, ip)
return "IP:%s" % (ip)





def mem_usage():
usage = psutil.virtual_memory()
return "Mem: %s %.0f%%" \
% (bytes2human(usage.used), 100 - usage.percent)
return "Mem:%s %.0f%%" % (bytes2human(usage.used), 100 - usage.percent)


def disk_usage(dir):
usage = psutil.disk_usage(dir)
return "SD: %s %.0f%%" \
% (bytes2human(usage.used), usage.percent)
return "SD:%s %.0f%%" % (bytes2human(usage.used), usage.percent)


def network(iface):
stat = psutil.net_io_counters(pernic=True)[iface]
return "%s: Tx%s, Rx%s" % \
(iface, bytes2human(stat.bytes_sent), bytes2human(stat.bytes_recv))
return "%s: Tx: %s,Rx: %s" % (iface, bytes2human(stat.bytes_sent), bytes2human(stat.bytes_recv))


def stats(device):
Expand Down Expand Up @@ -95,3 +79,4 @@ def stats(device):
while True:
stats(device)
time.sleep(5)

117 changes: 0 additions & 117 deletions install.sh

This file was deleted.

Loading

0 comments on commit b03f413

Please sign in to comment.