mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Added 11 waveshare lcd displays
Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
This commit is contained in:
@ -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'
|
||||||
|
|
||||||
|
@ -70,6 +70,17 @@ from pwnagotchi.ui.hw.waveshare7in5b_HD import Waveshare7in5bHD
|
|||||||
from pwnagotchi.ui.hw.waveshare7in5b_V2 import Waveshare7in5bV2
|
from pwnagotchi.ui.hw.waveshare7in5b_V2 import Waveshare7in5bV2
|
||||||
from pwnagotchi.ui.hw.waveshare7in5bc import Waveshare7in5bc
|
from pwnagotchi.ui.hw.waveshare7in5bc import Waveshare7in5bc
|
||||||
from pwnagotchi.ui.hw.waveshare13in3k import Waveshare13in3k
|
from pwnagotchi.ui.hw.waveshare13in3k import Waveshare13in3k
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd0in96 import Wavesharelcd0in96
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd1in3 import Wavesharelcd1in3
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd1in8 import Wavesharelcd1in8
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd1in9 import Wavesharelcd1in9
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd1in14 import Wavesharelcd1in14
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd1in28 import Wavesharelcd1in28
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd1in47 import Wavesharelcd1in47
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd1in54 import Wavesharelcd1in54
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd1in69 import Wavesharelcd1in69
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd2in0 import Wavesharelcd2in0
|
||||||
|
from pwnagotchi.ui.hw.wavesharelcd2in4 import Wavesharelcd2in4
|
||||||
|
|
||||||
|
|
||||||
def display_for(config):
|
def display_for(config):
|
||||||
@ -77,6 +88,39 @@ def display_for(config):
|
|||||||
if config['ui']['display']['type'] == 'inky':
|
if config['ui']['display']['type'] == 'inky':
|
||||||
return Inky(config)
|
return Inky(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd0in96':
|
||||||
|
return Wavesharelcd0in96(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd1in3':
|
||||||
|
return Wavesharelcd1in3(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd1in8':
|
||||||
|
return Wavesharelcd1in8(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd1in9':
|
||||||
|
return Wavesharelcd1in9(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd1in14':
|
||||||
|
return Wavesharelcd1in14(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd1in28':
|
||||||
|
return Wavesharelcd1in28(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd1in47':
|
||||||
|
return Wavesharelcd1in47(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd1in54':
|
||||||
|
return Wavesharelcd1in54(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd1in69':
|
||||||
|
return Wavesharelcd1in69(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd2in0':
|
||||||
|
return Wavesharelcd2in0(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'wavesharelcd2in4':
|
||||||
|
return Wavesharelcd2in4(config)
|
||||||
|
|
||||||
elif config['ui']['display']['type'] == 'dummydisplay':
|
elif config['ui']['display']['type'] == 'dummydisplay':
|
||||||
return DummyDisplay(config)
|
return DummyDisplay(config)
|
||||||
|
|
||||||
|
116
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdconfig.py
Normal file
116
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdconfig.py
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
# /*****************************************************************************
|
||||||
|
# * | File : epdconfig.py
|
||||||
|
# * | Author : Waveshare team
|
||||||
|
# * | Function : Hardware underlying interface
|
||||||
|
# * | Info :
|
||||||
|
# *----------------
|
||||||
|
# * | This version: V1.0
|
||||||
|
# * | Date : 2019-06-21
|
||||||
|
# * | 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 logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import spidev
|
||||||
|
from gpiozero import *
|
||||||
|
|
||||||
|
|
||||||
|
class RaspberryPi:
|
||||||
|
def __init__(self, spi=spidev.SpiDev(0, 0), spi_freq=40000000, rst=27, dc=25, bl=18, bl_freq=1000, i2c=None,
|
||||||
|
i2c_freq=100000):
|
||||||
|
self.np = np
|
||||||
|
self.INPUT = False
|
||||||
|
self.OUTPUT = True
|
||||||
|
|
||||||
|
self.SPEED = spi_freq
|
||||||
|
self.BL_freq = bl_freq
|
||||||
|
|
||||||
|
self.RST_PIN = self.gpio_mode(rst, self.OUTPUT)
|
||||||
|
self.DC_PIN = self.gpio_mode(dc, self.OUTPUT)
|
||||||
|
self.BL_PIN = self.gpio_pwm(bl)
|
||||||
|
self.bl_DutyCycle(0)
|
||||||
|
|
||||||
|
# Initialize SPI
|
||||||
|
self.SPI = spi
|
||||||
|
if self.SPI is not None:
|
||||||
|
self.SPI.max_speed_hz = spi_freq
|
||||||
|
self.SPI.mode = 0b00
|
||||||
|
|
||||||
|
def gpio_mode(self, Pin, Mode, pull_up=None, active_state=True):
|
||||||
|
if Mode:
|
||||||
|
return DigitalOutputDevice(Pin, active_high=True, initial_value=False)
|
||||||
|
else:
|
||||||
|
return DigitalInputDevice(Pin, pull_up=pull_up, active_state=active_state)
|
||||||
|
|
||||||
|
def digital_write(self, Pin, value):
|
||||||
|
if value:
|
||||||
|
Pin.on()
|
||||||
|
else:
|
||||||
|
Pin.off()
|
||||||
|
|
||||||
|
def digital_read(self, Pin):
|
||||||
|
return Pin.value
|
||||||
|
|
||||||
|
def delay_ms(self, delaytime):
|
||||||
|
time.sleep(delaytime / 1000.0)
|
||||||
|
|
||||||
|
def gpio_pwm(self, Pin):
|
||||||
|
return PWMOutputDevice(Pin, frequency=self.BL_freq)
|
||||||
|
|
||||||
|
def spi_writebyte(self, data):
|
||||||
|
if self.SPI != None:
|
||||||
|
self.SPI.writebytes(data)
|
||||||
|
|
||||||
|
def bl_DutyCycle(self, duty):
|
||||||
|
self.BL_PIN.value = duty / 100
|
||||||
|
|
||||||
|
def bl_Frequency(self, freq): # Hz
|
||||||
|
self.BL_PIN.frequency = freq
|
||||||
|
|
||||||
|
def module_init(self):
|
||||||
|
if self.SPI != None:
|
||||||
|
self.SPI.max_speed_hz = self.SPEED
|
||||||
|
self.SPI.mode = 0b00
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def module_exit(self):
|
||||||
|
logging.debug("spi end")
|
||||||
|
if self.SPI != None:
|
||||||
|
self.SPI.close()
|
||||||
|
|
||||||
|
logging.debug("gpio cleanup...")
|
||||||
|
self.digital_write(self.RST_PIN, 1)
|
||||||
|
self.digital_write(self.DC_PIN, 0)
|
||||||
|
self.BL_PIN.close()
|
||||||
|
time.sleep(0.001)
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
if os.path.exists('/sys/bus/platform/drivers/gpiomem-bcm2835'):
|
||||||
|
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 ###
|
180
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat0in96/LCD_0inch96.py
Normal file
180
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat0in96/LCD_0inch96.py
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_0inch96(lcdconfig.RaspberryPi):
|
||||||
|
width = 160
|
||||||
|
height = 80
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def Init(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.command(0x11)
|
||||||
|
time.sleep(0.1)
|
||||||
|
self.command(0x21)
|
||||||
|
self.command(0x21)
|
||||||
|
|
||||||
|
self.command(0xB1)
|
||||||
|
self.data(0x05)
|
||||||
|
self.data(0x3A)
|
||||||
|
self.data(0x3A)
|
||||||
|
|
||||||
|
self.command(0xB2)
|
||||||
|
self.data(0x05)
|
||||||
|
self.data(0x3A)
|
||||||
|
self.data(0x3A)
|
||||||
|
|
||||||
|
self.command(0xB3)
|
||||||
|
self.data(0x05)
|
||||||
|
self.data(0x3A)
|
||||||
|
self.data(0x3A)
|
||||||
|
self.data(0x05)
|
||||||
|
self.data(0x3A)
|
||||||
|
self.data(0x3A)
|
||||||
|
|
||||||
|
self.command(0xB4)
|
||||||
|
self.data(0x03)
|
||||||
|
|
||||||
|
self.command(0xC0)
|
||||||
|
self.data(0x62)
|
||||||
|
self.data(0x02)
|
||||||
|
self.data(0x04)
|
||||||
|
|
||||||
|
self.command(0xC1)
|
||||||
|
self.data(0xC0)
|
||||||
|
|
||||||
|
self.command(0xC2)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0xC3)
|
||||||
|
self.data(0x8D)
|
||||||
|
self.data(0x6A)
|
||||||
|
|
||||||
|
self.command(0xC4)
|
||||||
|
self.data(0x8D)
|
||||||
|
self.data(0xEE)
|
||||||
|
|
||||||
|
self.command(0xC5)
|
||||||
|
self.data(0x0E)
|
||||||
|
|
||||||
|
self.command(0xE0)
|
||||||
|
self.data(0x10)
|
||||||
|
self.data(0x0E)
|
||||||
|
self.data(0x02)
|
||||||
|
self.data(0x03)
|
||||||
|
self.data(0x0E)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x02)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x0A)
|
||||||
|
self.data(0x12)
|
||||||
|
self.data(0x27)
|
||||||
|
self.data(0x37)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x0E)
|
||||||
|
self.data(0x10)
|
||||||
|
|
||||||
|
self.command(0xE1)
|
||||||
|
self.data(0x10)
|
||||||
|
self.data(0x0E)
|
||||||
|
self.data(0x03)
|
||||||
|
self.data(0x03)
|
||||||
|
self.data(0x0F)
|
||||||
|
self.data(0x06)
|
||||||
|
self.data(0x02)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x0A)
|
||||||
|
self.data(0x13)
|
||||||
|
self.data(0x26)
|
||||||
|
self.data(0x36)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x0E)
|
||||||
|
self.data(0x10)
|
||||||
|
|
||||||
|
self.command(0x3A)
|
||||||
|
self.data(0x05)
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0xA8)
|
||||||
|
|
||||||
|
self.command(0x29)
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend):
|
||||||
|
# set the X coordinates
|
||||||
|
Xstart = Xstart + 1
|
||||||
|
Xend = Xend + 1
|
||||||
|
Ystart = Ystart + 26
|
||||||
|
Yend = Yend + 26
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(0x00) # Set the horizontal starting point to the high octet
|
||||||
|
self.data(Xstart & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(0x00) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend - 1) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data((Ystart & 0xff))
|
||||||
|
self.data(0x00)
|
||||||
|
self.data((Yend - 1) & 0xff)
|
||||||
|
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def ShowImage(self, Image):
|
||||||
|
"""Set buffer to value of Python Imaging Library image."""
|
||||||
|
"""Write display buffer to physical display"""
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth != self.width or imheight != self.height:
|
||||||
|
if imwidth != self.height or imheight != self.width:
|
||||||
|
raise ValueError('Image must be same dimensions as display \
|
||||||
|
({0}x{1}).'.format(self.height, self.width))
|
||||||
|
else:
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.width, self.hight, 2), dtype=self.np.uint8)
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8),
|
||||||
|
self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
else:
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.height, self.width, 2), dtype=self.np.uint8)
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
|
||||||
|
for i in range(0, len(pix), 4096): # The length is 160*160*2 Actually 160*80*2 So take 2
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [0xff] * (self.width * self.height)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
151
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in14/LCD_1inch14.py
Normal file
151
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in14/LCD_1inch14.py
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_1inch14(lcdconfig.RaspberryPi):
|
||||||
|
width = 240
|
||||||
|
height = 135
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def Init(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x70) # self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x3A)
|
||||||
|
self.data(0x05)
|
||||||
|
|
||||||
|
self.command(0xB2)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x33)
|
||||||
|
|
||||||
|
self.command(0xB7)
|
||||||
|
self.data(0x35)
|
||||||
|
|
||||||
|
self.command(0xBB)
|
||||||
|
self.data(0x19)
|
||||||
|
|
||||||
|
self.command(0xC0)
|
||||||
|
self.data(0x2C)
|
||||||
|
|
||||||
|
self.command(0xC2)
|
||||||
|
self.data(0x01)
|
||||||
|
|
||||||
|
self.command(0xC3)
|
||||||
|
self.data(0x12)
|
||||||
|
|
||||||
|
self.command(0xC4)
|
||||||
|
self.data(0x20)
|
||||||
|
|
||||||
|
self.command(0xC6)
|
||||||
|
self.data(0x0F)
|
||||||
|
|
||||||
|
self.command(0xD0)
|
||||||
|
self.data(0xA4)
|
||||||
|
self.data(0xA1)
|
||||||
|
|
||||||
|
self.command(0xE0)
|
||||||
|
self.data(0xD0)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x11)
|
||||||
|
self.data(0x13)
|
||||||
|
self.data(0x2B)
|
||||||
|
self.data(0x3F)
|
||||||
|
self.data(0x54)
|
||||||
|
self.data(0x4C)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x0B)
|
||||||
|
self.data(0x1F)
|
||||||
|
self.data(0x23)
|
||||||
|
|
||||||
|
self.command(0xE1)
|
||||||
|
self.data(0xD0)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x11)
|
||||||
|
self.data(0x13)
|
||||||
|
self.data(0x2C)
|
||||||
|
self.data(0x3F)
|
||||||
|
self.data(0x44)
|
||||||
|
self.data(0x51)
|
||||||
|
self.data(0x2F)
|
||||||
|
self.data(0x1F)
|
||||||
|
self.data(0x1F)
|
||||||
|
self.data(0x20)
|
||||||
|
self.data(0x23)
|
||||||
|
|
||||||
|
self.command(0x21)
|
||||||
|
|
||||||
|
self.command(0x11)
|
||||||
|
|
||||||
|
self.command(0x29)
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend):
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data((Xstart + 40) >> 8 & 0xff) # Set the horizontal starting point to the high octet
|
||||||
|
self.data((Xstart + 40) & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data((Xend - 1 + 40) >> 8 & 0xff) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend - 1 + 40) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data((Ystart + 53) >> 8 & 0xff)
|
||||||
|
self.data((Ystart + 53) & 0xff)
|
||||||
|
self.data((Yend - 1 + 53) >> 8 & 0xff)
|
||||||
|
self.data((Yend - 1 + 53) & 0xff)
|
||||||
|
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def ShowImage(self, Image):
|
||||||
|
"""Set buffer to value of Python Imaging Library image."""
|
||||||
|
"""Write display buffer to physical display"""
|
||||||
|
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth != self.width or imheight != self.height:
|
||||||
|
raise ValueError('Image must be same dimensions as display \
|
||||||
|
({0}x{1}).'.format(self.width, self.height))
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.height, self.width, 2), dtype=self.np.uint8)
|
||||||
|
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [0xff] * (self.width * self.height * 2)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
303
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in28/LCD_1inch28.py
Normal file
303
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in28/LCD_1inch28.py
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_1inch28(lcdconfig.RaspberryPi):
|
||||||
|
width = 240
|
||||||
|
height = 240
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def Init(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.command(0xEF)
|
||||||
|
self.command(0xEB)
|
||||||
|
self.data(0x14)
|
||||||
|
|
||||||
|
self.command(0xFE)
|
||||||
|
self.command(0xEF)
|
||||||
|
|
||||||
|
self.command(0xEB)
|
||||||
|
self.data(0x14)
|
||||||
|
|
||||||
|
self.command(0x84)
|
||||||
|
self.data(0x40)
|
||||||
|
|
||||||
|
self.command(0x85)
|
||||||
|
self.data(0xFF)
|
||||||
|
|
||||||
|
self.command(0x86)
|
||||||
|
self.data(0xFF)
|
||||||
|
|
||||||
|
self.command(0x87)
|
||||||
|
self.data(0xFF)
|
||||||
|
|
||||||
|
self.command(0x88)
|
||||||
|
self.data(0x0A)
|
||||||
|
|
||||||
|
self.command(0x89)
|
||||||
|
self.data(0x21)
|
||||||
|
|
||||||
|
self.command(0x8A)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x8B)
|
||||||
|
self.data(0x80)
|
||||||
|
|
||||||
|
self.command(0x8C)
|
||||||
|
self.data(0x01)
|
||||||
|
|
||||||
|
self.command(0x8D)
|
||||||
|
self.data(0x01)
|
||||||
|
|
||||||
|
self.command(0x8E)
|
||||||
|
self.data(0xFF)
|
||||||
|
|
||||||
|
self.command(0x8F)
|
||||||
|
self.data(0xFF)
|
||||||
|
|
||||||
|
self.command(0xB6)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x20)
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x08)
|
||||||
|
|
||||||
|
self.command(0x3A)
|
||||||
|
self.data(0x05)
|
||||||
|
|
||||||
|
self.command(0x90)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x08)
|
||||||
|
|
||||||
|
self.command(0xBD)
|
||||||
|
self.data(0x06)
|
||||||
|
|
||||||
|
self.command(0xBC)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0xFF)
|
||||||
|
self.data(0x60)
|
||||||
|
self.data(0x01)
|
||||||
|
self.data(0x04)
|
||||||
|
|
||||||
|
self.command(0xC3)
|
||||||
|
self.data(0x13)
|
||||||
|
self.command(0xC4)
|
||||||
|
self.data(0x13)
|
||||||
|
|
||||||
|
self.command(0xC9)
|
||||||
|
self.data(0x22)
|
||||||
|
|
||||||
|
self.command(0xBE)
|
||||||
|
self.data(0x11)
|
||||||
|
|
||||||
|
self.command(0xE1)
|
||||||
|
self.data(0x10)
|
||||||
|
self.data(0x0E)
|
||||||
|
|
||||||
|
self.command(0xDF)
|
||||||
|
self.data(0x21)
|
||||||
|
self.data(0x0c)
|
||||||
|
self.data(0x02)
|
||||||
|
|
||||||
|
self.command(0xF0)
|
||||||
|
self.data(0x45)
|
||||||
|
self.data(0x09)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x26)
|
||||||
|
self.data(0x2A)
|
||||||
|
|
||||||
|
self.command(0xF1)
|
||||||
|
self.data(0x43)
|
||||||
|
self.data(0x70)
|
||||||
|
self.data(0x72)
|
||||||
|
self.data(0x36)
|
||||||
|
self.data(0x37)
|
||||||
|
self.data(0x6F)
|
||||||
|
|
||||||
|
self.command(0xF2)
|
||||||
|
self.data(0x45)
|
||||||
|
self.data(0x09)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x26)
|
||||||
|
self.data(0x2A)
|
||||||
|
|
||||||
|
self.command(0xF3)
|
||||||
|
self.data(0x43)
|
||||||
|
self.data(0x70)
|
||||||
|
self.data(0x72)
|
||||||
|
self.data(0x36)
|
||||||
|
self.data(0x37)
|
||||||
|
self.data(0x6F)
|
||||||
|
|
||||||
|
self.command(0xED)
|
||||||
|
self.data(0x1B)
|
||||||
|
self.data(0x0B)
|
||||||
|
|
||||||
|
self.command(0xAE)
|
||||||
|
self.data(0x77)
|
||||||
|
|
||||||
|
self.command(0xCD)
|
||||||
|
self.data(0x63)
|
||||||
|
|
||||||
|
self.command(0x70)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x0E)
|
||||||
|
self.data(0x0F)
|
||||||
|
self.data(0x09)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x03)
|
||||||
|
|
||||||
|
self.command(0xE8)
|
||||||
|
self.data(0x34)
|
||||||
|
|
||||||
|
self.command(0x62)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x71)
|
||||||
|
self.data(0xED)
|
||||||
|
self.data(0x70)
|
||||||
|
self.data(0x70)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x0F)
|
||||||
|
self.data(0x71)
|
||||||
|
self.data(0xEF)
|
||||||
|
self.data(0x70)
|
||||||
|
self.data(0x70)
|
||||||
|
|
||||||
|
self.command(0x63)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x11)
|
||||||
|
self.data(0x71)
|
||||||
|
self.data(0xF1)
|
||||||
|
self.data(0x70)
|
||||||
|
self.data(0x70)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x13)
|
||||||
|
self.data(0x71)
|
||||||
|
self.data(0xF3)
|
||||||
|
self.data(0x70)
|
||||||
|
self.data(0x70)
|
||||||
|
|
||||||
|
self.command(0x64)
|
||||||
|
self.data(0x28)
|
||||||
|
self.data(0x29)
|
||||||
|
self.data(0xF1)
|
||||||
|
self.data(0x01)
|
||||||
|
self.data(0xF1)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x07)
|
||||||
|
|
||||||
|
self.command(0x66)
|
||||||
|
self.data(0x3C)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0xCD)
|
||||||
|
self.data(0x67)
|
||||||
|
self.data(0x45)
|
||||||
|
self.data(0x45)
|
||||||
|
self.data(0x10)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x67)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x3C)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x01)
|
||||||
|
self.data(0x54)
|
||||||
|
self.data(0x10)
|
||||||
|
self.data(0x32)
|
||||||
|
self.data(0x98)
|
||||||
|
|
||||||
|
self.command(0x74)
|
||||||
|
self.data(0x10)
|
||||||
|
self.data(0x85)
|
||||||
|
self.data(0x80)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x4E)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x98)
|
||||||
|
self.data(0x3e)
|
||||||
|
self.data(0x07)
|
||||||
|
|
||||||
|
self.command(0x35)
|
||||||
|
self.command(0x21)
|
||||||
|
|
||||||
|
self.command(0x11)
|
||||||
|
time.sleep(0.12)
|
||||||
|
self.command(0x29)
|
||||||
|
time.sleep(0.02)
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend):
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(0x00) # Set the horizontal starting point to the high octet
|
||||||
|
self.data(Xstart) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(0x00) # Set the horizontal end to the high octet
|
||||||
|
self.data(Xend - 1) # Set the horizontal end to the low octet
|
||||||
|
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(Ystart)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(Yend - 1)
|
||||||
|
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def ShowImage(self, Image):
|
||||||
|
"""Set buffer to value of Python Imaging Library image."""
|
||||||
|
"""Write display buffer to physical display"""
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth != self.width or imheight != self.height:
|
||||||
|
raise ValueError('Image must be same dimensions as display \
|
||||||
|
({0}x{1}).'.format(self.width, self.height))
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.width, self.height, 2), dtype=self.np.uint8)
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [0xff] * (self.width * self.height * 2)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
148
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in3/LCD_1inch3.py
Normal file
148
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in3/LCD_1inch3.py
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_1inch3(lcdconfig.RaspberryPi):
|
||||||
|
width = 240
|
||||||
|
height = 240
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def Init(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x70) # self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x3A)
|
||||||
|
self.data(0x05)
|
||||||
|
|
||||||
|
self.command(0xB2)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x33)
|
||||||
|
|
||||||
|
self.command(0xB7)
|
||||||
|
self.data(0x35)
|
||||||
|
|
||||||
|
self.command(0xBB)
|
||||||
|
self.data(0x19)
|
||||||
|
|
||||||
|
self.command(0xC0)
|
||||||
|
self.data(0x2C)
|
||||||
|
|
||||||
|
self.command(0xC2)
|
||||||
|
self.data(0x01)
|
||||||
|
|
||||||
|
self.command(0xC3)
|
||||||
|
self.data(0x12)
|
||||||
|
|
||||||
|
self.command(0xC4)
|
||||||
|
self.data(0x20)
|
||||||
|
|
||||||
|
self.command(0xC6)
|
||||||
|
self.data(0x0F)
|
||||||
|
|
||||||
|
self.command(0xD0)
|
||||||
|
self.data(0xA4)
|
||||||
|
self.data(0xA1)
|
||||||
|
|
||||||
|
self.command(0xE0)
|
||||||
|
self.data(0xD0)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x11)
|
||||||
|
self.data(0x13)
|
||||||
|
self.data(0x2B)
|
||||||
|
self.data(0x3F)
|
||||||
|
self.data(0x54)
|
||||||
|
self.data(0x4C)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x0B)
|
||||||
|
self.data(0x1F)
|
||||||
|
self.data(0x23)
|
||||||
|
|
||||||
|
self.command(0xE1)
|
||||||
|
self.data(0xD0)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x11)
|
||||||
|
self.data(0x13)
|
||||||
|
self.data(0x2C)
|
||||||
|
self.data(0x3F)
|
||||||
|
self.data(0x44)
|
||||||
|
self.data(0x51)
|
||||||
|
self.data(0x2F)
|
||||||
|
self.data(0x1F)
|
||||||
|
self.data(0x1F)
|
||||||
|
self.data(0x20)
|
||||||
|
self.data(0x23)
|
||||||
|
|
||||||
|
self.command(0x21)
|
||||||
|
|
||||||
|
self.command(0x11)
|
||||||
|
|
||||||
|
self.command(0x29)
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend):
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(0x00) # Set the horizontal starting point to the high octet
|
||||||
|
self.data(Xstart & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(0x00) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend - 1) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data((Ystart & 0xff))
|
||||||
|
self.data(0x00)
|
||||||
|
self.data((Yend - 1) & 0xff)
|
||||||
|
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def ShowImage(self, Image):
|
||||||
|
"""Set buffer to value of Python Imaging Library image."""
|
||||||
|
"""Write display buffer to physical display"""
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth != self.width or imheight != self.height:
|
||||||
|
raise ValueError('Image must be same dimensions as display \
|
||||||
|
({0}x{1}).'.format(self.width, self.height))
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.width, self.height, 2), dtype=self.np.uint8)
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [0xff] * (self.width * self.height * 2)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
152
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in47/LCD_1inch47.py
Normal file
152
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in47/LCD_1inch47.py
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_1inch47(lcdconfig.RaspberryPi):
|
||||||
|
width = 172
|
||||||
|
height = 320
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def Init(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x00) # self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x3A)
|
||||||
|
self.data(0x05)
|
||||||
|
|
||||||
|
self.command(0xB2)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x33)
|
||||||
|
|
||||||
|
self.command(0xB7)
|
||||||
|
self.data(0x35)
|
||||||
|
|
||||||
|
self.command(0xBB)
|
||||||
|
self.data(0x35)
|
||||||
|
|
||||||
|
self.command(0xC0)
|
||||||
|
self.data(0x2C)
|
||||||
|
|
||||||
|
self.command(0xC2)
|
||||||
|
self.data(0x01)
|
||||||
|
|
||||||
|
self.command(0xC3)
|
||||||
|
self.data(0x13)
|
||||||
|
|
||||||
|
self.command(0xC4)
|
||||||
|
self.data(0x20)
|
||||||
|
|
||||||
|
self.command(0xC6)
|
||||||
|
self.data(0x0F)
|
||||||
|
|
||||||
|
self.command(0xD0)
|
||||||
|
self.data(0xA4)
|
||||||
|
self.data(0xA1)
|
||||||
|
|
||||||
|
self.command(0xE0)
|
||||||
|
self.data(0xF0)
|
||||||
|
self.data(0xF0)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x05)
|
||||||
|
self.data(0x29)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x3E)
|
||||||
|
self.data(0x38)
|
||||||
|
self.data(0x12)
|
||||||
|
self.data(0x12)
|
||||||
|
self.data(0x28)
|
||||||
|
self.data(0x30)
|
||||||
|
|
||||||
|
self.command(0xE1)
|
||||||
|
self.data(0xF0)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x0A)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x0B)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x28)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x3E)
|
||||||
|
self.data(0x36)
|
||||||
|
self.data(0x14)
|
||||||
|
self.data(0x14)
|
||||||
|
self.data(0x29)
|
||||||
|
self.data(0x32)
|
||||||
|
|
||||||
|
self.command(0x21)
|
||||||
|
|
||||||
|
self.command(0x11)
|
||||||
|
|
||||||
|
self.command(0x29)
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend):
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data((Xstart) >> 8 & 0xff) # Set the horizontal starting point to the high octet
|
||||||
|
self.data((Xstart + 34) & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data((Xend - 1 + 34) >> 8 & 0xff) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend - 1 + 34) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data((Ystart) >> 8 & 0xff)
|
||||||
|
self.data((Ystart) & 0xff)
|
||||||
|
self.data((Yend - 1) >> 8 & 0xff)
|
||||||
|
self.data((Yend - 1) & 0xff)
|
||||||
|
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def ShowImage(self, Image):
|
||||||
|
"""Set buffer to value of Python Imaging Library image."""
|
||||||
|
"""Write display buffer to physical display"""
|
||||||
|
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth != self.width or imheight != self.height:
|
||||||
|
raise ValueError('Image must be same dimensions as display \
|
||||||
|
({0}x{1}).'.format(self.width, self.height))
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.height, self.width, 2), dtype=self.np.uint8)
|
||||||
|
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [0xff] * (self.width * self.height * 2)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
148
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in54/LCD_1inch54.py
Normal file
148
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in54/LCD_1inch54.py
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_1inch54(lcdconfig.RaspberryPi):
|
||||||
|
width = 240
|
||||||
|
height = 240
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def Init(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x70) # self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x3A)
|
||||||
|
self.data(0x05)
|
||||||
|
|
||||||
|
self.command(0xB2)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x33)
|
||||||
|
|
||||||
|
self.command(0xB7)
|
||||||
|
self.data(0x35)
|
||||||
|
|
||||||
|
self.command(0xBB)
|
||||||
|
self.data(0x19)
|
||||||
|
|
||||||
|
self.command(0xC0)
|
||||||
|
self.data(0x2C)
|
||||||
|
|
||||||
|
self.command(0xC2)
|
||||||
|
self.data(0x01)
|
||||||
|
|
||||||
|
self.command(0xC3)
|
||||||
|
self.data(0x12)
|
||||||
|
|
||||||
|
self.command(0xC4)
|
||||||
|
self.data(0x20)
|
||||||
|
|
||||||
|
self.command(0xC6)
|
||||||
|
self.data(0x0F)
|
||||||
|
|
||||||
|
self.command(0xD0)
|
||||||
|
self.data(0xA4)
|
||||||
|
self.data(0xA1)
|
||||||
|
|
||||||
|
self.command(0xE0)
|
||||||
|
self.data(0xD0)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x11)
|
||||||
|
self.data(0x13)
|
||||||
|
self.data(0x2B)
|
||||||
|
self.data(0x3F)
|
||||||
|
self.data(0x54)
|
||||||
|
self.data(0x4C)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x0D)
|
||||||
|
self.data(0x0B)
|
||||||
|
self.data(0x1F)
|
||||||
|
self.data(0x23)
|
||||||
|
|
||||||
|
self.command(0xE1)
|
||||||
|
self.data(0xD0)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x11)
|
||||||
|
self.data(0x13)
|
||||||
|
self.data(0x2C)
|
||||||
|
self.data(0x3F)
|
||||||
|
self.data(0x44)
|
||||||
|
self.data(0x51)
|
||||||
|
self.data(0x2F)
|
||||||
|
self.data(0x1F)
|
||||||
|
self.data(0x1F)
|
||||||
|
self.data(0x20)
|
||||||
|
self.data(0x23)
|
||||||
|
|
||||||
|
self.command(0x21)
|
||||||
|
|
||||||
|
self.command(0x11)
|
||||||
|
|
||||||
|
self.command(0x29)
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend):
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(0x00) # Set the horizontal starting point to the high octet
|
||||||
|
self.data(Xstart & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(0x00) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend - 1) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data((Ystart & 0xff))
|
||||||
|
self.data(0x00)
|
||||||
|
self.data((Yend - 1) & 0xff)
|
||||||
|
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def ShowImage(self, Image):
|
||||||
|
"""Set buffer to value of Python Imaging Library image."""
|
||||||
|
"""Write display buffer to physical display"""
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth != self.width or imheight != self.height:
|
||||||
|
raise ValueError('Image must be same dimensions as display \
|
||||||
|
({0}x{1}).'.format(self.width, self.height))
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.width, self.height, 2), dtype=self.np.uint8)
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [0xff] * (self.width * self.height * 2)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
190
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in69/LCD_1inch69.py
Normal file
190
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in69/LCD_1inch69.py
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_1inch69(lcdconfig.RaspberryPi):
|
||||||
|
width = 240
|
||||||
|
height = 280
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def Init(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x3A)
|
||||||
|
self.data(0x05)
|
||||||
|
|
||||||
|
self.command(0xB2)
|
||||||
|
self.data(0x0B)
|
||||||
|
self.data(0x0B)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x35)
|
||||||
|
|
||||||
|
self.command(0xB7)
|
||||||
|
self.data(0x11)
|
||||||
|
|
||||||
|
self.command(0xBB)
|
||||||
|
self.data(0x35)
|
||||||
|
|
||||||
|
self.command(0xC0)
|
||||||
|
self.data(0x2C)
|
||||||
|
|
||||||
|
self.command(0xC2)
|
||||||
|
self.data(0x01)
|
||||||
|
|
||||||
|
self.command(0xC3)
|
||||||
|
self.data(0x0D)
|
||||||
|
|
||||||
|
self.command(0xC4)
|
||||||
|
self.data(0x20) # VDV, 0x20: 0V
|
||||||
|
|
||||||
|
self.command(0xC6)
|
||||||
|
self.data(0x13) # 0x13: 60Hz
|
||||||
|
|
||||||
|
self.command(0xD0)
|
||||||
|
self.data(0xA4)
|
||||||
|
self.data(0xA1)
|
||||||
|
|
||||||
|
self.command(0xD6)
|
||||||
|
self.data(0xA1)
|
||||||
|
|
||||||
|
self.command(0xE0)
|
||||||
|
self.data(0xF0)
|
||||||
|
self.data(0x06)
|
||||||
|
self.data(0x0B)
|
||||||
|
self.data(0x0A)
|
||||||
|
self.data(0x09)
|
||||||
|
self.data(0x26)
|
||||||
|
self.data(0x29)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x41)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x16)
|
||||||
|
self.data(0x15)
|
||||||
|
self.data(0x29)
|
||||||
|
self.data(0x2D)
|
||||||
|
|
||||||
|
self.command(0xE1)
|
||||||
|
self.data(0xF0)
|
||||||
|
self.data(0x04)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x03)
|
||||||
|
self.data(0x28)
|
||||||
|
self.data(0x32)
|
||||||
|
self.data(0x40)
|
||||||
|
self.data(0x3B)
|
||||||
|
self.data(0x19)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x2A)
|
||||||
|
self.data(0x2E)
|
||||||
|
|
||||||
|
self.command(0xE4)
|
||||||
|
self.data(0x25)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x21)
|
||||||
|
|
||||||
|
self.command(0x11)
|
||||||
|
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
self.command(0x29)
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend, horizontal=0):
|
||||||
|
if horizontal:
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(Xstart + 20 >> 8) # Set the horizontal starting point to the high octet
|
||||||
|
self.data(Xstart + 20 & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(Xend + 20 - 1 >> 8) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend + 20 - 1) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(Ystart >> 8)
|
||||||
|
self.data((Ystart & 0xff))
|
||||||
|
self.data(Yend - 1 >> 8)
|
||||||
|
self.data((Yend - 1) & 0xff)
|
||||||
|
self.command(0x2C)
|
||||||
|
else:
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(Xstart >> 8) # Set the horizontal starting point to the high octet
|
||||||
|
self.data(Xstart & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(Xend - 1 >> 8) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend - 1) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(Ystart + 20 >> 8)
|
||||||
|
self.data((Ystart + 20 & 0xff))
|
||||||
|
self.data(Yend + 20 - 1 >> 8)
|
||||||
|
self.data((Yend + 20 - 1) & 0xff)
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def ShowImage(self, Image):
|
||||||
|
"""Set buffer to value of Python Imaging Library image."""
|
||||||
|
"""Write display buffer to physical display"""
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth == self.height and imheight == self.width:
|
||||||
|
print("Landscape screen")
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.width, self.height, 2), dtype=self.np.uint8)
|
||||||
|
# RGB888 >> RGB565
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x70)
|
||||||
|
self.SetWindows(0, 0, self.height, self.width, 1)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
else:
|
||||||
|
print("Portrait screen")
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((imheight, imwidth, 2), dtype=self.np.uint8)
|
||||||
|
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x00)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height, 0)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i: i + 4096])
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [0xff] * (self.width * self.height * 2)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i: i + 4096])
|
265
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in8/LCD_1inch8.py
Normal file
265
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in8/LCD_1inch8.py
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
|
||||||
|
LCD_X = 2
|
||||||
|
LCD_Y = 1
|
||||||
|
LCD_X_MAXPIXEL = 128 # LCD width maximum memory
|
||||||
|
LCD_Y_MAXPIXEL = 160 # LCD height maximum memory
|
||||||
|
|
||||||
|
# scanning method
|
||||||
|
L2R_U2D = 1
|
||||||
|
L2R_D2U = 2
|
||||||
|
R2L_U2D = 3
|
||||||
|
R2L_D2U = 4
|
||||||
|
U2D_L2R = 5
|
||||||
|
U2D_R2L = 6
|
||||||
|
D2U_L2R = 7
|
||||||
|
D2U_R2L = 8
|
||||||
|
SCAN_DIR_DFT = U2D_R2L
|
||||||
|
|
||||||
|
LCD_WIDTH = 160
|
||||||
|
LCD_HEIGHT = 128
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_1inch8(lcdconfig.RaspberryPi):
|
||||||
|
LCD_Dis_Column = LCD_WIDTH
|
||||||
|
LCD_Dis_Page = LCD_HEIGHT
|
||||||
|
LCD_Scan_Dir = SCAN_DIR_DFT
|
||||||
|
LCD_X_Adjust = LCD_X
|
||||||
|
LCD_Y_Adjust = LCD_Y
|
||||||
|
width = LCD_WIDTH
|
||||||
|
height = LCD_HEIGHT
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def SetGramScanWay(self, Scan_dir):
|
||||||
|
# Get the screen scan direction
|
||||||
|
self.LCD_Scan_Dir = Scan_dir
|
||||||
|
|
||||||
|
# Get GRAM and LCD width and height
|
||||||
|
if (Scan_dir == L2R_U2D) or (Scan_dir == L2R_D2U) or (Scan_dir == R2L_U2D) or (Scan_dir == R2L_D2U):
|
||||||
|
self.LCD_Dis_Column = LCD_HEIGHT
|
||||||
|
self.LCD_Dis_Page = LCD_WIDTH
|
||||||
|
self.LCD_X_Adjust = LCD_X
|
||||||
|
self.LCD_Y_Adjust = LCD_Y
|
||||||
|
if Scan_dir == L2R_U2D:
|
||||||
|
MemoryAccessReg_Data = 0X00 | 0x00
|
||||||
|
elif Scan_dir == L2R_D2U:
|
||||||
|
MemoryAccessReg_Data = 0X00 | 0x80
|
||||||
|
elif Scan_dir == R2L_U2D:
|
||||||
|
MemoryAccessReg_Data = 0x40 | 0x00
|
||||||
|
else: # R2L_D2U:
|
||||||
|
MemoryAccessReg_Data = 0x40 | 0x80
|
||||||
|
else:
|
||||||
|
self.LCD_Dis_Column = LCD_WIDTH
|
||||||
|
self.LCD_Dis_Page = LCD_HEIGHT
|
||||||
|
self.LCD_X_Adjust = LCD_Y
|
||||||
|
self.LCD_Y_Adjust = LCD_X
|
||||||
|
if Scan_dir == U2D_L2R:
|
||||||
|
MemoryAccessReg_Data = 0X00 | 0x00 | 0x20
|
||||||
|
elif Scan_dir == U2D_R2L:
|
||||||
|
MemoryAccessReg_Data = 0X00 | 0x40 | 0x20
|
||||||
|
elif Scan_dir == D2U_L2R:
|
||||||
|
MemoryAccessReg_Data = 0x80 | 0x00 | 0x20
|
||||||
|
else: # R2L_D2U
|
||||||
|
MemoryAccessReg_Data = 0x40 | 0x80 | 0x20
|
||||||
|
|
||||||
|
# Set the read / write scan direction of the frame memory
|
||||||
|
self.command(0x36) # MX, MY, RGB mode
|
||||||
|
self.data(MemoryAccessReg_Data & 0xf7) # RGB color filter panel
|
||||||
|
|
||||||
|
def Init_reg(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.command(0xB1)
|
||||||
|
self.data(0x01)
|
||||||
|
self.data(0x2C)
|
||||||
|
self.data(0x2D)
|
||||||
|
|
||||||
|
self.command(0xB2)
|
||||||
|
self.data(0x01)
|
||||||
|
self.data(0x2C)
|
||||||
|
self.data(0x2D)
|
||||||
|
|
||||||
|
self.command(0xB3)
|
||||||
|
self.data(0x01)
|
||||||
|
self.data(0x2C)
|
||||||
|
self.data(0x2D)
|
||||||
|
self.data(0x01)
|
||||||
|
self.data(0x2C)
|
||||||
|
self.data(0x2D)
|
||||||
|
|
||||||
|
# Column inversion
|
||||||
|
self.command(0xB4)
|
||||||
|
self.data(0x07)
|
||||||
|
|
||||||
|
# ST7735R Power Sequence
|
||||||
|
self.command(0xC0)
|
||||||
|
self.data(0xA2)
|
||||||
|
self.data(0x02)
|
||||||
|
self.data(0x84)
|
||||||
|
self.command(0xC1)
|
||||||
|
self.data(0xC5)
|
||||||
|
|
||||||
|
self.command(0xC2)
|
||||||
|
self.data(0x0A)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0xC3)
|
||||||
|
self.data(0x8A)
|
||||||
|
self.data(0x2A)
|
||||||
|
self.command(0xC4)
|
||||||
|
self.data(0x8A)
|
||||||
|
self.data(0xEE)
|
||||||
|
|
||||||
|
self.command(0xC5) # VCOM
|
||||||
|
self.data(0x0E)
|
||||||
|
|
||||||
|
# ST7735R Gamma Sequence
|
||||||
|
self.command(0xe0)
|
||||||
|
self.data(0x0f)
|
||||||
|
self.data(0x1a)
|
||||||
|
self.data(0x0f)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x2f)
|
||||||
|
self.data(0x28)
|
||||||
|
self.data(0x20)
|
||||||
|
self.data(0x22)
|
||||||
|
self.data(0x1f)
|
||||||
|
self.data(0x1b)
|
||||||
|
self.data(0x23)
|
||||||
|
self.data(0x37)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x02)
|
||||||
|
self.data(0x10)
|
||||||
|
|
||||||
|
self.command(0xe1)
|
||||||
|
self.data(0x0f)
|
||||||
|
self.data(0x1b)
|
||||||
|
self.data(0x0f)
|
||||||
|
self.data(0x17)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x2c)
|
||||||
|
self.data(0x29)
|
||||||
|
self.data(0x2e)
|
||||||
|
self.data(0x30)
|
||||||
|
self.data(0x30)
|
||||||
|
self.data(0x39)
|
||||||
|
self.data(0x3f)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x03)
|
||||||
|
self.data(0x10)
|
||||||
|
|
||||||
|
# Enable test command
|
||||||
|
self.command(0xF0)
|
||||||
|
self.data(0x01)
|
||||||
|
|
||||||
|
# Disable ram power save mode
|
||||||
|
self.command(0xF6)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
# 65k mode
|
||||||
|
self.command(0x3A)
|
||||||
|
self.data(0x05)
|
||||||
|
|
||||||
|
def Init(self, Lcd_ScanDir=U2D_R2L):
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
# Set the initialization register
|
||||||
|
self.Init_reg()
|
||||||
|
|
||||||
|
# Set the display scan and color transfer modes
|
||||||
|
self.SetGramScanWay(Lcd_ScanDir)
|
||||||
|
self.delay_ms(200)
|
||||||
|
|
||||||
|
# sleep out
|
||||||
|
self.command(0x11)
|
||||||
|
self.delay_ms(120)
|
||||||
|
|
||||||
|
# Turn on the LCD display
|
||||||
|
self.command(0x29)
|
||||||
|
|
||||||
|
self.clear()
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend):
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(0x00) # Set the horizontal starting point to the high octet
|
||||||
|
self.data((Xstart & 0xff) + self.LCD_X_Adjust) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(0x00) # Set the horizontal end to the high octet
|
||||||
|
self.data(((Xend - 1) & 0xff) + self.LCD_X_Adjust) # Set the horizontal end to the low octet
|
||||||
|
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data((Ystart & 0xff) + self.LCD_Y_Adjust)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(((Yend - 1) & 0xff) + self.LCD_Y_Adjust)
|
||||||
|
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def clear(self, color=0XFFFF):
|
||||||
|
_buffer = [color] * (self.LCD_Dis_Column * self.LCD_Dis_Page * 2)
|
||||||
|
if (self.LCD_Scan_Dir == L2R_U2D) or (self.LCD_Scan_Dir == L2R_D2U) or (self.LCD_Scan_Dir == R2L_U2D) or (
|
||||||
|
self.LCD_Scan_Dir == R2L_D2U):
|
||||||
|
# self.LCD_SetArealColor(0,0, LCD_X_MAXPIXEL , LCD_Y_MAXPIXEL , Color = color)#white
|
||||||
|
self.SetWindows(0, 0, LCD_X_MAXPIXEL, LCD_Y_MAXPIXEL)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
||||||
|
|
||||||
|
else:
|
||||||
|
# self.LCD_SetArealColor(0,0, LCD_Y_MAXPIXEL , LCD_X_MAXPIXEL , Color = color)#white
|
||||||
|
self.SetWindows(0, 0, LCD_Y_MAXPIXEL, LCD_X_MAXPIXEL)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
||||||
|
|
||||||
|
def ShowImage(self, Image):
|
||||||
|
if (Image == None):
|
||||||
|
return
|
||||||
|
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth != self.width or imheight != self.height:
|
||||||
|
raise ValueError('Image must be same dimensions as display \
|
||||||
|
({0}x{1}).'.format(self.width, self.height))
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.height, self.width, 2), dtype=self.np.uint8)
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
'''
|
||||||
|
self.SetWindows ( Xstart, Ystart, self.LCD_Dis_Column , self.LCD_Dis_Page )
|
||||||
|
self.digital_write(self.DC_PIN,self.GPIO.HIGH)
|
||||||
|
# Pixels = Image.load()
|
||||||
|
img = np.asarray(Image)
|
||||||
|
pix = np.zeros((Image.height,Image.width, 2), dtype = np.uint8)
|
||||||
|
pix[...,[0]] = np.add(np.bitwise_and(img[...,[0]],0xF8),np.right_shift(img[...,[1]],5))
|
||||||
|
pix[...,[1]] = np.add(np.bitwise_and(np.left_shift(img[...,[1]],3),0xE0), np.right_shift(img[...,[2]],3))
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
self.digital_write(self.DC_PIN,self.GPIO.HIGH)
|
||||||
|
for i in range(0,len(pix),4096):
|
||||||
|
self.spi_writebyte(pix[i:i+4096])
|
||||||
|
'''
|
178
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in9/LCD_1inch9.py
Normal file
178
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat1in9/LCD_1inch9.py
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_1inch9(lcdconfig.RaspberryPi):
|
||||||
|
width = 170
|
||||||
|
height = 320
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def Init(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x3A)
|
||||||
|
self.data(0x55)
|
||||||
|
|
||||||
|
self.command(0xB2)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x33)
|
||||||
|
|
||||||
|
self.command(0xB7)
|
||||||
|
self.data(0x35)
|
||||||
|
|
||||||
|
self.command(0xBB)
|
||||||
|
self.data(0x13)
|
||||||
|
|
||||||
|
self.command(0xC0)
|
||||||
|
self.data(0x2C)
|
||||||
|
|
||||||
|
self.command(0xC2)
|
||||||
|
self.data(0x01)
|
||||||
|
|
||||||
|
self.command(0xC3)
|
||||||
|
self.data(0x0B)
|
||||||
|
|
||||||
|
self.command(0xC4)
|
||||||
|
self.data(0x20)
|
||||||
|
|
||||||
|
self.command(0xC6)
|
||||||
|
self.data(0x0F)
|
||||||
|
|
||||||
|
self.command(0xD0)
|
||||||
|
self.data(0xA4)
|
||||||
|
self.data(0xA1)
|
||||||
|
|
||||||
|
self.command(0xE0)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x03)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x15)
|
||||||
|
self.data(0x2A)
|
||||||
|
self.data(0x44)
|
||||||
|
self.data(0x42)
|
||||||
|
self.data(0x0A)
|
||||||
|
self.data(0x17)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x25)
|
||||||
|
self.data(0x27)
|
||||||
|
|
||||||
|
self.command(0xE1)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x03)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x07)
|
||||||
|
self.data(0x23)
|
||||||
|
self.data(0x2A)
|
||||||
|
self.data(0x43)
|
||||||
|
self.data(0x42)
|
||||||
|
self.data(0x09)
|
||||||
|
self.data(0x18)
|
||||||
|
self.data(0x17)
|
||||||
|
self.data(0x25)
|
||||||
|
self.data(0x27)
|
||||||
|
|
||||||
|
self.command(0x21)
|
||||||
|
|
||||||
|
self.command(0x11)
|
||||||
|
|
||||||
|
self.command(0x29)
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend, horizontal=0):
|
||||||
|
if horizontal:
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(Xstart >> 8) # Set the horizontal starting point to the high octet
|
||||||
|
self.data(Xstart & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(Xend - 1 >> 8) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend - 1) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(Ystart + 35 >> 8)
|
||||||
|
self.data((Ystart + 35 & 0xff))
|
||||||
|
self.data(Yend + 35 - 1 >> 8)
|
||||||
|
self.data((Yend + 35 - 1) & 0xff)
|
||||||
|
self.command(0x2C)
|
||||||
|
else:
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(Xstart + 35 >> 8) # Set the horizontal starting point to the high octet
|
||||||
|
self.data(Xstart + 35 & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(Xend + 35 - 1 >> 8) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend + 35 - 1) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(Ystart >> 8)
|
||||||
|
self.data((Ystart & 0xff))
|
||||||
|
self.data(Yend - 1 >> 8)
|
||||||
|
self.data((Yend - 1) & 0xff)
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def ShowImage(self, Image):
|
||||||
|
"""Set buffer to value of Python Imaging Library image."""
|
||||||
|
"""Write display buffer to physical display"""
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth == self.height and imheight == self.width:
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.width, self.height, 2), dtype=self.np.uint8)
|
||||||
|
# RGB888 >> RGB565
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x70)
|
||||||
|
self.SetWindows(0, 0, self.height, self.width, 1)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
else:
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((imheight, imwidth, 2), dtype=self.np.uint8)
|
||||||
|
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x00)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i: i + 4096])
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [0xff] * (self.width * self.height * 2)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i: i + 4096])
|
180
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat2in0/LCD_2inch.py
Normal file
180
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat2in0/LCD_2inch.py
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_2inch(lcdconfig.RaspberryPi):
|
||||||
|
width = 240
|
||||||
|
height = 320
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def Init(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x00)
|
||||||
|
|
||||||
|
self.command(0x3A)
|
||||||
|
self.data(0x05)
|
||||||
|
|
||||||
|
self.command(0x21)
|
||||||
|
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x01)
|
||||||
|
self.data(0x3F)
|
||||||
|
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0xEF)
|
||||||
|
|
||||||
|
self.command(0xB2)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x00)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x33)
|
||||||
|
|
||||||
|
self.command(0xB7)
|
||||||
|
self.data(0x35)
|
||||||
|
|
||||||
|
self.command(0xBB)
|
||||||
|
self.data(0x1F)
|
||||||
|
|
||||||
|
self.command(0xC0)
|
||||||
|
self.data(0x2C)
|
||||||
|
|
||||||
|
self.command(0xC2)
|
||||||
|
self.data(0x01)
|
||||||
|
|
||||||
|
self.command(0xC3)
|
||||||
|
self.data(0x12)
|
||||||
|
|
||||||
|
self.command(0xC4)
|
||||||
|
self.data(0x20)
|
||||||
|
|
||||||
|
self.command(0xC6)
|
||||||
|
self.data(0x0F)
|
||||||
|
|
||||||
|
self.command(0xD0)
|
||||||
|
self.data(0xA4)
|
||||||
|
self.data(0xA1)
|
||||||
|
|
||||||
|
self.command(0xE0)
|
||||||
|
self.data(0xD0)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x11)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x0C)
|
||||||
|
self.data(0x15)
|
||||||
|
self.data(0x39)
|
||||||
|
self.data(0x33)
|
||||||
|
self.data(0x50)
|
||||||
|
self.data(0x36)
|
||||||
|
self.data(0x13)
|
||||||
|
self.data(0x14)
|
||||||
|
self.data(0x29)
|
||||||
|
self.data(0x2D)
|
||||||
|
|
||||||
|
self.command(0xE1)
|
||||||
|
self.data(0xD0)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x10)
|
||||||
|
self.data(0x08)
|
||||||
|
self.data(0x06)
|
||||||
|
self.data(0x06)
|
||||||
|
self.data(0x39)
|
||||||
|
self.data(0x44)
|
||||||
|
self.data(0x51)
|
||||||
|
self.data(0x0B)
|
||||||
|
self.data(0x16)
|
||||||
|
self.data(0x14)
|
||||||
|
self.data(0x2F)
|
||||||
|
self.data(0x31)
|
||||||
|
self.command(0x21)
|
||||||
|
|
||||||
|
self.command(0x11)
|
||||||
|
|
||||||
|
self.command(0x29)
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend):
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(Xstart >> 8) # Set the horizontal starting point to the high octet
|
||||||
|
self.data(Xstart & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(Xend >> 8) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend - 1) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(Ystart >> 8)
|
||||||
|
self.data((Ystart & 0xff))
|
||||||
|
self.data(Yend >> 8)
|
||||||
|
self.data((Yend - 1) & 0xff)
|
||||||
|
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def ShowImage(self, Image, Xstart=0, Ystart=0):
|
||||||
|
"""Set buffer to value of Python Imaging Library image."""
|
||||||
|
"""Write display buffer to physical display"""
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth == self.height and imheight == self.width:
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((self.width, self.height, 2), dtype=self.np.uint8)
|
||||||
|
# RGB888 >> RGB565
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x70)
|
||||||
|
self.SetWindows(0, 0, self.height, self.width)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
|
||||||
|
else:
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((imheight, imwidth, 2), dtype=self.np.uint8)
|
||||||
|
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x00)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [0xff] * (self.width * self.height * 2)
|
||||||
|
self.SetWindows(0, 0, self.height, self.width)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
187
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat2in4/LCD_2inch4.py
Normal file
187
pwnagotchi/ui/hw/libs/waveshare/lcd/lcdhat2in4/LCD_2inch4.py
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
import time
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd import lcdconfig
|
||||||
|
import numbers
|
||||||
|
|
||||||
|
|
||||||
|
class LCD_2inch4(lcdconfig.RaspberryPi):
|
||||||
|
width = 240
|
||||||
|
height = 320
|
||||||
|
|
||||||
|
def command(self, cmd):
|
||||||
|
self.digital_write(self.DC_PIN, False)
|
||||||
|
self.spi_writebyte([cmd])
|
||||||
|
|
||||||
|
def data(self, val):
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
self.spi_writebyte([val])
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""Reset the display"""
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, False)
|
||||||
|
time.sleep(0.01)
|
||||||
|
self.digital_write(self.RST_PIN, True)
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
def Init(self):
|
||||||
|
"""Initialize dispaly"""
|
||||||
|
self.module_init()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.command(0x11) # '''Sleep out'''
|
||||||
|
self.command(0xCF) #
|
||||||
|
self.data(0x00) #
|
||||||
|
self.data(0xC1) #
|
||||||
|
self.data(0X30) #
|
||||||
|
self.command(0xED) #
|
||||||
|
self.data(0x64) #
|
||||||
|
self.data(0x03) #
|
||||||
|
self.data(0X12) #
|
||||||
|
self.data(0X81) #
|
||||||
|
self.command(0xE8) #
|
||||||
|
self.data(0x85) #
|
||||||
|
self.data(0x00) #
|
||||||
|
self.data(0x79) #
|
||||||
|
self.command(0xCB) #
|
||||||
|
self.data(0x39) #
|
||||||
|
self.data(0x2C) #
|
||||||
|
self.data(0x00) #
|
||||||
|
self.data(0x34) #
|
||||||
|
self.data(0x02) #
|
||||||
|
self.command(0xF7) #
|
||||||
|
self.data(0x20) #
|
||||||
|
self.command(0xEA) #
|
||||||
|
self.data(0x00) #
|
||||||
|
self.data(0x00) #
|
||||||
|
self.command(0xC0) # '''Power control'''
|
||||||
|
self.data(0x1D) # '''VRH[5:0]'''
|
||||||
|
self.command(0xC1) # '''Power control'''
|
||||||
|
self.data(0x12) # '''SAP[2:0]#BT[3:0]'''
|
||||||
|
self.command(0xC5) # '''VCM control'''
|
||||||
|
self.data(0x33) #
|
||||||
|
self.data(0x3F) #
|
||||||
|
self.command(0xC7) # '''VCM control'''
|
||||||
|
self.data(0x92) #
|
||||||
|
self.command(0x3A) # '''Memory Access Control'''
|
||||||
|
self.data(0x55) #
|
||||||
|
self.command(0x36) # '''Memory Access Control'''
|
||||||
|
self.data(0x08) #
|
||||||
|
self.command(0xB1) #
|
||||||
|
self.data(0x00) #
|
||||||
|
self.data(0x12) #
|
||||||
|
self.command(0xB6) # '''Display Function Control'''
|
||||||
|
self.data(0x0A) #
|
||||||
|
self.data(0xA2) #
|
||||||
|
|
||||||
|
self.command(0x44) #
|
||||||
|
self.data(0x02) #
|
||||||
|
|
||||||
|
self.command(0xF2) # '''3Gamma Function Disable'''
|
||||||
|
self.data(0x00) #
|
||||||
|
self.command(0x26) # '''Gamma curve selected'''
|
||||||
|
self.data(0x01) #
|
||||||
|
self.command(0xE0) # '''Set Gamma'''
|
||||||
|
self.data(0x0F) #
|
||||||
|
self.data(0x22) #
|
||||||
|
self.data(0x1C) #
|
||||||
|
self.data(0x1B) #
|
||||||
|
self.data(0x08) #
|
||||||
|
self.data(0x0F) #
|
||||||
|
self.data(0x48) #
|
||||||
|
self.data(0xB8) #
|
||||||
|
self.data(0x34) #
|
||||||
|
self.data(0x05) #
|
||||||
|
self.data(0x0C) #
|
||||||
|
self.data(0x09) #
|
||||||
|
self.data(0x0F) #
|
||||||
|
self.data(0x07) #
|
||||||
|
self.data(0x00) #
|
||||||
|
self.command(0XE1) # '''Set Gamma'''
|
||||||
|
self.data(0x00) #
|
||||||
|
self.data(0x23) #
|
||||||
|
self.data(0x24) #
|
||||||
|
self.data(0x07) #
|
||||||
|
self.data(0x10) #
|
||||||
|
self.data(0x07) #
|
||||||
|
self.data(0x38) #
|
||||||
|
self.data(0x47) #
|
||||||
|
self.data(0x4B) #
|
||||||
|
self.data(0x0A) #
|
||||||
|
self.data(0x13) #
|
||||||
|
self.data(0x06) #
|
||||||
|
self.data(0x30) #
|
||||||
|
self.data(0x38) #
|
||||||
|
self.data(0x0F) #
|
||||||
|
self.command(0x29) # '''Display on'''
|
||||||
|
|
||||||
|
def SetWindows(self, Xstart, Ystart, Xend, Yend):
|
||||||
|
# set the X coordinates
|
||||||
|
self.command(0x2A)
|
||||||
|
self.data(Xstart >> 8) # Set the horizontal starting point to the high octet
|
||||||
|
self.data(Xstart & 0xff) # Set the horizontal starting point to the low octet
|
||||||
|
self.data(Xend >> 8) # Set the horizontal end to the high octet
|
||||||
|
self.data((Xend - 1) & 0xff) # Set the horizontal end to the low octet
|
||||||
|
# set the Y coordinates
|
||||||
|
self.command(0x2B)
|
||||||
|
self.data(Ystart >> 8)
|
||||||
|
self.data((Ystart & 0xff))
|
||||||
|
self.data(Yend >> 8)
|
||||||
|
self.data((Yend - 1) & 0xff)
|
||||||
|
|
||||||
|
self.command(0x2C)
|
||||||
|
|
||||||
|
def ShowImage(self, Image, Xstart=0, Ystart=0):
|
||||||
|
"""Set buffer to value of Python Imaging Library image."""
|
||||||
|
"""Write display buffer to physical display"""
|
||||||
|
imwidth, imheight = Image.size
|
||||||
|
if imwidth == self.height and imheight == self.width:
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((imheight, imwidth, 2), dtype=self.np.uint8)
|
||||||
|
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x78)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
|
||||||
|
else:
|
||||||
|
img = self.np.asarray(Image)
|
||||||
|
pix = self.np.zeros((imheight, imwidth, 2), dtype=self.np.uint8)
|
||||||
|
|
||||||
|
pix[..., [0]] = self.np.add(self.np.bitwise_and(img[..., [0]], 0xF8), self.np.right_shift(img[..., [1]], 5))
|
||||||
|
pix[..., [1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[..., [1]], 3), 0xE0),
|
||||||
|
self.np.right_shift(img[..., [2]], 3))
|
||||||
|
|
||||||
|
pix = pix.flatten().tolist()
|
||||||
|
self.command(0x36)
|
||||||
|
self.data(0x08)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(pix), 4096):
|
||||||
|
self.spi_writebyte(pix[i:i + 4096])
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [0xff] * (self.width * self.height * 2)
|
||||||
|
time.sleep(0.02)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
||||||
|
|
||||||
|
def clear_color(self, color):
|
||||||
|
"""Clear contents of image buffer"""
|
||||||
|
_buffer = [color >> 8, color & 0xff] * (self.width * self.height)
|
||||||
|
time.sleep(0.02)
|
||||||
|
self.SetWindows(0, 0, self.width, self.height)
|
||||||
|
self.digital_write(self.DC_PIN, True)
|
||||||
|
for i in range(0, len(_buffer), 4096):
|
||||||
|
self.spi_writebyte(_buffer[i:i + 4096])
|
45
pwnagotchi/ui/hw/wavesharelcd0in96.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd0in96.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd0in96(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd0in96, self).__init__(config, 'wavesharelcd0in96')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 160
|
||||||
|
self._layout['height'] = 80
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 80, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 80, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 0.96 inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat0in96.LCD_0inch96 import LCD_0inch96
|
||||||
|
self._display = LCD_0inch96()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
45
pwnagotchi/ui/hw/wavesharelcd1in14.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd1in14.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd1in14(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd1in14, self).__init__(config, 'wavesharelcd1in14')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 240
|
||||||
|
self._layout['height'] = 135
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 168, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 168, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 1.14 inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat1in14.LCD_1inch14 import LCD_1inch14
|
||||||
|
self._display = LCD_1inch14()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
45
pwnagotchi/ui/hw/wavesharelcd1in28.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd1in28.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd1in28(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd1in28, self).__init__(config, 'wavesharelcd1in28')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 240
|
||||||
|
self._layout['height'] = 240
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 168, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 168, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 1.28 inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat1in28.LCD_1inch28 import LCD_1inch28
|
||||||
|
self._display = LCD_1inch28()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
45
pwnagotchi/ui/hw/wavesharelcd1in3.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd1in3.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd1in3(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd1in3, self).__init__(config, 'wavesharelcd1in3')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 240
|
||||||
|
self._layout['height'] = 240
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 168, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 168, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 1.3 inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat1in3.LCD_1inch3 import LCD_1inch3
|
||||||
|
self._display = LCD_1inch3()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
45
pwnagotchi/ui/hw/wavesharelcd1in47.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd1in47.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd1in47(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd1in47, self).__init__(config, 'wavesharelcd1in47')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 172
|
||||||
|
self._layout['height'] = 320
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 168, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 168, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 1.47 inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat1in47.LCD_1inch47 import LCD_1inch47
|
||||||
|
self._display = LCD_1inch47()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
45
pwnagotchi/ui/hw/wavesharelcd1in54.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd1in54.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd1in54(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd1in54, self).__init__(config, 'wavesharelcd1in54')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 240
|
||||||
|
self._layout['height'] = 240
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 168, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 168, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 1.54 inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat1in54.LCD_1inch54 import LCD_1inch54
|
||||||
|
self._display = LCD_1inch54()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
45
pwnagotchi/ui/hw/wavesharelcd1in69.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd1in69.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd1in69(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd1in69, self).__init__(config, 'wavesharelcd1in69')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 240
|
||||||
|
self._layout['height'] = 280
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 168, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 168, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 1.69 inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat1in69.LCD_1inch69 import LCD_1inch69
|
||||||
|
self._display = LCD_1inch69()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
45
pwnagotchi/ui/hw/wavesharelcd1in8.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd1in8.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd1in8(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd1in8, self).__init__(config, 'wavesharelcd1in8')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 160
|
||||||
|
self._layout['height'] = 128
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 168, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 168, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 1.8 inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat1in8.LCD_1inch8 import LCD_1inch8
|
||||||
|
self._display = LCD_1inch8()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
45
pwnagotchi/ui/hw/wavesharelcd1in9.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd1in9.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd1in9(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd1in9, self).__init__(config, 'wavesharelcd1in9')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 170
|
||||||
|
self._layout['height'] = 320
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 168, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 168, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 1.9 inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat1in9.LCD_1inch9 import LCD_1inch9
|
||||||
|
self._display = LCD_1inch9()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
45
pwnagotchi/ui/hw/wavesharelcd2in0.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd2in0.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd2in0(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd2in0, self).__init__(config, 'wavesharelcd2in0')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 240
|
||||||
|
self._layout['height'] = 320
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 168, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 168, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 2.0 inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat2in0.LCD_2inch import LCD_2inch
|
||||||
|
self._display = LCD_2inch()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
45
pwnagotchi/ui/hw/wavesharelcd2in4.py
Normal file
45
pwnagotchi/ui/hw/wavesharelcd2in4.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class Wavesharelcd2in4(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(Wavesharelcd2in4, self).__init__(config, 'wavesharelcd2in4')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
fonts.setup(10, 8, 10, 18, 25, 9)
|
||||||
|
self._layout['width'] = 240
|
||||||
|
self._layout['height'] = 320
|
||||||
|
self._layout['face'] = (0, 43)
|
||||||
|
self._layout['name'] = (0, 14)
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (0, 71)
|
||||||
|
self._layout['uptime'] = (0, 25)
|
||||||
|
self._layout['line1'] = [0, 12, 168, 12]
|
||||||
|
self._layout['line2'] = [0, 116, 168, 116]
|
||||||
|
self._layout['friend_face'] = (12, 88)
|
||||||
|
self._layout['friend_name'] = (1, 103)
|
||||||
|
self._layout['shakes'] = (26, 117)
|
||||||
|
self._layout['mode'] = (0, 117)
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (65, 26),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': 12
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
logging.info("initializing waveshare 2.4inch lcd display")
|
||||||
|
from pwnagotchi.ui.hw.libs.waveshare.lcd.lcdhat2in4.LCD_2inch4 import LCD_2inch4
|
||||||
|
self._display = LCD_2inch4()
|
||||||
|
self._display.Init()
|
||||||
|
self._display.clear()
|
||||||
|
self._display.bl_DutyCycle(50)
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
self._display.ShowImage(canvas)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._display.clear()
|
@ -243,6 +243,39 @@ def load_config(args):
|
|||||||
config['ui']['display']['type'] = 'dummydisplay'
|
config['ui']['display']['type'] = 'dummydisplay'
|
||||||
|
|
||||||
# NON E-INK DISPLAYS---------------------------------------------------------------
|
# NON E-INK DISPLAYS---------------------------------------------------------------
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd0in96', 'wslcd0in96'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd0in96'
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd1in3', 'wslcd1in3'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd1in3'
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd1in8', 'wslcd1in8'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd1in8'
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd1in9', 'wslcd1in9'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd1in9'
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd1in14', 'wslcd1in14'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd1in14'
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd1in28', 'wslcd1in28'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd1in28'
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd1in47', 'wslcd1in47'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd1in47'
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd1in54', 'wslcd1in54'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd1in54'
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd1in69', 'wslcd1in69'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd1in69'
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd2in0', 'wslcd2in0'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd2in0'
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] in ('wavesharelcd2in4', 'wslcd2in4'):
|
||||||
|
config['ui']['display']['type'] = 'wavesharelcd2in4'
|
||||||
|
|
||||||
elif config['ui']['display']['type'] in ('inky', 'inkyphat'):
|
elif config['ui']['display']['type'] in ('inky', 'inkyphat'):
|
||||||
config['ui']['display']['type'] = 'inky'
|
config['ui']['display']['type'] = 'inky'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user