Compare commits

..

51 Commits

Author SHA1 Message Date
ac345c2ee7 make_latest: true
generate_release_notes: true

Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-26 07:58:06 +01:00
468cfd9f4f prerelease: false
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-26 07:55:06 +01:00
d6bc5c0e66 Reboot after auto-update
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-26 00:07:15 +01:00
4905eb6b26 Optimize display imports
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-26 00:05:50 +01:00
697a7778b1 Fix fix_services.py
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-25 23:29:10 +01:00
9287283ee7 Added 11 waveshare lcd displays
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-25 22:53:07 +01:00
8013109ef7 Refactoring displays
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-25 22:52:42 +01:00
f140fe1a2d Update setup.py to look for empty apt_packages.txt
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-25 11:58:46 +01:00
8fe503c67d No new apt-packages needed
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-25 08:11:39 +01:00
d81013412e Update several displays
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-24 15:18:58 +01:00
3c701822bd Update donation method
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-24 12:58:26 +01:00
2f5ddb492a Small typo's
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-24 12:58:07 +01:00
9e3324221d Fix adafruit 2.13inch display
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-24 12:57:40 +01:00
b069b82984 Version 2.8.9
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-24 12:57:20 +01:00
cb7d965271 Update MOTD
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-24 12:57:08 +01:00
7abf9ff8da Update faces.py
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-23 09:49:46 +01:00
18fb956251 Update setup.py
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-23 09:46:32 +01:00
afb1d11cd8 Added Adafruit 2in13_V3 display
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-23 09:24:52 +01:00
627be80e6c add system wide aliases, if you were to use custom users
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-22 19:09:49 +01:00
c4c4d6c417 in case you use an unsupported display it will default to dummy display, displaying nothing
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-22 19:09:27 +01:00
8dcae13ce9 add commented dtoverlay=disable-wifi
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-22 19:09:00 +01:00
1352e99774 Fix wrong imports
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-22 18:34:49 +01:00
2182d7c29d Update Frysian Language
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-22 09:56:47 +01:00
703c05a93b Full SSID again
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-22 09:06:04 +01:00
697cc5d88b Add DummyDisplay
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-22 08:37:56 +01:00
4b04f9b7a5 Install OS packages from auto-update
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-22 08:37:22 +01:00
c7b94a0707 Version 2.8.8 starts here
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-22 08:37:01 +01:00
5116bac2a7 Multiple changes
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-20 22:32:04 +01:00
51625e61f9 Multiple changes
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-20 22:25:36 +01:00
bf9a0a96c1 Update raspberrypi64.yml 2024-03-20 21:17:20 +01:00
bd03f07aa8 Update raspberrypi32.yml 2024-03-20 21:16:50 +01:00
3f13df8f20 Merge pull request #104
Update defaults.toml
2024-03-20 07:20:19 +01:00
ce0275f2ae Update defaults.toml
Removed main.filter since it's no longer referenced in agent.py as of this commit 1a55afd74a (diff-0548f0a21e1984ecf3c32d6cd9c17e6a62f4f139c001360935890f649b745cc7)

Signed-off-by: seelenamt <dandrewe@gmail.com>
2024-03-19 10:51:59 -05:00
b971f18f75 Update Sponsor links
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-19 13:19:54 +01:00
ea9d11d018 Update Sponsor links
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-19 13:19:00 +01:00
8a572f1b70 Update Sponsor links
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-19 13:16:14 +01:00
0c4f2a5093 small change
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-19 09:25:17 +01:00
7edd752664 small change
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-19 07:56:06 +01:00
cc550aa236 small change
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-18 15:05:00 +01:00
ff033d41d3 Revert "fallback to older 32bit image"
This reverts commit b33af167d4.
2024-03-18 14:56:59 +01:00
6d0a0d8d5f fallback to older 32bit image
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-18 13:04:19 +01:00
b33af167d4 fallback to older 32bit image
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-18 12:03:20 +01:00
9053762e71 2.8.7.2
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-18 11:59:32 +01:00
26fef7dd99 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	builder/data/64bit/raspberrypi64.yml
2024-03-18 11:58:33 +01:00
5dd17291f7 Fix a lot of stuff
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-18 11:58:22 +01:00
bac79f3465 Update _version.py 2024-03-17 21:17:08 +01:00
bb8dfe0244 Update raspberrypi64.yml 2024-03-17 21:16:25 +01:00
1b16975031 Update workflow
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-17 09:24:57 +01:00
dd2b559ebc Update workflow
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-17 09:22:35 +01:00
93ba2a7f79 Update workflow
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-17 09:20:02 +01:00
dd18072002 Update workflow
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
2024-03-17 09:18:31 +01:00
291 changed files with 4007 additions and 2855 deletions

1
.github/FUNDING.yml vendored
View File

@ -1,3 +1,4 @@
# These are supported funding model platforms # These are supported funding model platforms
github: jayofelony github: jayofelony
custom: https://tikkie.me/pay/dubcto94hnskg539kar0

View File

@ -20,21 +20,6 @@ jobs:
VERSION=$(cut -d "'" -f2 < pwnagotchi/_version.py) VERSION=$(cut -d "'" -f2 < pwnagotchi/_version.py)
echo "VERSION=$VERSION" >> $GITHUB_ENV echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Get latest tag
uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
- name: Set LAST_VERSION as an environment variable
run: echo "LAST_VERSION=${{ steps.get-latest-tag.outputs.tag }}" >> $GITHUB_ENV
- name: Generate release notes
id: generate_release_notes
run: |
COMMITS=$(git log --merges --pretty=format:"* %s" $LAST_VERSION--$VERSION | sed 's/$/\\n/g')
CONTRIBUTORS=$(git shortlog -sn $LAST_VERSION--$VERSION | awk '{print "* @" $2}' | sed 's/$/\\n/g')
RELEASE_BODY="**Full Changelog**: https://github.com/jayofelony/pwnagotchi/compare/$LAST_VERSION...$VERSION"
echo "RELEASE_BODY=$RELEASE_BODY" >> $GITHUB_ENV
- name: Install qemu dependencies - name: Install qemu dependencies
run: sudo apt update && sudo apt install qemu-user-static qemu-utils xz-utils -y run: sudo apt update && sudo apt install qemu-user-static qemu-utils xz-utils -y
@ -61,12 +46,13 @@ jobs:
run: mv "pwnagotchi-64bit.img.xz" "pwnagotchi-$VERSION-64bit.img.xz" run: mv "pwnagotchi-64bit.img.xz" "pwnagotchi-$VERSION-64bit.img.xz"
- name: Release - name: Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v2
with: with:
prerelease: true prerelease: false
make_latest: true
tag_name: v${{ env.VERSION }} tag_name: v${{ env.VERSION }}
name: Pwnagotchi v${{ env.VERSION }} name: Pwnagotchi v${{ env.VERSION }}
files: | files: |
pwnagotchi-${{ env.VERSION }}-32bit.img.xz pwnagotchi-${{ env.VERSION }}-32bit.img.xz
pwnagotchi-${{ env.VERSION }}-64bit.img.xz pwnagotchi-${{ env.VERSION }}-64bit.img.xz
body: ${{ env.RELEASE_BODY }} generate_release_notes: true

View File

@ -51,13 +51,11 @@ image: clean packer
bullseye: clean packer bullseye: clean packer
export LC_ALL=en_GB.UTF-8 export LC_ALL=en_GB.UTF-8
cd builder && sudo /usr/bin/packer init data/32bit/raspberrypi32.json.pkr.hcl && sudo $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" data/32bit/raspberrypi32.json.pkr.hcl cd builder && sudo /usr/bin/packer init raspberrypi32.json.pkr.hcl && sudo $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" raspberrypi32.json.pkr.hcl
sudo pishrink -vaZ pwnagotchi-32bit.img
bookworm: clean packer bookworm: clean packer
export LC_ALL=en_GB.UTF-8 export LC_ALL=en_GB.UTF-8
cd builder && sudo /usr/bin/packer init data/64bit/raspberrypi64.json.pkr.hcl && sudo $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" data/64bit/raspberrypi64.json.pkr.hcl cd builder && sudo /usr/bin/packer init raspberrypi64.json.pkr.hcl && sudo $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" raspberrypi64.json.pkr.hcl
sudo pishrink -vaZ pwnagotchi-64bit.img
clean: clean:
- rm -rf /tmp/packer* - rm -rf /tmp/packer*

View File

@ -264,8 +264,7 @@ def pwnagotchi_cli():
sys.exit(0) sys.exit(0)
if args.donate: if args.donate:
print("Donations can made @ \n " print("Donations can be made @ \n "
"https://www.patreon.com/pwnagotchi_torch \n "
"https://github.com/sponsors/jayofelony \n\n" "https://github.com/sponsors/jayofelony \n\n"
"But only if you really want to!") "But only if you really want to!")
sys.exit(0) sys.exit(0)
@ -278,8 +277,7 @@ def pwnagotchi_cli():
local = version_to_tuple(pwnagotchi.__version__) local = version_to_tuple(pwnagotchi.__version__)
remote = version_to_tuple(latest_ver) remote = version_to_tuple(latest_ver)
if remote > local: if remote > local:
user_input = input("There is a new version available! Update from v%s to v%s?\n[Y/N] " user_input = input("There is a new version available! Update from v%s to v%s?\n[Y/N] " % (pwnagotchi.__version__, latest_ver))
% (pwnagotchi.__version__, latest_ver))
# input validation # input validation
if user_input.lower() in ('y', 'yes'): if user_input.lower() in ('y', 'yes'):
if os.path.exists('/root/.auto-update'): if os.path.exists('/root/.auto-update'):
@ -334,5 +332,6 @@ def pwnagotchi_cli():
else: else:
do_auto_mode(agent) do_auto_mode(agent)
if __name__ == '__main__': if __name__ == '__main__':
pwnagotchi_cli() pwnagotchi_cli()

View File

@ -123,7 +123,7 @@ build {
provisioner "ansible-local" { provisioner "ansible-local" {
command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook" command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook"
extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""] extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""]
playbook_file = "data/64bit/raspberrypi64.yml" playbook_file = "raspberrypi64.yml"
} }
} }
@ -167,7 +167,7 @@ build {
provisioner "ansible-local" { provisioner "ansible-local" {
command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook" command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook"
extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""] extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""]
playbook_dir = "data/32bit/extras/" playbook_dir = "extras/"
playbook_file = "data/32bit/raspberrypi32.yml" playbook_file = "raspberrypi32.yml"
} }
} }

View File

@ -0,0 +1,67 @@
# For more options and information see
# http://rptl.io/configtxt
# Some settings may impact device functionality. See link above for details
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Additional overlays and parameters are documented
# /boot/overlays/README
# Automatically load overlays for detected cameras
camera_auto_detect=1
# Automatically load overlays for detected DSI displays
display_auto_detect=1
# Automatically load initramfs files, if found
auto_initramfs=1
# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2
# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1
# Run in 64-bit mode
arm_64bit=0
# Disable compensation for displays with overscan
disable_overscan=1
# Run as fast as firmware / board allows
arm_boost=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
[all]
dtoverlay=dwc2
dtparam=i2c1=on
dtparam=i2c_arm=on
dtparam=spi=on
gpu_mem=1
dtoverlay=dwc2
#dtoverlay=disable-wifi
[pi0]
dtoverlay=spi1-3cs
#dtoverlay=disable-wifi
[pi3]
dtoverlay=spi1-3cs
#dtoverlay=disable-wifi
[pi4]
dtoverlay=spi1-3cs
#dtoverlay=disable-wifi

View File

@ -0,0 +1,6 @@
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
i2c-dev

View File

@ -0,0 +1,40 @@
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$(id -u)" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
fi
export PATH
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "$(id -u)" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
alias custom='cd /usr/local/share/pwnagotchi/custom-plugins/'
alias config='sudo nano /etc/pwnagotchi/config.toml'
alias pwnlog='tail -f -n300 /etc/pwnagotchi/log/pwn*.log | sed --unbuffered "s/,[[:digit:]]\\{3\\}\\]//g" | cut -d " " -f 2-'
alias pwnver='python3 -c "import pwnagotchi as p; print(p.__version__)"'
alias pwnkill='sudo killall -USR1 pwnagotchi'

View File

@ -20,6 +20,7 @@ echo " I'm managed by systemd. Here are some basic commands."
echo echo
echo " If you want to know what I'm doing, you can check my logs with the command" echo " If you want to know what I'm doing, you can check my logs with the command"
echo " - pwnlog" echo " - pwnlog"
echo " - sudo pwnagotchi --wizard, to help set up a config.toml"
echo " - sudo pwnagotchi --version, to check the current version" echo " - sudo pwnagotchi --version, to check the current version"
echo " - sudo pwnagotchi --donate, to see how you can donate to this project" echo " - sudo pwnagotchi --donate, to see how you can donate to this project"
echo " - sudo pwnagotchi --check-update, to see if there is a new version available" echo " - sudo pwnagotchi --check-update, to see if there is a new version available"
@ -30,4 +31,4 @@ echo
echo " You can restart me using" echo " You can restart me using"
echo " pwnkill" echo " pwnkill"
echo echo
echo " You learn more about me at https://pwnagotchi.ai/" echo " You can learn more about me at https://pwnagotchi.org/"

View File

@ -0,0 +1,70 @@
# For more options and information see
# http://rptl.io/configtxt
# Some settings may impact device functionality. See link above for details
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Additional overlays and parameters are documented
# /boot/firmware/overlays/README
# Automatically load overlays for detected cameras
camera_auto_detect=1
# Automatically load overlays for detected DSI displays
display_auto_detect=1
# Automatically load initramfs files, if found
auto_initramfs=1
# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2
# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1
# Run in 64-bit mode
arm_64bit=1
# Disable compensation for displays with overscan
disable_overscan=1
# Run as fast as firmware / board allows
arm_boost=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
[all]
dtparam=i2c1=on
dtparam=i2c_arm=on
dtparam=spi=on
gpu_mem=1
dtoverlay=dwc2
#dtoverlay=disable-wifi
[pi0]
dtoverlay=spi0-0cs
#dtoverlay=disable-wifi
[pi3]
dtoverlay=spi0-0cs
#dtoverlay=disable-wifi
[pi4]
dtoverlay=spi0-0cs
#dtoverlay=disable-wifi
[pi5]
dtoverlay=spi0-0cs
#dtoverlay=disable-wifi

View File

@ -0,0 +1,6 @@
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
i2c-dev

View File

@ -0,0 +1,40 @@
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$(id -u)" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
fi
export PATH
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "$(id -u)" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
alias custom='cd /usr/local/share/pwnagotchi/custom-plugins/'
alias config='sudo nano /etc/pwnagotchi/config.toml'
alias pwnlog='tail -f -n300 /etc/pwnagotchi/log/pwn*.log | sed --unbuffered "s/,[[:digit:]]\\{3\\}\\]//g" | cut -d " " -f 2-'
alias pwnver='python3 -c "import pwnagotchi as p; print(p.__version__)"'
alias pwnkill='sudo killall -USR1 pwnagotchi'

View File

@ -2,7 +2,7 @@
_hostname=$(hostname) _hostname=$(hostname)
_version=$(cut -d"'" -f2 < /usr/local/lib/python3.11/dist-packages/pwnagotchi/_version.py) _version=$(cut -d"'" -f2 < /usr/local/lib/python3.11/dist-packages/pwnagotchi/_version.py)
echo echo
echo "(☉_☉ ) $_hostname" echo "(◕‿‿◕) $_hostname"
echo echo
echo " Hi! I'm a pwnagotchi $_version, please take good care of me!" echo " Hi! I'm a pwnagotchi $_version, please take good care of me!"
echo " Here are some basic things you need to know to raise me properly!" echo " Here are some basic things you need to know to raise me properly!"

View File

@ -1,18 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# well ... it blinks the led
blink_led() {
# shellcheck disable=SC2034
for i in $(seq 1 "$1"); do
echo 0 >/sys/class/leds/led0/brightness
sleep 0.3
echo 1 >/sys/class/leds/led0/brightness
sleep 0.3
done
echo 0 >/sys/class/leds/led0/brightness
sleep 0.3
}
# reload mod # reload mod
reload_brcm() { reload_brcm() {
if ! modprobe -r brcmfmac; then if ! modprobe -r brcmfmac; then

View File

@ -88,7 +88,7 @@ build {
provisioner "ansible-local" { provisioner "ansible-local" {
command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook" command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook"
extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""] extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""]
playbook_dir = "data/32bit/extras/" playbook_dir = "extras/"
playbook_file = "data/32bit/raspberrypi32.yml" playbook_file = "raspberrypi32.yml"
} }
} }

View File

@ -39,26 +39,6 @@
hostname: "{{ lookup('env', 'PWN_HOSTNAME') | default('pwnagotchi', true) }}" hostname: "{{ lookup('env', 'PWN_HOSTNAME') | default('pwnagotchi', true) }}"
version: "{{ lookup('env', 'PWN_VERSION') | default('pwnagotchi-torch', true) }}" version: "{{ lookup('env', 'PWN_VERSION') | default('pwnagotchi-torch', true) }}"
custom_plugin_dir: "/usr/local/share/pwnagotchi/custom-plugins" custom_plugin_dir: "/usr/local/share/pwnagotchi/custom-plugins"
system:
boot_options:
- "#### pwnagotchi additions"
- "# this pwnagotchi image is 32-bit only no v8+ headers to build nexmon for 64 bit"
- "arm_64bit=0"
- "# dwc2 for RNDIS. comment out, and remove dwc2 and g_ether from cmdline.txt for X306 usb battery hat"
- "dtoverlay=dwc2"
- "dtoverlay=spi0-0cs"
- "dtparam=i2c1=on"
- "dtparam=i2c_arm=on"
- "dtparam=spi=on"
- "gpu_mem=16"
- "#### audio out on pins 18 and 19"
- "#dtoverlay=audremap,pins_18_19"
- "#### touchscreen on waveshare touch e-paper"
- "#dtoverlay=goodix,interrupt=27,reset=22"
- "#### for PWM backlighting on pimoroni displayhatmini"
- "dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4"
modules:
- "i2c-dev"
services: services:
enable: enable:
- bettercap.service - bettercap.service
@ -117,6 +97,7 @@
- bc - bc
- bison - bison
- bluez - bluez
- bluez-tools
- build-essential - build-essential
- curl - curl
- dkms - dkms
@ -178,6 +159,7 @@
- lsof - lsof
- make - make
- ntp - ntp
- python3-dbus
- python3-flask - python3-flask
- python3-flask-cors - python3-flask-cors
- python3-flaskext.wtf - python3-flaskext.wtf
@ -389,11 +371,6 @@
block: | block: |
export GOPATH=$HOME/go export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
alias custom='cd /usr/local/share/pwnagotchi/custom-plugins/'
alias config='sudo nano /etc/pwnagotchi/config.toml'
alias pwnlog='tail -f -n300 /etc/pwnagotchi/log/pwn*.log | sed --unbuffered "s/,[[:digit:]]\\{3\\}\\]//g" | cut -d " " -f 2-'
alias pwnver='python3 -c "import pwnagotchi as p; print(p.__version__)"'
alias pwnkill='sudo killall -USR1 pwnagotchi'
when: golang.changed when: golang.changed
- name: download pwngrid - name: download pwngrid
@ -475,20 +452,6 @@
path: /boot/ssh path: /boot/ssh
state: touch state: touch
- name: adjust /boot/config.txt
lineinfile:
dest: /boot/config.txt
insertafter: EOF
line: '{{ item }}'
with_items: "{{system.boot_options}}"
- name: adjust /etc/modules
lineinfile:
dest: /etc/modules
insertafter: EOF
line: '{{ item }}'
with_items: "{{system.modules}}"
- name: change root partition - name: change root partition
replace: replace:
dest: /boot/cmdline.txt dest: /boot/cmdline.txt

View File

@ -95,6 +95,6 @@ build {
provisioner "ansible-local" { provisioner "ansible-local" {
command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook" command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook"
extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""] extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""]
playbook_file = "data/64bit/raspberrypi64.yml" playbook_file = "raspberrypi64.yml"
} }
} }

View File

@ -11,23 +11,6 @@
pwnagotchi: pwnagotchi:
hostname: "{{ lookup('env', 'PWN_HOSTNAME') | default('pwnagotchi', true) }}" hostname: "{{ lookup('env', 'PWN_HOSTNAME') | default('pwnagotchi', true) }}"
version: "{{ lookup('env', 'PWN_VERSION') | default('pwnagotchi', true) }}" version: "{{ lookup('env', 'PWN_VERSION') | default('pwnagotchi', true) }}"
system:
boot_options:
- "dtoverlay=dwc2"
- "dtparam=i2c1=on"
- "dtparam=i2c_arm=on"
- "dtparam=spi=on"
- "gpu_mem=16"
- "[pi0]"
- "dtoverlay=spi0-0cs"
- "[pi3]"
- "dtoverlay=spi0-0cs"
- "[pi4]"
- "dtoverlay=spi0-0cs"
- "[pi5]"
- "dtoverlay=spi0-0cs"
modules:
- "i2c-dev"
services: services:
enable: enable:
- bettercap.service - bettercap.service
@ -81,6 +64,7 @@
- bc - bc
- bison - bison
- bluez - bluez
- bluez-tools
- build-essential - build-essential
- curl - curl
- dkms - dkms
@ -211,25 +195,6 @@
path: /etc/rc.local path: /etc/rc.local
state: absent state: absent
- name: adjust /boot/config.txt
blockinfile:
dest: /boot/config.txt
insertafter: EOF
block: |
dtoverlay=dwc2
dtparam=i2c1=on
dtparam=i2c_arm=on"
dtparam=spi=on
gpu_mem=16
[pi0]
dtoverlay=spi0-0cs
[pi3]
dtoverlay=spi0-0cs
[pi4]
dtoverlay=spi0-0cs
[pi5]
dtoverlay=spi0-0cs
- name: change root partition - name: change root partition
replace: replace:
dest: /boot/firmware/cmdline.txt dest: /boot/firmware/cmdline.txt
@ -517,16 +482,11 @@
- name: Update .bashrc for go-1.21 - name: Update .bashrc for go-1.21
blockinfile: blockinfile:
dest: /home/pi/.bashrc dest: /etc/profile
state: present state: present
block: | block: |
export GOPATH=$HOME/go export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
alias custom='cd /usr/local/share/pwnagotchi/custom-plugins/'
alias config='sudo nano /etc/pwnagotchi/config.toml'
alias pwnlog='tail -f -n300 /etc/pwnagotchi/log/pwn*.log | sed --unbuffered "s/,[[:digit:]]\\{3\\}\\]//g" | cut -d " " -f 2-'
alias pwnver='python3 -c "import pwnagotchi as p; print(p.__version__)"'
alias pwnkill='sudo killall -USR1 pwnagotchi'
when: golang.changed when: golang.changed
- name: download pwngrid - name: download pwngrid

View File

@ -1 +1 @@
__version__ = '2.8.7' __version__ = '2.8.9'

View File

@ -254,7 +254,7 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer):
txt = '%d (%d)' % (len(self._handshakes), tot) txt = '%d (%d)' % (len(self._handshakes), tot)
if self._last_pwnd is not None: if self._last_pwnd is not None:
txt += ' [%s]' % self._last_pwnd[:11] # So it doesn't overlap with fix_brcmfmac_plugin txt += ' [%s]' % self._last_pwnd
self._view.set('shakes', txt) self._view.set('shakes', txt)

View File

@ -100,7 +100,6 @@ class Client(object):
await asyncio.sleep(sleep_time) await asyncio.sleep(sleep_time)
continue continue
except OSError: except OSError:
sleep_time = min_sleep + max_sleep * random.random()
logging.warning('connection to the bettercap endpoint failed...') logging.warning('connection to the bettercap endpoint failed...')
pwnagotchi.restart("AUTO") pwnagotchi.restart("AUTO")

View File

@ -112,8 +112,6 @@ main.mon_stop_cmd = "/usr/bin/monstop"
main.mon_max_blind_epochs = 50 main.mon_max_blind_epochs = 50
main.no_restart = false main.no_restart = false
main.filter = ""
main.log.path = "/etc/pwnagotchi/log/pwnagotchi.log" main.log.path = "/etc/pwnagotchi/log/pwnagotchi.log"
main.log.rotation.enabled = true main.log.rotation.enabled = true
main.log.rotation.size = "10M" main.log.rotation.size = "10M"

View File

@ -248,7 +248,7 @@ msgid "minutes"
msgstr "minuten" msgstr "minuten"
msgid "seconds" msgid "seconds"
msgstr "seconds" msgstr "sekondes"
msgid "hour" msgid "hour"
msgstr "oere" msgstr "oere"

View File

@ -230,7 +230,7 @@ class AutoUpdate(plugins.Plugin):
if num_installed > 0: if num_installed > 0:
display.update(force=True, new_data={'status': 'Rebooting ...'}) display.update(force=True, new_data={'status': 'Rebooting ...'})
time.sleep(3) time.sleep(3)
os.system("service pwnagotchi restart") pwnagotchi.reboot()
except Exception as e: except Exception as e:
logging.error("[update] %s" % e) logging.error("[update] %s" % e)

View File

@ -4,6 +4,7 @@ import subprocess
import time import time
import random import random
from io import TextIOWrapper from io import TextIOWrapper
import os
import pwnagotchi import pwnagotchi
from pwnagotchi import plugins from pwnagotchi import plugins
@ -32,6 +33,8 @@ class FixServices(plugins.Plugin):
self.pattern2 = re.compile(r'wifi error while hopping to channel') self.pattern2 = re.compile(r'wifi error while hopping to channel')
self.pattern3 = re.compile(r'Firmware has halted or crashed') self.pattern3 = re.compile(r'Firmware has halted or crashed')
self.pattern4 = re.compile(r'error 400: could not find interface wlan0mon') self.pattern4 = re.compile(r'error 400: could not find interface wlan0mon')
self.pattern5 = re.compile(r'fatal error: concurrent map iteration and map write')
self.pattern6 = re.compile(r'panic: runtime error')
self.isReloadingMon = False self.isReloadingMon = False
self.connection = None self.connection = None
self.LASTTRY = 0 self.LASTTRY = 0
@ -177,6 +180,25 @@ class FixServices(plugins.Plugin):
except Exception as err: except Exception as err:
logging.error("[Fix_Services monstart]: %s" % repr(err)) logging.error("[Fix_Services monstart]: %s" % repr(err))
# Look for pattern 5
elif len(self.pattern5.findall(other_other_last_lines)) >= 1:
logging.debug("[Fix_Services] Bettercap has crashed!")
if hasattr(agent, 'view'):
display = agent.view()
display.set('status', 'Restarting pwnagotchi!')
display.update(force=True)
os.system("systemctl restart bettercap")
pwnagotchi.restart("AUTO")
# Look for pattern 6
elif len(self.pattern6.findall(other_other_last_lines)) >= 1:
logging.debug("[Fix_Services] Bettercap has crashed!")
if hasattr(agent, 'view'):
display = agent.view()
display.set('status', 'Restarting pwnagotchi!')
display.update(force=True)
os.system("systemctl restart bettercap")
pwnagotchi.restart("AUTO")
else: else:
print("logs look good") print("logs look good")

View File

@ -253,7 +253,6 @@ class Logtail(plugins.Plugin):
""" """
logging.info("Logtail plugin loaded.") logging.info("Logtail plugin loaded.")
def on_webhook(self, path, request): def on_webhook(self, path, request):
if not self.ready: if not self.ready:
return "Plugin not ready" return "Plugin not ready"

View File

@ -28,6 +28,39 @@ class Display(View):
def is_lcdhat(self): def is_lcdhat(self):
return self._implementation.name == 'lcdhat' return self._implementation.name == 'lcdhat'
def is_wavesharelcd0in96(self):
return self._implementation.name == 'wavesharelcd0in96'
def is_wavesharelcd1in3(self):
return self._implementation.name == 'wavesharelcd1in3'
def is_wavesharelcd1in8(self):
return self._implementation.name == 'wavesharelcd1in8'
def is_wavesharelcd1in9(self):
return self._implementation.name == 'wavesharelcd1in9'
def is_wavesharelcd1in14(self):
return self._implementation.name == 'wavesharelcd1in14'
def is_wavesharelcd1in28(self):
return self._implementation.name == 'wavesharelcd1in28'
def is_wavesharelcd1in47(self):
return self._implementation.name == 'wavesharelcd1in47'
def is_wavesharelcd1in54(self):
return self._implementation.name == 'wavesharelcd1in54'
def is_wavesharelcd1in69(self):
return self._implementation.name == 'wavesharelcd1in69'
def is_wavesharelcd2in0(self):
return self._implementation.name == 'wavesharelcd2in0'
def is_wavesharelcd2in4(self):
return self._implementation.name == 'wavesharelcd2in4'
def is_waveshare144lcd(self): def is_waveshare144lcd(self):
return self._implementation.name == 'waveshare144lcd' return self._implementation.name == 'waveshare144lcd'
@ -202,6 +235,9 @@ class Display(View):
def is_inky(self): def is_inky(self):
return self._implementation.name == 'inky' return self._implementation.name == 'inky'
def is_dummy_display(self):
return self._implementation.name == 'dummydisplay'
def is_papirus(self): def is_papirus(self):
return self._implementation.name == 'papirus' return self._implementation.name == 'papirus'
@ -232,6 +268,9 @@ class Display(View):
def is_waveshare35lcd(self): def is_waveshare35lcd(self):
return self._implementation.name == 'waveshare35lcd' return self._implementation.name == 'waveshare35lcd'
def is_adfruit213v3(self):
return self._implementation.name == 'adafruit2in13_v3'
def is_waveshare_any(self): def is_waveshare_any(self):
return self.is_waveshare_v1() or self.is_waveshare_v2() return self.is_waveshare_v1() or self.is_waveshare_v2()

View File

@ -27,6 +27,7 @@ PNG = False
POSITION_X = 0 POSITION_X = 0
POSITION_Y = 40 POSITION_Y = 40
def load_from_config(config): def load_from_config(config):
for face_name, face_value in config.items(): for face_name, face_value in config.items():
globals()[face_name.upper()] = face_value globals()[face_name.upper()] = face_value

View File

@ -1,283 +1,333 @@
from pwnagotchi.ui.hw.inky import Inky
from pwnagotchi.ui.hw.papirus import Papirus
from pwnagotchi.ui.hw.oledhat import OledHat
from pwnagotchi.ui.hw.lcdhat import LcdHat
from pwnagotchi.ui.hw.dfrobot import DFRobotV1
from pwnagotchi.ui.hw.dfrobot_v2 import DFRobotV2
from pwnagotchi.ui.hw.waveshare2in13 import WaveshareV1
from pwnagotchi.ui.hw.waveshare2in13_V2 import WaveshareV2
from pwnagotchi.ui.hw.waveshare2in13_V3 import WaveshareV3
from pwnagotchi.ui.hw.waveshare2in13_V4 import WaveshareV4
from pwnagotchi.ui.hw.waveshare2in7 import Waveshare27inch
from pwnagotchi.ui.hw.waveshare2in7_V2 import Waveshare27inchV2
from pwnagotchi.ui.hw.waveshare2in9 import Waveshare29inch
from pwnagotchi.ui.hw.waveshare2in9_V2 import Waveshare29inchV2
from pwnagotchi.ui.hw.waveshare1in44lcd import Waveshare144lcd
from pwnagotchi.ui.hw.waveshare1in54b import Waveshare154inchb
from pwnagotchi.ui.hw.waveshare2in13bc import Waveshare213bc
from pwnagotchi.ui.hw.waveshare2in13d import Waveshare213d
from pwnagotchi.ui.hw.waveshare2in13g import Waveshare2in13g
from pwnagotchi.ui.hw.waveshare2in13b_V4 import Waveshare213bV4
from pwnagotchi.ui.hw.waveshare3in5lcd import Waveshare35lcd
from pwnagotchi.ui.hw.spotpear24in import Spotpear24inch
from pwnagotchi.ui.hw.displayhatmini import DisplayHatMini
from pwnagotchi.ui.hw.pirateaudio import PirateAudio
from pwnagotchi.ui.hw.pitft import Pitft
from pwnagotchi.ui.hw.tftbonnet import TftBonnet
from pwnagotchi.ui.hw.waveshareoledlcd import Waveshareoledlcd
from pwnagotchi.ui.hw.waveshare1in02 import Waveshare1in02
from pwnagotchi.ui.hw.waveshare1in54 import Waveshare154
from pwnagotchi.ui.hw.waveshare1in54_V2 import Waveshare154V2
from pwnagotchi.ui.hw.waveshare1in54b_V2 import Waveshare154bV2
from pwnagotchi.ui.hw.waveshare1in54c import Waveshare1in54c
from pwnagotchi.ui.hw.waveshare1in64g import Waveshare1in64g
from pwnagotchi.ui.hw.waveshare2in7b import Waveshare27b
from pwnagotchi.ui.hw.waveshare2in7b_V2 import Waveshare27bV2
from pwnagotchi.ui.hw.waveshare2in9b_V3 import Waveshare29bV3
from pwnagotchi.ui.hw.waveshare2in9b_V4 import Waveshare29bV4
from pwnagotchi.ui.hw.waveshare2in9bc import Waveshare2in9bc
from pwnagotchi.ui.hw.waveshare2in9d import Waveshare2in9d
from pwnagotchi.ui.hw.waveshare2in13b_V3 import Waveshare2in13bV3
from pwnagotchi.ui.hw.waveshare2in36g import Waveshare2in36g
from pwnagotchi.ui.hw.waveshare2in66 import Waveshare2in66
from pwnagotchi.ui.hw.waveshare2in66b import Waveshare2in66b
from pwnagotchi.ui.hw.waveshare2in66g import Waveshare2in66g
from pwnagotchi.ui.hw.waveshare3in0g import Waveshare3in0g
from pwnagotchi.ui.hw.waveshare3in7 import Waveshare3in7
from pwnagotchi.ui.hw.waveshare3in52 import Waveshare3in52
from pwnagotchi.ui.hw.waveshare4in01f import Waveshare4in01f
from pwnagotchi.ui.hw.waveshare4in2 import Waveshare4in2
from pwnagotchi.ui.hw.waveshare4in2_V2 import Waveshare4in2V2
from pwnagotchi.ui.hw.waveshare4in2b_V2 import Waveshare4in2bV2
from pwnagotchi.ui.hw.waveshare4in2bc import Waveshare4in2bc
from pwnagotchi.ui.hw.waveshare4in26 import Waveshare4in26
from pwnagotchi.ui.hw.waveshare4in37g import Waveshare4in37g
from pwnagotchi.ui.hw.waveshare5in65f import Waveshare5in65f
from pwnagotchi.ui.hw.waveshare5in79 import Waveshare5in79
from pwnagotchi.ui.hw.waveshare5in79b import Waveshare5in79b
from pwnagotchi.ui.hw.waveshare5in83 import Waveshare5in83
from pwnagotchi.ui.hw.waveshare5in83_V2 import Waveshare5in83V2
from pwnagotchi.ui.hw.waveshare5in83b_V2 import Waveshare5in83bV2
from pwnagotchi.ui.hw.waveshare5in83bc import Waveshare5in83bc
from pwnagotchi.ui.hw.waveshare7in3f import Waveshare7in3f
from pwnagotchi.ui.hw.waveshare7in3g import Waveshare7in3g
from pwnagotchi.ui.hw.waveshare7in5 import Waveshare7in5
from pwnagotchi.ui.hw.waveshare7in5_HD import Waveshare7in5HD
from pwnagotchi.ui.hw.waveshare7in5_V2 import Waveshare7in5V2
from pwnagotchi.ui.hw.waveshare7in5b_HD import Waveshare7in5bHD
from pwnagotchi.ui.hw.waveshare7in5b_V2 import Waveshare7in5bV2
from pwnagotchi.ui.hw.waveshare7in5bc import Waveshare7in5bc
from pwnagotchi.ui.hw.waveshare13in3k import Waveshare13in3k
def display_for(config): def display_for(config):
# config has been normalized already in utils.load_config # config has been normalized already in utils.load_config
if config['ui']['display']['type'] == 'inky': if config['ui']['display']['type'] == 'inky':
from pwnagotchi.ui.hw.inky import Inky
return Inky(config) return Inky(config)
elif config['ui']['display']['type'] == 'wavesharelcd0in96':
from pwnagotchi.ui.hw.wavesharelcd0in96 import Wavesharelcd0in96
return Wavesharelcd0in96(config)
elif config['ui']['display']['type'] == 'wavesharelcd1in3':
from pwnagotchi.ui.hw.wavesharelcd1in3 import Wavesharelcd1in3
return Wavesharelcd1in3(config)
elif config['ui']['display']['type'] == 'wavesharelcd1in8':
from pwnagotchi.ui.hw.wavesharelcd1in8 import Wavesharelcd1in8
return Wavesharelcd1in8(config)
elif config['ui']['display']['type'] == 'wavesharelcd1in9':
from pwnagotchi.ui.hw.wavesharelcd1in9 import Wavesharelcd1in9
return Wavesharelcd1in9(config)
elif config['ui']['display']['type'] == 'wavesharelcd1in14':
from pwnagotchi.ui.hw.wavesharelcd1in14 import Wavesharelcd1in14
return Wavesharelcd1in14(config)
elif config['ui']['display']['type'] == 'wavesharelcd1in28':
from pwnagotchi.ui.hw.wavesharelcd1in28 import Wavesharelcd1in28
return Wavesharelcd1in28(config)
elif config['ui']['display']['type'] == 'wavesharelcd1in47':
from pwnagotchi.ui.hw.wavesharelcd1in47 import Wavesharelcd1in47
return Wavesharelcd1in47(config)
elif config['ui']['display']['type'] == 'wavesharelcd1in54':
from pwnagotchi.ui.hw.wavesharelcd1in54 import Wavesharelcd1in54
return Wavesharelcd1in54(config)
elif config['ui']['display']['type'] == 'wavesharelcd1in69':
from pwnagotchi.ui.hw.wavesharelcd1in69 import Wavesharelcd1in69
return Wavesharelcd1in69(config)
elif config['ui']['display']['type'] == 'wavesharelcd2in0':
from pwnagotchi.ui.hw.wavesharelcd2in0 import Wavesharelcd2in0
return Wavesharelcd2in0(config)
elif config['ui']['display']['type'] == 'wavesharelcd2in4':
from pwnagotchi.ui.hw.wavesharelcd2in4 import Wavesharelcd2in4
return Wavesharelcd2in4(config)
elif config['ui']['display']['type'] == 'dummydisplay':
from pwnagotchi.ui.hw.dummydisplay import DummyDisplay
return DummyDisplay(config)
elif config['ui']['display']['type'] == 'papirus': elif config['ui']['display']['type'] == 'papirus':
from pwnagotchi.ui.hw.papirus import Papirus
return Papirus(config) return Papirus(config)
elif config['ui']['display']['type'] == 'oledhat': elif config['ui']['display']['type'] == 'oledhat':
from pwnagotchi.ui.hw.oledhat import OledHat
return OledHat(config) return OledHat(config)
elif config['ui']['display']['type'] == 'lcdhat': elif config['ui']['display']['type'] == 'lcdhat':
from pwnagotchi.ui.hw.lcdhat import LcdHat
return LcdHat(config) return LcdHat(config)
elif config['ui']['display']['type'] == 'dfrobot_1': elif config['ui']['display']['type'] == 'dfrobot_1':
from pwnagotchi.ui.hw.dfrobot import DFRobotV1
return DFRobotV1(config) return DFRobotV1(config)
elif config['ui']['display']['type'] == 'dfrobot_2': elif config['ui']['display']['type'] == 'dfrobot_2':
from pwnagotchi.ui.hw.dfrobot_v2 import DFRobotV2
return DFRobotV2(config) return DFRobotV2(config)
elif config['ui']['display']['type'] == 'waveshare144lcd': elif config['ui']['display']['type'] == 'waveshare144lcd':
from pwnagotchi.ui.hw.waveshare1in44lcd import Waveshare144lcd
return Waveshare144lcd(config) return Waveshare144lcd(config)
elif config['ui']['display']['type'] == 'waveshare35lcd': elif config['ui']['display']['type'] == 'waveshare35lcd':
from pwnagotchi.ui.hw.waveshare3in5lcd import Waveshare35lcd
return Waveshare35lcd(config) return Waveshare35lcd(config)
elif config['ui']['display']['type'] == 'spotpear24inch': elif config['ui']['display']['type'] == 'spotpear24inch':
from pwnagotchi.ui.hw.spotpear24in import Spotpear24inch
return Spotpear24inch(config) return Spotpear24inch(config)
elif config['ui']['display']['type'] == 'displayhatmini': elif config['ui']['display']['type'] == 'displayhatmini':
from pwnagotchi.ui.hw.displayhatmini import DisplayHatMini
return DisplayHatMini(config) return DisplayHatMini(config)
elif config['ui']['display']['type'] == 'pirateaudio': elif config['ui']['display']['type'] == 'pirateaudio':
from pwnagotchi.ui.hw.pirateaudio import PirateAudio
return PirateAudio(config) return PirateAudio(config)
elif config['ui']['display']['type'] == 'pitft': elif config['ui']['display']['type'] == 'pitft':
from pwnagotchi.ui.hw.pitft import Pitft
return Pitft(config) return Pitft(config)
elif config['ui']['display']['type'] == 'tftbonnet': elif config['ui']['display']['type'] == 'tftbonnet':
from pwnagotchi.ui.hw.tftbonnet import TftBonnet
return TftBonnet(config) return TftBonnet(config)
elif config['ui']['display']['type'] == 'waveshareoledlcd': elif config['ui']['display']['type'] == 'waveshareoledlcd':
from pwnagotchi.ui.hw.waveshareoledlcd import Waveshareoledlcd
return Waveshareoledlcd(config) return Waveshareoledlcd(config)
elif config['ui']['display']['type'] == 'waveshare1in02': elif config['ui']['display']['type'] == 'waveshare1in02':
from pwnagotchi.ui.hw.waveshare1in02 import Waveshare1in02
return Waveshare1in02(config) return Waveshare1in02(config)
elif config['ui']['display']['type'] == 'waveshare1in54': elif config['ui']['display']['type'] == 'waveshare1in54':
from pwnagotchi.ui.hw.waveshare1in54 import Waveshare154
return Waveshare154(config) return Waveshare154(config)
elif config['ui']['display']['type'] == 'waveshare1in54_v2': elif config['ui']['display']['type'] == 'waveshare1in54_v2':
from pwnagotchi.ui.hw.waveshare1in54_V2 import Waveshare154V2
return Waveshare154V2(config) return Waveshare154V2(config)
elif config['ui']['display']['type'] == 'waveshare1in54b': elif config['ui']['display']['type'] == 'waveshare1in54b':
from pwnagotchi.ui.hw.waveshare1in54b import Waveshare154inchb
return Waveshare154inchb(config) return Waveshare154inchb(config)
elif config['ui']['display']['type'] == 'waveshare1in54b_v2': elif config['ui']['display']['type'] == 'waveshare1in54b_v2':
from pwnagotchi.ui.hw.waveshare1in54b_V2 import Waveshare154bV2
return Waveshare154bV2(config) return Waveshare154bV2(config)
elif config['ui']['display']['type'] == 'waveshare1in54c': elif config['ui']['display']['type'] == 'waveshare1in54c':
from pwnagotchi.ui.hw.waveshare1in54c import Waveshare1in54c
return Waveshare1in54c(config) return Waveshare1in54c(config)
elif config['ui']['display']['type'] == 'waveshare1in64g': elif config['ui']['display']['type'] == 'waveshare1in64g':
from pwnagotchi.ui.hw.waveshare1in64g import Waveshare1in64g
return Waveshare1in64g(config) return Waveshare1in64g(config)
elif config['ui']['display']['type'] == 'waveshare2in7': elif config['ui']['display']['type'] == 'waveshare2in7':
from pwnagotchi.ui.hw.waveshare2in7 import Waveshare27inch
return Waveshare27inch(config) return Waveshare27inch(config)
elif config['ui']['display']['type'] == 'waveshare2in7_v2': elif config['ui']['display']['type'] == 'waveshare2in7_v2':
from pwnagotchi.ui.hw.waveshare2in7_V2 import Waveshare27inchV2
return Waveshare27inchV2(config) return Waveshare27inchV2(config)
elif config['ui']['display']['type'] == 'waveshare2in7b': elif config['ui']['display']['type'] == 'waveshare2in7b':
from pwnagotchi.ui.hw.waveshare2in7b import Waveshare27b
return Waveshare27b(config) return Waveshare27b(config)
elif config['ui']['display']['type'] == 'waveshare2in7b_v2': elif config['ui']['display']['type'] == 'waveshare2in7b_v2':
from pwnagotchi.ui.hw.waveshare2in7b_V2 import Waveshare27bV2
return Waveshare27bV2(config) return Waveshare27bV2(config)
elif config['ui']['display']['type'] == 'waveshare2in9': elif config['ui']['display']['type'] == 'waveshare2in9':
from pwnagotchi.ui.hw.waveshare2in9 import Waveshare29inch
return Waveshare29inch(config) return Waveshare29inch(config)
elif config['ui']['display']['type'] == 'waveshare2in9bc': elif config['ui']['display']['type'] == 'waveshare2in9bc':
from pwnagotchi.ui.hw.waveshare2in9bc import Waveshare2in9bc
return Waveshare2in9bc(config) return Waveshare2in9bc(config)
elif config['ui']['display']['type'] == 'waveshare2in9d': elif config['ui']['display']['type'] == 'waveshare2in9d':
from pwnagotchi.ui.hw.waveshare2in9d import Waveshare2in9d
return Waveshare2in9d(config) return Waveshare2in9d(config)
elif config['ui']['display']['type'] == 'waveshare2in9_v2': elif config['ui']['display']['type'] == 'waveshare2in9_v2':
from pwnagotchi.ui.hw.waveshare2in9_V2 import Waveshare29inchV2
return Waveshare29inchV2(config) return Waveshare29inchV2(config)
elif config['ui']['display']['type'] == 'waveshare2in9b_v3': elif config['ui']['display']['type'] == 'waveshare2in9b_v3':
from pwnagotchi.ui.hw.waveshare2in9b_V3 import Waveshare29bV3
return Waveshare29bV3(config) return Waveshare29bV3(config)
elif config['ui']['display']['type'] == 'waveshare2in9b_v4': elif config['ui']['display']['type'] == 'waveshare2in9b_v4':
from pwnagotchi.ui.hw.waveshare2in9b_V4 import Waveshare29bV4
return Waveshare29bV4(config) return Waveshare29bV4(config)
elif config['ui']['display']['type'] == 'waveshare_1': elif config['ui']['display']['type'] == 'waveshare_1':
from pwnagotchi.ui.hw.waveshare2in13 import WaveshareV1
return WaveshareV1(config) return WaveshareV1(config)
elif config['ui']['display']['type'] == 'waveshare_2': elif config['ui']['display']['type'] == 'waveshare_2':
from pwnagotchi.ui.hw.waveshare2in13_V2 import WaveshareV2
return WaveshareV2(config) return WaveshareV2(config)
elif config['ui']['display']['type'] == 'waveshare_3': elif config['ui']['display']['type'] == 'waveshare_3':
from pwnagotchi.ui.hw.waveshare2in13_V3 import WaveshareV3
return WaveshareV3(config) return WaveshareV3(config)
elif config['ui']['display']['type'] == 'waveshare_4': elif config['ui']['display']['type'] == 'waveshare_4':
from pwnagotchi.ui.hw.waveshare2in13_V4 import WaveshareV4
return WaveshareV4(config) return WaveshareV4(config)
elif config['ui']['display']['type'] == 'adafruit2in13_v3':
from pwnagotchi.ui.hw.adafruit2in13 import Adafruit2in13V3
return Adafruit2in13V3(config)
elif config['ui']['display']['type'] == 'waveshare2in13bc': elif config['ui']['display']['type'] == 'waveshare2in13bc':
from pwnagotchi.ui.hw.waveshare2in13bc import Waveshare213bc
return Waveshare213bc(config) return Waveshare213bc(config)
elif config['ui']['display']['type'] == 'waveshare2in13d': elif config['ui']['display']['type'] == 'waveshare2in13d':
from pwnagotchi.ui.hw.waveshare2in13d import Waveshare213d
return Waveshare213d(config) return Waveshare213d(config)
elif config['ui']['display']['type'] == 'waveshare2in13b_v3': elif config['ui']['display']['type'] == 'waveshare2in13b_v3':
from pwnagotchi.ui.hw.waveshare2in13b_V3 import Waveshare2in13bV3
return Waveshare2in13bV3(config) return Waveshare2in13bV3(config)
elif config['ui']['display']['type'] == 'waveshare2in13b_v4': elif config['ui']['display']['type'] == 'waveshare2in13b_v4':
from pwnagotchi.ui.hw.waveshare2in13b_V4 import Waveshare213bV4
return Waveshare213bV4(config) return Waveshare213bV4(config)
elif config['ui']['display']['type'] == 'waveshare2in13g': elif config['ui']['display']['type'] == 'waveshare2in13g':
from pwnagotchi.ui.hw.waveshare2in13g import Waveshare2in13g
return Waveshare2in13g(config) return Waveshare2in13g(config)
elif config['ui']['display']['type'] == 'waveshare2in36g': elif config['ui']['display']['type'] == 'waveshare2in36g':
from pwnagotchi.ui.hw.waveshare2in36g import Waveshare2in36g
return Waveshare2in36g(config) return Waveshare2in36g(config)
elif config['ui']['display']['type'] == 'waveshare2in66': elif config['ui']['display']['type'] == 'waveshare2in66':
from pwnagotchi.ui.hw.waveshare2in66 import Waveshare2in66
return Waveshare2in66(config) return Waveshare2in66(config)
elif config['ui']['display']['type'] == 'waveshare2in66b': elif config['ui']['display']['type'] == 'waveshare2in66b':
from pwnagotchi.ui.hw.waveshare2in66b import Waveshare2in66b
return Waveshare2in66b(config) return Waveshare2in66b(config)
elif config['ui']['display']['type'] == 'waveshare2in66g': elif config['ui']['display']['type'] == 'waveshare2in66g':
from pwnagotchi.ui.hw.waveshare2in66g import Waveshare2in66g
return Waveshare2in66g(config) return Waveshare2in66g(config)
elif config['ui']['display']['type'] == 'waveshare3in0g': elif config['ui']['display']['type'] == 'waveshare3in0g':
from pwnagotchi.ui.hw.waveshare3in0g import Waveshare3in0g
return Waveshare3in0g(config) return Waveshare3in0g(config)
elif config['ui']['display']['type'] == 'waveshare3in7': elif config['ui']['display']['type'] == 'waveshare3in7':
from pwnagotchi.ui.hw.waveshare3in7 import Waveshare3in7
return Waveshare3in7(config) return Waveshare3in7(config)
elif config['ui']['display']['type'] == 'waveshare3in52': elif config['ui']['display']['type'] == 'waveshare3in52':
from pwnagotchi.ui.hw.waveshare3in52 import Waveshare3in52
return Waveshare3in52(config) return Waveshare3in52(config)
elif config['ui']['display']['type'] == 'waveshare4in01f': elif config['ui']['display']['type'] == 'waveshare4in01f':
from pwnagotchi.ui.hw.waveshare4in01f import Waveshare4in01f
return Waveshare4in01f(config) return Waveshare4in01f(config)
elif config['ui']['display']['type'] == 'waveshare4in2': elif config['ui']['display']['type'] == 'waveshare4in2':
from pwnagotchi.ui.hw.waveshare4in2 import Waveshare4in2
return Waveshare4in2(config) return Waveshare4in2(config)
elif config['ui']['display']['type'] == 'waveshare4in2_v2': elif config['ui']['display']['type'] == 'waveshare4in2_v2':
from pwnagotchi.ui.hw.waveshare4in2_V2 import Waveshare4in2V2
return Waveshare4in2V2(config) return Waveshare4in2V2(config)
elif config['ui']['display']['type'] == 'waveshare4in2b_v2': elif config['ui']['display']['type'] == 'waveshare4in2b_v2':
from pwnagotchi.ui.hw.waveshare4in2b_V2 import Waveshare4in2bV2
return Waveshare4in2bV2(config) return Waveshare4in2bV2(config)
elif config['ui']['display']['type'] == 'waveshare4in2bc': elif config['ui']['display']['type'] == 'waveshare4in2bc':
from pwnagotchi.ui.hw.waveshare4in2bc import Waveshare4in2bc
return Waveshare4in2bc(config) return Waveshare4in2bc(config)
elif config['ui']['display']['type'] == 'waveshare4in26': elif config['ui']['display']['type'] == 'waveshare4in26':
from pwnagotchi.ui.hw.waveshare4in26 import Waveshare4in26
return Waveshare4in26(config) return Waveshare4in26(config)
elif config['ui']['display']['type'] == 'waveshare4in37g': elif config['ui']['display']['type'] == 'waveshare4in37g':
from pwnagotchi.ui.hw.waveshare4in37g import Waveshare4in37g
return Waveshare4in37g(config) return Waveshare4in37g(config)
elif config['ui']['display']['type'] == 'waveshare5in65f': elif config['ui']['display']['type'] == 'waveshare5in65f':
from pwnagotchi.ui.hw.waveshare5in65f import Waveshare5in65f
return Waveshare5in65f(config) return Waveshare5in65f(config)
elif config['ui']['display']['type'] == 'waveshare5in79': elif config['ui']['display']['type'] == 'waveshare5in79':
from pwnagotchi.ui.hw.waveshare5in79 import Waveshare5in79
return Waveshare5in79(config) return Waveshare5in79(config)
elif config['ui']['display']['type'] == 'waveshare5in79b': elif config['ui']['display']['type'] == 'waveshare5in79b':
from pwnagotchi.ui.hw.waveshare5in79b import Waveshare5in79b
return Waveshare5in79b(config) return Waveshare5in79b(config)
elif config['ui']['display']['type'] == 'waveshare5in83': elif config['ui']['display']['type'] == 'waveshare5in83':
from pwnagotchi.ui.hw.waveshare5in83 import Waveshare5in83
return Waveshare5in83(config) return Waveshare5in83(config)
elif config['ui']['display']['type'] == 'waveshare5in83_v2': elif config['ui']['display']['type'] == 'waveshare5in83_v2':
from pwnagotchi.ui.hw.waveshare5in83_V2 import Waveshare5in83V2
return Waveshare5in83V2(config) return Waveshare5in83V2(config)
elif config['ui']['display']['type'] == 'waveshare5in83b_v2': elif config['ui']['display']['type'] == 'waveshare5in83b_v2':
from pwnagotchi.ui.hw.waveshare5in83b_V2 import Waveshare5in83bV2
return Waveshare5in83bV2(config) return Waveshare5in83bV2(config)
elif config['ui']['display']['type'] == 'waveshare5in83bc': elif config['ui']['display']['type'] == 'waveshare5in83bc':
from pwnagotchi.ui.hw.waveshare5in83bc import Waveshare5in83bc
return Waveshare5in83bc(config) return Waveshare5in83bc(config)
elif config['ui']['display']['type'] == 'waveshare7in3f': elif config['ui']['display']['type'] == 'waveshare7in3f':
from pwnagotchi.ui.hw.waveshare7in3f import Waveshare7in3f
return Waveshare7in3f(config) return Waveshare7in3f(config)
elif config['ui']['display']['type'] == 'waveshare7in3g': elif config['ui']['display']['type'] == 'waveshare7in3g':
from pwnagotchi.ui.hw.waveshare7in3g import Waveshare7in3g
return Waveshare7in3g(config) return Waveshare7in3g(config)
elif config['ui']['display']['type'] == 'waveshare7in5': elif config['ui']['display']['type'] == 'waveshare7in5':
from pwnagotchi.ui.hw.waveshare7in5 import Waveshare7in5
return Waveshare7in5(config) return Waveshare7in5(config)
elif config['ui']['display']['type'] == 'waveshare7in5_HD': elif config['ui']['display']['type'] == 'waveshare7in5_HD':
from pwnagotchi.ui.hw.waveshare7in5_HD import Waveshare7in5HD
return Waveshare7in5HD(config) return Waveshare7in5HD(config)
elif config['ui']['display']['type'] == 'waveshare7in5_v2': elif config['ui']['display']['type'] == 'waveshare7in5_v2':
from pwnagotchi.ui.hw.waveshare7in5_V2 import Waveshare7in5V2
return Waveshare7in5V2(config) return Waveshare7in5V2(config)
elif config['ui']['display']['type'] == 'waveshare7in5b_HD': elif config['ui']['display']['type'] == 'waveshare7in5b_HD':
from pwnagotchi.ui.hw.waveshare7in5b_HD import Waveshare7in5bHD
return Waveshare7in5bHD(config) return Waveshare7in5bHD(config)
elif config['ui']['display']['type'] == 'waveshare7in5b_v2': elif config['ui']['display']['type'] == 'waveshare7in5b_v2':
from pwnagotchi.ui.hw.waveshare7in5b_V2 import Waveshare7in5bV2
return Waveshare7in5bV2(config) return Waveshare7in5bV2(config)
elif config['ui']['display']['type'] == 'waveshare7in5bc': elif config['ui']['display']['type'] == 'waveshare7in5bc':
from pwnagotchi.ui.hw.waveshare7in5bc import Waveshare7in5bc
return Waveshare7in5bc(config) return Waveshare7in5bc(config)
elif config['ui']['display']['type'] == 'waveshare13in3k': elif config['ui']['display']['type'] == 'waveshare13in3k':
from pwnagotchi.ui.hw.waveshare13in3k import Waveshare13in3k
return Waveshare13in3k(config) return Waveshare13in3k(config)

View File

@ -0,0 +1,45 @@
import logging
import pwnagotchi.ui.fonts as fonts
from pwnagotchi.ui.hw.base import DisplayImpl
class Adafruit2in13V3(DisplayImpl):
def __init__(self, config):
super(Adafruit2in13V3, self).__init__(config, 'adafruit2in13_v3')
def layout(self):
fonts.setup(10, 9, 10, 35, 25, 9)
self._layout['width'] = 250
self._layout['height'] = 122
self._layout['face'] = (0, 40)
self._layout['name'] = (5, 20)
self._layout['channel'] = (0, 0)
self._layout['aps'] = (28, 0)
self._layout['uptime'] = (185, 0)
self._layout['line1'] = [0, 14, 250, 14]
self._layout['line2'] = [0, 108, 250, 108]
self._layout['friend_face'] = (0, 92)
self._layout['friend_name'] = (40, 94)
self._layout['shakes'] = (0, 109)
self._layout['mode'] = (225, 109)
self._layout['status'] = {
'pos': (125, 20),
'font': fonts.status_font(fonts.Medium),
'max': 20
}
return self._layout
def initialize(self):
logging.info("initializing adafruit 2in13 V3 display")
from pwnagotchi.ui.hw.libs.adafruit.v2in13_v3.epd2in13_v3 import EPD
self._display = EPD()
self._display.init()
self._display.Clear(0xFF)
def render(self, canvas):
buf = self._display.getbuffer(canvas)
self._display.displayPartial(buf)
def clear(self):
self._display.Clear(0xFF)

View File

@ -34,7 +34,7 @@ class DisplayHatMini(DisplayImpl):
def initialize(self): def initialize(self):
logging.info("initializing Display Hat Mini") logging.info("initializing Display Hat Mini")
from pwnagotchi.ui.hw.libs.pimoroni.displayhatmini.ST7789 import ST7789 from pwnagotchi.ui.hw.libs.pimoroni.displayhatmini.ST7789 import ST7789
self._display = ST7789(0,1,9,13) self._display = ST7789(0, 1, 9, 13)
def render(self, canvas): def render(self, canvas):
self._display.display(canvas) self._display.display(canvas)

View File

@ -0,0 +1,43 @@
import logging
import pwnagotchi.ui.fonts as fonts
from pwnagotchi.ui.hw.base import DisplayImpl
class DummyDisplay(DisplayImpl):
def __init__(self, config):
super(DummyDisplay, self).__init__(config, 'DummyDisplay')
def layout(self):
width = 480 if 'width' not in self.config else self.config['width']
height = 720 if 'height' not in self.config else self.config['height']
fonts.setup(int(height/30), int(height/40), int(height/30), int(height/6), int(height/30), int(height/35))
self._layout['width'] = width
self._layout['height'] = height
self._layout['face'] = (0, int(width/12))
self._layout['name'] = (5, int(width/25))
self._layout['channel'] = (0, 0)
self._layout['aps'] = (int(width/8), 0)
self._layout['uptime'] = (width-int(width/12), 0)
self._layout['line1'] = [0, int(height/32), width, int(height/32)]
self._layout['line2'] = [0, height-int(height/25)-1, width, height-int(height/25)-1]
self._layout['friend_face'] = (0, int(height/10))
self._layout['friend_name'] = (int(width/12), int(height/10))
self._layout['shakes'] = (0, height-int(height/25))
self._layout['mode'] = (width-int(width/8), height - int (height/25))
lw, lh = fonts.Small.getsize("W")
self._layout['status'] = {
'pos': (int(width/48), int(height/3)),
'font': fonts.status_font(fonts.Small),
'max': int(width / lw)
}
return self._layout
def initialize(self):
return
def render(self, canvas):
return
def clear(self):
return

View File

@ -33,7 +33,7 @@ class LcdHat(DisplayImpl):
def initialize(self): def initialize(self):
logging.info("initializing lcdhat display") logging.info("initializing lcdhat display")
from pwnagotchi.ui.hw.libs.waveshare.lcdhat.epd import EPD from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat.epd import EPD
self._display = EPD() self._display = EPD()
self._display.init() self._display.init()
self._display.clear() self._display.clear()

View File

@ -0,0 +1,132 @@
# /*****************************************************************************
# * | File : epdconfig.py
# * | Author : Waveshare team
# * | Function : Hardware underlying interface
# * | Info :
# *----------------
# * | This version: V1.2
# * | Date : 2022-10-29
# * | Info :
# ******************************************************************************
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
import os
import logging
import sys
import time
import subprocess
logger = logging.getLogger(__name__)
class RaspberryPi:
# Pin definition
RST_PIN = 27
DC_PIN = 22
CS_PIN = 8
BUSY_PIN = 17
PWR_PIN = 18
def __init__(self):
import spidev
import gpiozero
self.SPI = spidev.SpiDev()
self.GPIO_RST_PIN = gpiozero.LED(self.RST_PIN)
self.GPIO_DC_PIN = gpiozero.LED(self.DC_PIN)
self.GPIO_CS_PIN = gpiozero.LED(self.CS_PIN)
self.GPIO_PWR_PIN = gpiozero.LED(self.PWR_PIN)
self.GPIO_BUSY_PIN = gpiozero.Button(self.BUSY_PIN, pull_up=False)
def digital_write(self, pin, value):
if pin == self.RST_PIN:
if value:
self.GPIO_RST_PIN.on()
else:
self.GPIO_RST_PIN.off()
elif pin == self.DC_PIN:
if value:
self.GPIO_DC_PIN.on()
else:
self.GPIO_DC_PIN.off()
elif pin == self.CS_PIN:
if value:
self.GPIO_CS_PIN.on()
else:
self.GPIO_CS_PIN.off()
elif pin == self.PWR_PIN:
if value:
self.GPIO_PWR_PIN.on()
else:
self.GPIO_PWR_PIN.off()
def digital_read(self, pin):
if pin == self.BUSY_PIN:
return self.GPIO_BUSY_PIN.value
elif pin == self.RST_PIN:
return self.RST_PIN.value
elif pin == self.DC_PIN:
return self.DC_PIN.value
elif pin == self.CS_PIN:
return self.CS_PIN.value
elif pin == self.PWR_PIN:
return self.PWR_PIN.value
def delay_ms(self, delaytime):
time.sleep(delaytime / 1000.0)
def spi_writebyte(self, data):
self.SPI.writebytes(data)
def spi_writebyte2(self, data):
self.SPI.writebytes2(data)
def module_init(self):
self.GPIO_PWR_PIN.on()
# SPI device, bus = 0, device = 0
self.SPI.open(0, 0)
self.SPI.max_speed_hz = 4000000
self.SPI.mode = 0b00
return 0
def module_exit(self, cleanup=False):
logger.debug("spi end")
self.SPI.close()
self.GPIO_RST_PIN.off()
self.GPIO_DC_PIN.off()
self.GPIO_PWR_PIN.off()
logger.debug("close 5V, Module enters 0 power consumption ...")
if cleanup:
self.GPIO_RST_PIN.close()
self.GPIO_DC_PIN.close()
self.GPIO_CS_PIN.close()
self.GPIO_PWR_PIN.close()
self.GPIO_BUSY_PIN.close()
implementation = RaspberryPi()
for func in [x for x in dir(implementation) if not x.startswith('_')]:
setattr(sys.modules[__name__], func, getattr(implementation, func))
### END OF FILE ###

View File

@ -93,6 +93,7 @@ ILI9341_GMCTRN1 = 0xE1
ILI9341_PWCTR6 = 0xFC ILI9341_PWCTR6 = 0xFC
class ILI9341(object): class ILI9341(object):
"""Representation of an ILI9341 TFT LCD.""" """Representation of an ILI9341 TFT LCD."""
@ -349,7 +350,6 @@ class ILI9341(object):
# Rotate the image # Rotate the image
pb = np.rot90(image, rotation // 90).astype('uint16') pb = np.rot90(image, rotation // 90).astype('uint16')
# Mask and shift the 888 RGB into 565 RGB # Mask and shift the 888 RGB into 565 RGB
red = (pb[..., [0]] & 0xf8) << 8 red = (pb[..., [0]] & 0xf8) << 8
green = (pb[..., [1]] & 0xfc) << 3 green = (pb[..., [1]] & 0xfc) << 3

View File

@ -1,144 +1,164 @@
FBIOGET_VSCREENINFO=0x4600 FBIOGET_VSCREENINFO = 0x4600
FBIOPUT_VSCREENINFO=0x4601 FBIOPUT_VSCREENINFO = 0x4601
FBIOGET_FSCREENINFO=0x4602 FBIOGET_FSCREENINFO = 0x4602
FBIOGETCMAP=0x4604 FBIOGETCMAP = 0x4604
FBIOPUTCMAP=0x4605 FBIOPUTCMAP = 0x4605
FBIOPAN_DISPLAY=0x4606 FBIOPAN_DISPLAY = 0x4606
FBIOGET_CON2FBMAP=0x460F FBIOGET_CON2FBMAP = 0x460F
FBIOPUT_CON2FBMAP=0x4610 FBIOPUT_CON2FBMAP = 0x4610
FBIOBLANK=0x4611 FBIOBLANK = 0x4611
FBIO_ALLOC=0x4613 FBIO_ALLOC = 0x4613
FBIO_FREE=0x4614 FBIO_FREE = 0x4614
FBIOGET_GLYPH=0x4615 FBIOGET_GLYPH = 0x4615
FBIOGET_HWCINFO=0x4616 FBIOGET_HWCINFO = 0x4616
FBIOPUT_MODEINFO=0x4617 FBIOPUT_MODEINFO = 0x4617
FBIOGET_DISPINFO=0x4618 FBIOGET_DISPINFO = 0x4618
from mmap import mmap from mmap import mmap
from fcntl import ioctl from fcntl import ioctl
import struct import struct
mm = None mm = None
bpp, w, h = 0, 0, 0 # framebuffer bpp and size bpp, w, h = 0, 0, 0 # framebuffer bpp and size
bytepp = 0 bytepp = 0
vx, vy, vw, vh = 0, 0, 0, 0 #virtual window offset and size vx, vy, vw, vh = 0, 0, 0, 0 # virtual window offset and size
vi, fi = None, None vi, fi = None, None
_fb_cmap = 'IIPPPP' # start, len, r, g, b, a _fb_cmap = 'IIPPPP' # start, len, r, g, b, a
RGB = False RGB = False
_verbose = False _verbose = False
msize_kb = 0 msize_kb = 0
def report_fb(i=0, layer=0): def report_fb(i=0, layer=0):
with open('/dev/fb'+str(i), 'r+b')as f: with open('/dev/fb' + str(i), 'r+b') as f:
vi = ioctl(f, FBIOGET_VSCREENINFO, bytes(160)) vi = ioctl(f, FBIOGET_VSCREENINFO, bytes(160))
vi = list(struct.unpack('I'*40, vi)) vi = list(struct.unpack('I' * 40, vi))
ffm = 'c'*16+'L'+'I'*4+'H'*3+'ILIIHHH' ffm = 'c' * 16 + 'L' + 'I' * 4 + 'H' * 3 + 'ILIIHHH'
fic = struct.calcsize(ffm) fic = struct.calcsize(ffm)
fi = struct.unpack(ffm, ioctl(f, FBIOGET_FSCREENINFO, bytes(fic))) fi = struct.unpack(ffm, ioctl(f, FBIOGET_FSCREENINFO, bytes(fic)))
def ready_fb(_bpp=None, i=0, layer=0, _win=None): def ready_fb(_bpp=None, i=0, layer=0, _win=None):
global mm, bpp, w, h, vi, fi, RGB, msize_kb, vx, vy, vw, vh, bytepp global mm, bpp, w, h, vi, fi, RGB, msize_kb, vx, vy, vw, vh, bytepp
if mm and bpp == _bpp: return mm, w, h, bpp if mm and bpp == _bpp:
with open('/dev/fb'+str(i), 'r+b')as f: return mm, w, h, bpp
vi = ioctl(f, FBIOGET_VSCREENINFO, bytes(160)) with open('/dev/fb' + str(i), 'r+b') as f:
vi = list(struct.unpack('I'*40, vi)) vi = ioctl(f, FBIOGET_VSCREENINFO, bytes(160))
bpp = vi[6] vi = list(struct.unpack('I' * 40, vi))
bytepp = bpp//8
if _bpp:
vi[6] = _bpp # 24 bit = BGR 888 mode
try:
vi = ioctl(f, FBIOPUT_VSCREENINFO, struct.pack('I'*40, *vi)) # fb_var_screeninfo
vi = struct.unpack('I'*40,vi)
bpp = vi[6] bpp = vi[6]
bytepp = bpp//8 bytepp = bpp // 8
except: if _bpp:
pass vi[6] = _bpp # 24 bit = BGR 888 mode
try:
vi = ioctl(f, FBIOPUT_VSCREENINFO, struct.pack('I' * 40, *vi)) # fb_var_screeninfo
vi = struct.unpack('I' * 40, vi)
bpp = vi[6]
bytepp = bpp // 8
except:
pass
if vi[8] == 0 : RGB = True if vi[8] == 0:
RGB = True
ffm = 'c'*16+'L'+'I'*4+'H'*3+'ILIIHHH' ffm = 'c' * 16 + 'L' + 'I' * 4 + 'H' * 3 + 'ILIIHHH'
fic = struct.calcsize(ffm) fic = struct.calcsize(ffm)
fi = struct.unpack(ffm, ioctl(f, FBIOGET_FSCREENINFO, bytes(fic))) fi = struct.unpack(ffm, ioctl(f, FBIOGET_FSCREENINFO, bytes(fic)))
msize = fi[17] # = w*h*bpp//8 msize = fi[17] # = w*h*bpp//8
ll, start = fi[-7:-5] ll, start = fi[-7:-5]
w, h = ll//bytepp, vi[1] # when screen is vertical, width becomes wrong. ll//3 is more accurate at such time. w, h = ll // bytepp, vi[1] # when screen is vertical, width becomes wrong. ll//3 is more accurate at such time.
if _win and len(_win)==4: # virtual window settings if _win and len(_win) == 4: # virtual window settings
vx, vy, vw, vh = _win vx, vy, vw, vh = _win
if vw == 'w': vw = w if vw == 'w':
if vh == 'h': vh = h vw = w
vx, vy, vw, vh = map(int, (vx, vy, vw, vh)) if vh == 'h':
if vx>=w: vx = 0 vh = h
if vy>=h: vy = 0 vx, vy, vw, vh = map(int, (vx, vy, vw, vh))
if vx>w: vw = w - vx if vx >= w:
else: vw -= vx vx = 0
if vy>h: vh = h - vy if vy >= h:
else: vh -= vy vy = 0
else: if vx > w:
vx, vy, vw, vh = 0,0,w,h vw = w - vx
msize_kb = vw*vh*bytepp//1024 # more accurate FB memory size in kb else:
vw -= vx
if vy > h:
vh = h - vy
else:
vh -= vy
else:
vx, vy, vw, vh = 0, 0, w, h
msize_kb = vw * vh * bytepp // 1024 # more accurate FB memory size in kb
mm = mmap(f.fileno(), msize, offset=start) mm = mmap(f.fileno(), msize, offset=start)
return mm, w, h, bpp#ll//(bpp//8), h return mm, w, h, bpp # ll//(bpp//8), h
def fill_scr(r, g, b):
if bpp == 32:
seed = struct.pack('BBBB', b, g, r, 255)
elif bpp == 24:
seed = struct.pack('BBB', b, g, r)
elif bpp == 16:
seed = struct.pack('H', r >> 3 << 11 | g >> 2 << 5 | b >> 3)
mm.seek(0)
show_img(seed * vw * vh)
def fill_scr(r,g,b):
if bpp == 32:
seed = struct.pack('BBBB', b, g, r, 255)
elif bpp == 24:
seed = struct.pack('BBB', b, g, r)
elif bpp == 16:
seed = struct.pack('H', r>>3<<11 | g>>2<<5 | b>>3)
mm.seek(0)
show_img(seed * vw * vh)
def black_scr(): def black_scr():
fill_scr(0,0,0) fill_scr(0, 0, 0)
def white_scr(): def white_scr():
fill_scr(255,255,255) fill_scr(255, 255, 255)
def mmseekto(x, y):
mm.seek((x + y * w) * bytepp)
def mmseekto(x,y):
mm.seek((x + y*w) * bytepp)
def dot(x, y, r, g, b): def dot(x, y, r, g, b):
mmseekto(x,y) mmseekto(x, y)
mm.write(struct.pack('BBB',*((r,g,b) if RGB else (b,g,r)))) mm.write(struct.pack('BBB', *((r, g, b) if RGB else (b, g, r))))
def get_pixel(x, y):
mmseekto(x, y)
return mm.read(bytepp)
def get_pixel(x,y):
mmseekto(x,y)
return mm.read(bytepp)
def _888_to_565(bt): def _888_to_565(bt):
b = b'' b = b''
for i in range(0, len(bt),3): for i in range(0, len(bt), 3):
b += int.to_bytes(bt[i]>>3<<11|bt[i+1]>>2<<5|bt[i+2]>>3, 2, 'little') b += int.to_bytes(bt[i] >> 3 << 11 | bt[i + 1] >> 2 << 5 | bt[i + 2] >> 3, 2, 'little')
return b return b
def numpy_888_565(bt): def numpy_888_565(bt):
import numpy as np import numpy as np
arr = np.fromstring(bt, dtype=np.uint32) arr = np.fromstring(bt, dtype=np.uint32)
return (((0xF80000 & arr)>>8)|((0xFC00 & arr)>>5)|((0xF8 & arr)>>3)).astype(np.uint16).tostring() return (((0xF80000 & arr) >> 8) | ((0xFC00 & arr) >> 5) | ((0xF8 & arr) >> 3)).astype(np.uint16).tostring()
def show_img(img): def show_img(img):
if not type(img) is bytes: if not type(img) is bytes:
if not RGB: if not RGB:
if bpp == 24: # for RPI if bpp == 24: # for RPI
img = img.tobytes('raw', 'BGR') img = img.tobytes('raw', 'BGR')
else: else:
img = img.convert('RGBA').tobytes('raw', 'BGRA') img = img.convert('RGBA').tobytes('raw', 'BGRA')
if bpp == 16: if bpp == 16:
img = numpy_888_565(img) img = numpy_888_565(img)
else: else:
if bpp == 24: if bpp == 24:
img = img.tobytes() img = img.tobytes()
else: else:
img = img.convert('RGBA').tobytes() img = img.convert('RGBA').tobytes()
if bpp == 16: if bpp == 16:
img = numpy_888_565(img) img = numpy_888_565(img)
from io import BytesIO from io import BytesIO
b = BytesIO(img) b = BytesIO(img)
s = vw*bytepp s = vw * bytepp
for y in range(vh): # virtual window drawing for y in range(vh): # virtual window drawing
mmseekto(vx,vy+y) mmseekto(vx, vy + y)
mm.write(b.read(s)) mm.write(b.read(s))

View File

@ -90,8 +90,8 @@ ST7789_PWCTR6 = 0xFC
class ST7789(object): class ST7789(object):
"""Representation of an ST7789 TFT LCD.""" """Representation of an ST7789 TFT LCD."""
def __init__(self, port, cs, dc, backlight, rst=None, width=320, def __init__(self, port, cs, dc, backlight=None, rst=None, width=240,
height=240, rotation=0, invert=True, spi_speed_hz=60 * 1000 * 1000, height=240, rotation=90, invert=True, spi_speed_hz=4000000,
offset_left=0, offset_left=0,
offset_top=0): offset_top=0):
"""Create an instance of the display using SPI communication. """Create an instance of the display using SPI communication.

View File

@ -29,7 +29,7 @@
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 960 EPD_WIDTH = 960

View File

@ -29,7 +29,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 80 EPD_WIDTH = 80

View File

@ -80,7 +80,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 200 EPD_WIDTH = 200

View File

@ -28,7 +28,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 200 EPD_WIDTH = 200

View File

@ -28,7 +28,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 200 EPD_WIDTH = 200

View File

@ -28,7 +28,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 200 EPD_WIDTH = 200

View File

@ -27,7 +27,7 @@
# THE SOFTWARE. # THE SOFTWARE.
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 152 EPD_WIDTH = 152

View File

@ -29,11 +29,9 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
import PIL
from PIL import Image from PIL import Image
import io
# Display resolution # Display resolution
EPD_WIDTH = 168 EPD_WIDTH = 168

View File

@ -29,7 +29,7 @@
import logging import logging
from . import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 122 EPD_WIDTH = 122

View File

@ -27,7 +27,7 @@
# THE SOFTWARE. # THE SOFTWARE.
# #
from . import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
# import numpy as np # import numpy as np

View File

@ -40,9 +40,8 @@
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
from PIL import Image from PIL import Image
import RPi.GPIO as GPIO
# Display resolution # Display resolution
EPD_WIDTH = 104 EPD_WIDTH = 104

View File

@ -29,7 +29,7 @@
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 122 EPD_WIDTH = 122

View File

@ -4,8 +4,8 @@
# * | Function : Electronic paper driver # * | Function : Electronic paper driver
# * | Info : # * | Info :
# *---------------- # *----------------
# * | This version: V1.1 # * | This version: V1.2
# * | Date : 2021-10-30 # * | Date : 2022-08-9
# # | Info : python demo # # | Info : python demo
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
@ -29,15 +29,15 @@
import logging import logging
from . import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
import numpy as np
# Display resolution # Display resolution
EPD_WIDTH = 122 EPD_WIDTH = 122
EPD_HEIGHT = 250 EPD_HEIGHT = 250
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class EPD: class EPD:
def __init__(self): def __init__(self):
self.reset_pin = epdconfig.RST_PIN self.reset_pin = epdconfig.RST_PIN
@ -47,54 +47,55 @@ class EPD:
self.width = EPD_WIDTH self.width = EPD_WIDTH
self.height = EPD_HEIGHT self.height = EPD_HEIGHT
lut_partial_update= [ lut_partial_update = [
0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x80, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x40, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x14,0x0,0x0,0x0,0x0,0x0,0x0, 0x14, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x1,0x0,0x0,0x0,0x0,0x0,0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x1,0x0,0x0,0x0,0x0,0x0,0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0,
0x22,0x17,0x41,0x00,0x32,0x36, 0x22, 0x17, 0x41, 0x00, 0x32, 0x36,
] ]
lut_full_update = [ lut_full_update = [
0x80,0x4A,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x80, 0x4A, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40,0x4A,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x40, 0x4A, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x80,0x4A,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x80, 0x4A, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40,0x4A,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x40, 0x4A, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0xF,0x0,0x0,0x0,0x0,0x0,0x0, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0xF,0x0,0x0,0xF,0x0,0x0,0x2, 0xF, 0x0, 0x0, 0xF, 0x0, 0x0, 0x2,
0xF,0x0,0x0,0x0,0x0,0x0,0x0, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x1,0x0,0x0,0x0,0x0,0x0,0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0,
0x22,0x17,0x41,0x0,0x32,0x36, 0x22, 0x17, 0x41, 0x0, 0x32, 0x36,
] ]
''' '''
function :Hardware reset function :Hardware reset
parameter: parameter:
''' '''
def reset(self): def reset(self):
epdconfig.digital_write(self.reset_pin, 1) epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(20) epdconfig.delay_ms(20)
@ -108,6 +109,7 @@ class EPD:
parameter: parameter:
command : Command register command : Command register
''' '''
def send_command(self, command): def send_command(self, command):
epdconfig.digital_write(self.dc_pin, 0) epdconfig.digital_write(self.dc_pin, 0)
epdconfig.digital_write(self.cs_pin, 0) epdconfig.digital_write(self.cs_pin, 0)
@ -119,19 +121,28 @@ class EPD:
parameter: parameter:
data : Write data data : Write data
''' '''
def send_data(self, data): def send_data(self, data):
epdconfig.digital_write(self.dc_pin, 1) epdconfig.digital_write(self.dc_pin, 1)
epdconfig.digital_write(self.cs_pin, 0) epdconfig.digital_write(self.cs_pin, 0)
epdconfig.spi_writebyte([data]) epdconfig.spi_writebyte([data])
epdconfig.digital_write(self.cs_pin, 1) epdconfig.digital_write(self.cs_pin, 1)
# send a lot of data
def send_data2(self, data):
epdconfig.digital_write(self.dc_pin, 1)
epdconfig.digital_write(self.cs_pin, 0)
epdconfig.spi_writebyte2(data)
epdconfig.digital_write(self.cs_pin, 1)
''' '''
function :Wait until the busy_pin goes LOW function :Wait until the busy_pin goes LOW
parameter: parameter:
''' '''
def ReadBusy(self): def ReadBusy(self):
logger.debug("e-Paper busy") logger.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy while (epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy
epdconfig.delay_ms(10) epdconfig.delay_ms(10)
logger.debug("e-Paper busy release") logger.debug("e-Paper busy release")
@ -139,20 +150,22 @@ class EPD:
function : Turn On Display function : Turn On Display
parameter: parameter:
''' '''
def TurnOnDisplay(self): def TurnOnDisplay(self):
self.send_command(0x22) # Display Update Control self.send_command(0x22) # Display Update Control
self.send_data(0xC7) self.send_data(0xC7)
self.send_command(0x20) # Activate Display Update Sequence self.send_command(0x20) # Activate Display Update Sequence
self.ReadBusy() self.ReadBusy()
''' '''
function : Turn On Display Part function : Turn On Display Part
parameter: parameter:
''' '''
def TurnOnDisplayPart(self): def TurnOnDisplayPart(self):
self.send_command(0x22) # Display Update Control self.send_command(0x22) # Display Update Control
self.send_data(0x0f) # fast:0x0c, quality:0x0f, 0xcf self.send_data(0x0f) # fast:0x0c, quality:0x0f, 0xcf
self.send_command(0x20) # Activate Display Update Sequence self.send_command(0x20) # Activate Display Update Sequence
self.ReadBusy() self.ReadBusy()
''' '''
@ -160,6 +173,7 @@ class EPD:
parameter: parameter:
lut : lut data lut : lut data
''' '''
def Lut(self, lut): def Lut(self, lut):
self.send_command(0x32) self.send_command(0x32)
for i in range(0, 153): for i in range(0, 153):
@ -171,17 +185,18 @@ class EPD:
parameter: parameter:
lut : lut data lut : lut data
''' '''
def SetLut(self, lut): def SetLut(self, lut):
self.Lut(lut) self.Lut(lut)
self.send_command(0x3f) self.send_command(0x3f)
self.send_data(lut[153]) self.send_data(lut[153])
self.send_command(0x03) # gate voltage self.send_command(0x03) # gate voltage
self.send_data(lut[154]) self.send_data(lut[154])
self.send_command(0x04) # source voltage self.send_command(0x04) # source voltage
self.send_data(lut[155]) # VSH self.send_data(lut[155]) # VSH
self.send_data(lut[156]) # VSH2 self.send_data(lut[156]) # VSH2
self.send_data(lut[157]) # VSL self.send_data(lut[157]) # VSL
self.send_command(0x2c) # VCOM self.send_command(0x2c) # VCOM
self.send_data(lut[158]) self.send_data(lut[158])
''' '''
@ -192,13 +207,14 @@ class EPD:
xend : End position of X-axis xend : End position of X-axis
yend : End position of Y-axis yend : End position of Y-axis
''' '''
def SetWindow(self, x_start, y_start, x_end, y_end):
self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION
# x point must be the multiple of 8 or the last 3 bits will be ignored
self.send_data((x_start>>3) & 0xFF)
self.send_data((x_end>>3) & 0xFF)
self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION def SetWindow(self, x_start, y_start, x_end, y_end):
self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION
# x point must be the multiple of 8 or the last 3 bits will be ignored
self.send_data((x_start >> 3) & 0xFF)
self.send_data((x_end >> 3) & 0xFF)
self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION
self.send_data(y_start & 0xFF) self.send_data(y_start & 0xFF)
self.send_data((y_start >> 8) & 0xFF) self.send_data((y_start >> 8) & 0xFF)
self.send_data(y_end & 0xFF) self.send_data(y_end & 0xFF)
@ -210,12 +226,13 @@ class EPD:
x : X-axis starting position x : X-axis starting position
y : Y-axis starting position y : Y-axis starting position
''' '''
def SetCursor(self, x, y): def SetCursor(self, x, y):
self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER
# x point must be the multiple of 8 or the last 3 bits will be ignored # x point must be the multiple of 8 or the last 3 bits will be ignored
self.send_data(x & 0xFF) self.send_data(x & 0xFF)
self.send_command(0x4F) # SET_RAM_Y_ADDRESS_COUNTER self.send_command(0x4F) # SET_RAM_Y_ADDRESS_COUNTER
self.send_data(y & 0xFF) self.send_data(y & 0xFF)
self.send_data((y >> 8) & 0xFF) self.send_data((y >> 8) & 0xFF)
@ -223,6 +240,7 @@ class EPD:
function : Initialize the e-Paper register function : Initialize the e-Paper register
parameter: parameter:
''' '''
def init(self): def init(self):
if (epdconfig.module_init() != 0): if (epdconfig.module_init() != 0):
return -1 return -1
@ -230,24 +248,24 @@ class EPD:
self.reset() self.reset()
self.ReadBusy() self.ReadBusy()
self.send_command(0x12) #SWRESET self.send_command(0x12) # SWRESET
self.ReadBusy() self.ReadBusy()
self.send_command(0x01) #Driver output control self.send_command(0x01) # Driver output control
self.send_data(0xf9) self.send_data(0xf9)
self.send_data(0x00) self.send_data(0x00)
self.send_data(0x00) self.send_data(0x00)
self.send_command(0x11) #data entry mode self.send_command(0x11) # data entry mode
self.send_data(0x03) self.send_data(0x03)
self.SetWindow(0, 0, self.width-1, self.height-1) self.SetWindow(0, 0, self.width - 1, self.height - 1)
self.SetCursor(0, 0) self.SetCursor(0, 0)
self.send_command(0x3c) self.send_command(0x3c)
self.send_data(0x05) self.send_data(0x05)
self.send_command(0x21) # Display update control self.send_command(0x21) # Display update control
self.send_data(0x00) self.send_data(0x00)
self.send_data(0x80) self.send_data(0x80)
@ -264,18 +282,19 @@ class EPD:
parameter: parameter:
image : Image data image : Image data
''' '''
def getbuffer(self, image): def getbuffer(self, image):
img = image img = image
imwidth, imheight = img.size imwidth, imheight = img.size
if(imwidth == self.width and imheight == self.height): if (imwidth == self.width and imheight == self.height):
img = img.convert('1') img = img.convert('1')
elif(imwidth == self.height and imheight == self.width): elif (imwidth == self.height and imheight == self.width):
# image has correct dimensions, but needs to be rotated # image has correct dimensions, but needs to be rotated
img = img.rotate(90, expand=True).convert('1') img = img.rotate(90, expand=True).convert('1')
else: else:
logger.warning("Wrong image dimensions: must be " + str(self.width) + "x" + str(self.height)) logger.warning("Wrong image dimensions: must be " + str(self.width) + "x" + str(self.height))
# return a blank buffer # return a blank buffer
return [0x00] * (int(self.width/8) * self.height) return [0x00] * (int(self.width / 8) * self.height)
buf = bytearray(img.tobytes('raw')) buf = bytearray(img.tobytes('raw'))
return buf return buf
@ -285,11 +304,12 @@ class EPD:
parameter: parameter:
image : Image data image : Image data
''' '''
def display(self, image): def display(self, image):
if self.width%8 == 0: if self.width % 8 == 0:
linewidth = int(self.width/8) linewidth = int(self.width / 8)
else: else:
linewidth = int(self.width/8) + 1 linewidth = int(self.width / 8) + 1
self.send_command(0x24) self.send_command(0x24)
for j in range(0, self.height): for j in range(0, self.height):
@ -302,12 +322,8 @@ class EPD:
parameter: parameter:
image : Image data image : Image data
''' '''
def displayPartial(self, image):
if self.width%8 == 0:
linewidth = int(self.width/8)
else:
linewidth = int(self.width/8) + 1
def displayPartial(self, image):
epdconfig.digital_write(self.reset_pin, 0) epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(1) epdconfig.delay_ms(1)
epdconfig.digital_write(self.reset_pin, 1) epdconfig.digital_write(self.reset_pin, 1)
@ -325,7 +341,7 @@ class EPD:
self.send_data(0x00) self.send_data(0x00)
self.send_data(0x00) self.send_data(0x00)
self.send_command(0x3C) #BorderWavefrom self.send_command(0x3C) # BorderWavefrom
self.send_data(0x80) self.send_data(0x80)
self.send_command(0x22) self.send_command(0x22)
@ -336,10 +352,11 @@ class EPD:
self.SetWindow(0, 0, self.width - 1, self.height - 1) self.SetWindow(0, 0, self.width - 1, self.height - 1)
self.SetCursor(0, 0) self.SetCursor(0, 0)
self.send_command(0x24) # WRITE_RAM self.send_command(0x24) # WRITE_RAM
for j in range(0, self.height): # for j in range(0, self.height):
for i in range(0, linewidth): # for i in range(0, linewidth):
self.send_data(image[i + j * linewidth]) # self.send_data(image[i + j * linewidth])
self.send_data2(image)
self.TurnOnDisplayPart() self.TurnOnDisplayPart()
''' '''
@ -347,51 +364,41 @@ class EPD:
parameter: parameter:
image : Image data image : Image data
''' '''
def displayPartBaseImage(self, image):
if self.width%8 == 0:
linewidth = int(self.width/8)
else:
linewidth = int(self.width/8) + 1
def displayPartBaseImage(self, image):
self.send_command(0x24) self.send_command(0x24)
for j in range(0, self.height): self.send_data2(image)
for i in range(0, linewidth):
self.send_data(image[i + j * linewidth])
self.send_command(0x26) self.send_command(0x26)
for j in range(0, self.height): self.send_data2(image)
for i in range(0, linewidth):
self.send_data(image[i + j * linewidth])
self.TurnOnDisplay() self.TurnOnDisplay()
''' '''
function : Clear screen function : Clear screen
parameter: parameter:
''' '''
def Clear(self, color):
if self.width%8 == 0: def Clear(self, color=0xFF):
linewidth = int(self.width/8) if self.width % 8 == 0:
linewidth = int(self.width / 8)
else: else:
linewidth = int(self.width/8) + 1 linewidth = int(self.width / 8) + 1
# logger.debug(linewidth) # logger.debug(linewidth)
self.send_command(0x24) self.send_command(0x24)
for j in range(0, self.height): self.send_data2([color] * int(self.height * linewidth))
for i in range(0, linewidth):
self.send_data(color)
self.TurnOnDisplay() self.TurnOnDisplay()
''' '''
function : Enter sleep mode function : Enter sleep mode
parameter: parameter:
''' '''
def sleep(self): def sleep(self):
self.send_command(0x10) #enter deep sleep self.send_command(0x10) # enter deep sleep
self.send_data(0x01) self.send_data(0x01)
epdconfig.delay_ms(2000) epdconfig.delay_ms(2000)
epdconfig.module_exit() epdconfig.module_exit()
### END OF FILE ### ### END OF FILE ###

View File

@ -29,7 +29,7 @@
import logging import logging
from . import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 122 EPD_WIDTH = 122

View File

@ -28,7 +28,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 104 EPD_WIDTH = 104

View File

@ -28,7 +28,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 122 EPD_WIDTH = 122

View File

@ -28,7 +28,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
from PIL import Image from PIL import Image
# Display resolution # Display resolution

View File

@ -29,9 +29,8 @@
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
from PIL import Image from PIL import Image
import RPi.GPIO as GPIO
# Display resolution # Display resolution
EPD_WIDTH = 104 EPD_WIDTH = 104

View File

@ -29,11 +29,9 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
import PIL
from PIL import Image from PIL import Image
import io
# Display resolution # Display resolution
EPD_WIDTH = 122 EPD_WIDTH = 122

View File

@ -29,11 +29,9 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
import PIL
from PIL import Image from PIL import Image
import io
# Display resolution # Display resolution
EPD_WIDTH = 122 EPD_WIDTH = 122

View File

@ -29,11 +29,9 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
import PIL
from PIL import Image from PIL import Image
import io
# Display resolution # Display resolution
EPD_WIDTH = 168 EPD_WIDTH = 168

View File

@ -28,7 +28,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 152 EPD_WIDTH = 152

View File

@ -28,7 +28,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 152 EPD_WIDTH = 152

View File

@ -29,11 +29,9 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
import PIL
from PIL import Image from PIL import Image
import io
# Display resolution # Display resolution
EPD_WIDTH = 184 EPD_WIDTH = 184

View File

@ -28,7 +28,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 176 EPD_WIDTH = 176

View File

@ -28,7 +28,7 @@
# #
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 176 EPD_WIDTH = 176

View File

@ -29,7 +29,7 @@
import logging import logging
from .. import epdconfig from pwnagotchi.ui.hw.libs.waveshare.epaper import epdconfig
# Display resolution # Display resolution
EPD_WIDTH = 176 EPD_WIDTH = 176

Some files were not shown because too many files have changed in this diff Show More