mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
@ -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"
|
||||||
|
@ -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
|
||||||
|
@ -29,6 +29,7 @@ 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))
|
||||||
@ -37,9 +38,11 @@ def report_fb(i=0, layer=0):
|
|||||||
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:
|
||||||
|
return mm, w, h, bpp
|
||||||
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))
|
||||||
@ -55,7 +58,8 @@ def ready_fb(_bpp=None, i=0, layer=0, _win=None):
|
|||||||
except:
|
except:
|
||||||
pass
|
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)
|
||||||
@ -65,15 +69,23 @@ def ready_fb(_bpp=None, i=0, layer=0, _win=None):
|
|||||||
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
|
||||||
|
if vh == 'h':
|
||||||
|
vh = h
|
||||||
vx, vy, vw, vh = map(int, (vx, vy, vw, vh))
|
vx, vy, vw, vh = map(int, (vx, vy, vw, vh))
|
||||||
if vx>=w: vx = 0
|
if vx >= w:
|
||||||
if vy>=h: vy = 0
|
vx = 0
|
||||||
if vx>w: vw = w - vx
|
if vy >= h:
|
||||||
else: vw -= vx
|
vy = 0
|
||||||
if vy>h: vh = h - vy
|
if vx > w:
|
||||||
else: vh -= vy
|
vw = w - vx
|
||||||
|
else:
|
||||||
|
vw -= vx
|
||||||
|
if vy > h:
|
||||||
|
vh = h - vy
|
||||||
|
else:
|
||||||
|
vh -= vy
|
||||||
else:
|
else:
|
||||||
vx, vy, vw, vh = 0, 0, w, h
|
vx, vy, vw, vh = 0, 0, w, h
|
||||||
msize_kb = vw * vh * bytepp // 1024 # more accurate FB memory size in kb
|
msize_kb = vw * vh * bytepp // 1024 # more accurate FB memory size in kb
|
||||||
@ -81,6 +93,7 @@ def ready_fb(_bpp=None, i=0, layer=0, _win=None):
|
|||||||
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):
|
def fill_scr(r, g, b):
|
||||||
if bpp == 32:
|
if bpp == 32:
|
||||||
seed = struct.pack('BBBB', b, g, r, 255)
|
seed = struct.pack('BBBB', b, g, r, 255)
|
||||||
@ -91,34 +104,42 @@ def fill_scr(r,g,b):
|
|||||||
mm.seek(0)
|
mm.seek(0)
|
||||||
show_img(seed * vw * vh)
|
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):
|
def mmseekto(x, y):
|
||||||
mm.seek((x + y * w) * bytepp)
|
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):
|
def get_pixel(x, y):
|
||||||
mmseekto(x, y)
|
mmseekto(x, y)
|
||||||
return mm.read(bytepp)
|
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:
|
||||||
@ -141,4 +162,3 @@ def show_img(img):
|
|||||||
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))
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import logging
|
|||||||
import pwnagotchi.ui.fonts as fonts
|
import pwnagotchi.ui.fonts as fonts
|
||||||
from pwnagotchi.ui.hw.base import DisplayImpl
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
import os,time
|
|
||||||
|
|
||||||
class Pitft(DisplayImpl):
|
class Pitft(DisplayImpl):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
|
@ -238,13 +238,14 @@ def load_config(args):
|
|||||||
config = merge_config(additional_config, config)
|
config = merge_config(additional_config, config)
|
||||||
|
|
||||||
# the very first step is to normalize the display name, so we don't need dozens of if/elif around
|
# the very first step is to normalize the display name, so we don't need dozens of if/elif around
|
||||||
# NON E-INK DISPLAYS---------------------------------------------------------------
|
# Dummy Display -------------------------------------------------------------------
|
||||||
if config['ui']['display']['type'] in ('inky', 'inkyphat'):
|
if config['ui']['display']['type'] in ('dummy', 'dummydisplay'):
|
||||||
config['ui']['display']['type'] = 'inky'
|
|
||||||
|
|
||||||
elif config['ui']['display']['type'] in ('dummy', 'dummydisplay'):
|
|
||||||
config['ui']['display']['type'] = 'dummydisplay'
|
config['ui']['display']['type'] = 'dummydisplay'
|
||||||
|
|
||||||
|
# NON E-INK DISPLAYS---------------------------------------------------------------
|
||||||
|
elif config['ui']['display']['type'] in ('inky', 'inkyphat'):
|
||||||
|
config['ui']['display']['type'] = 'inky'
|
||||||
|
|
||||||
elif config['ui']['display']['type'] in ('papirus', 'papi'):
|
elif config['ui']['display']['type'] in ('papirus', 'papi'):
|
||||||
config['ui']['display']['type'] = 'papirus'
|
config['ui']['display']['type'] = 'papirus'
|
||||||
|
|
||||||
@ -288,7 +289,7 @@ def load_config(args):
|
|||||||
|
|
||||||
# Adafruit
|
# Adafruit
|
||||||
|
|
||||||
elif config['ui']['display']['type'] in ('adafruit2in13v3', 'af213v3', 'adafruit_213v3', 'adafruit213inv3'):
|
elif config['ui']['display']['type'] in ('adafruit2in13_v3', 'adafruit2in13v3', 'af213v3', 'adafruit_213v3', 'adafruit213inv3'):
|
||||||
config['ui']['display']['type'] = 'adafruit2in13_v3'
|
config['ui']['display']['type'] = 'adafruit2in13_v3'
|
||||||
|
|
||||||
# Waveshare
|
# Waveshare
|
||||||
|
Reference in New Issue
Block a user