Compare commits
22 Commits
1d9bf8e22e
...
main
Author | SHA1 | Date | |
---|---|---|---|
26f7ce419b | |||
680026cb54 | |||
4beba1ab24 | |||
a16d472028 | |||
1605920d65 | |||
08d0e70e26 | |||
c5caa109cd | |||
|
8376e26f9c | ||
|
97976242cb | ||
|
5fdcd5f1a1 | ||
|
f62ca7abf5 | ||
|
d2884df7e2 | ||
|
e5bd164c4e | ||
|
b0f220d655 | ||
|
f4fee0e31f | ||
|
5b8503fcc9 | ||
|
38b8f06046 | ||
|
f9a932591d | ||
|
5c68b02e09 | ||
|
db5e279fda | ||
|
2bfe09e54b | ||
|
b2a8dc126c |
3
.github/workflows/update-os.yml
vendored
3
.github/workflows/update-os.yml
vendored
@@ -24,7 +24,8 @@ jobs:
|
|||||||
TINDIE_USERNAME: ${{ secrets.TINDIE_USERNAME }}
|
TINDIE_USERNAME: ${{ secrets.TINDIE_USERNAME }}
|
||||||
with:
|
with:
|
||||||
# Set the base_image to the desired Raspberry Pi OS version
|
# Set the base_image to the desired Raspberry Pi OS version
|
||||||
base_image: https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2023-12-11/2023-12-11-raspios-bookworm-armhf-lite.img.xz
|
# note: version 2023-12-11 seems to have issues with the kernel and gpio
|
||||||
|
base_image: https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2023-05-03/2023-05-03-raspios-bullseye-armhf-lite.img.xz
|
||||||
image_additional_mb: 3072 # enlarge free space to 3 GB
|
image_additional_mb: 3072 # enlarge free space to 3 GB
|
||||||
optimize_image: true
|
optimize_image: true
|
||||||
commands: |
|
commands: |
|
||||||
|
@@ -98,8 +98,7 @@ display!**
|
|||||||
|
|
||||||
## Configuring the Raspberry Pi
|
## Configuring the Raspberry Pi
|
||||||
|
|
||||||
Flash Raspberry Pi OS on your microSD card (min. 4GB) with [Raspberry Pi Imager](https://rptl.io/imager).
|
Flash Raspberry Pi OS on your microSD card (min. 4GB) with [Raspberry Pi Imager](https://rptl.io/imager). Please use this version of [Raspberry Pi OS - bookworm](https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2023-05-03/2023-05-03-raspios-bullseye-armhf-lite.img.xz) as the latest release is known to have some issues with the latest kernel update.
|
||||||
Use the following settings:
|
|
||||||
|
|
||||||
| option | value |
|
| option | value |
|
||||||
|:--------------------------|:---------------------------:|
|
|:--------------------------|:---------------------------:|
|
||||||
|
7
docs/_static/searchtools.js
vendored
7
docs/_static/searchtools.js
vendored
@@ -178,7 +178,7 @@ const Search = {
|
|||||||
|
|
||||||
htmlToText: (htmlString, anchor) => {
|
htmlToText: (htmlString, anchor) => {
|
||||||
const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html');
|
const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html');
|
||||||
for (const removalQuery of [".headerlinks", "script", "style"]) {
|
for (const removalQuery of [".headerlink", "script", "style"]) {
|
||||||
htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() });
|
htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() });
|
||||||
}
|
}
|
||||||
if (anchor) {
|
if (anchor) {
|
||||||
@@ -328,13 +328,14 @@ const Search = {
|
|||||||
for (const [title, foundTitles] of Object.entries(allTitles)) {
|
for (const [title, foundTitles] of Object.entries(allTitles)) {
|
||||||
if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) {
|
if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) {
|
||||||
for (const [file, id] of foundTitles) {
|
for (const [file, id] of foundTitles) {
|
||||||
let score = Math.round(100 * queryLower.length / title.length)
|
const score = Math.round(Scorer.title * queryLower.length / title.length);
|
||||||
|
const boost = titles[file] === title ? 1 : 0; // add a boost for document titles
|
||||||
normalResults.push([
|
normalResults.push([
|
||||||
docNames[file],
|
docNames[file],
|
||||||
titles[file] !== title ? `${titles[file]} > ${title}` : title,
|
titles[file] !== title ? `${titles[file]} > ${title}` : title,
|
||||||
id !== null ? "#" + id : "",
|
id !== null ? "#" + id : "",
|
||||||
null,
|
null,
|
||||||
score,
|
score + boost,
|
||||||
filenames[file],
|
filenames[file],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
527
inkycal/display/drivers/epd_13_in_3.py
Normal file
527
inkycal/display/drivers/epd_13_in_3.py
Normal file
@@ -0,0 +1,527 @@
|
|||||||
|
"""
|
||||||
|
* | File : epd13in3k.py
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Electronic paper driver
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2023-09-08
|
||||||
|
# | Info : python demo
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation 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
|
||||||
|
|
||||||
|
from inkycal.display.drivers import epdconfig
|
||||||
|
|
||||||
|
# Display resolution
|
||||||
|
EPD_WIDTH = 960
|
||||||
|
EPD_HEIGHT = 680
|
||||||
|
|
||||||
|
GRAY1 = 0xff # white
|
||||||
|
GRAY2 = 0xC0
|
||||||
|
GRAY3 = 0x80 # gray
|
||||||
|
GRAY4 = 0x00 # Blackest
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class EPD:
|
||||||
|
def __init__(self):
|
||||||
|
self.reset_pin = epdconfig.RST_PIN
|
||||||
|
self.dc_pin = epdconfig.DC_PIN
|
||||||
|
self.busy_pin = epdconfig.BUSY_PIN
|
||||||
|
self.cs_pin = epdconfig.CS_PIN
|
||||||
|
self.width = EPD_WIDTH
|
||||||
|
self.height = EPD_HEIGHT
|
||||||
|
self.GRAY1 = GRAY1 # white
|
||||||
|
self.GRAY2 = GRAY2
|
||||||
|
self.GRAY3 = GRAY3 # gray
|
||||||
|
self.GRAY4 = GRAY4 # Blackest
|
||||||
|
|
||||||
|
self.Lut_Partial = [
|
||||||
|
0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x2A, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x15, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x01, 0x01, 0x01, 0x00,
|
||||||
|
0x0A, 0x00, 0x05, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0x01,
|
||||||
|
0x22, 0x22, 0x22, 0x22, 0x22,
|
||||||
|
0x17, 0x41, 0xA8, 0x32, 0x18,
|
||||||
|
0x00, 0x00, ]
|
||||||
|
|
||||||
|
self.LUT_DATA_4Gray = [
|
||||||
|
0x80, 0x48, 0x4A, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x0A, 0x48, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x88, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0xA8, 0x48, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x07, 0x23, 0x17, 0x02, 0x00,
|
||||||
|
0x05, 0x01, 0x05, 0x01, 0x02,
|
||||||
|
0x08, 0x02, 0x01, 0x04, 0x04,
|
||||||
|
0x00, 0x02, 0x00, 0x02, 0x01,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
0x22, 0x22, 0x22, 0x22, 0x22,
|
||||||
|
0x17, 0x41, 0xA8, 0x32, 0x30,
|
||||||
|
0x00, 0x00, ]
|
||||||
|
|
||||||
|
if (epdconfig.module_init() != 0):
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# Hardware reset
|
||||||
|
def reset(self):
|
||||||
|
epdconfig.digital_write(self.reset_pin, 1)
|
||||||
|
epdconfig.delay_ms(20)
|
||||||
|
epdconfig.digital_write(self.reset_pin, 0)
|
||||||
|
epdconfig.delay_ms(2)
|
||||||
|
epdconfig.digital_write(self.reset_pin, 1)
|
||||||
|
epdconfig.delay_ms(20)
|
||||||
|
|
||||||
|
def send_command(self, command):
|
||||||
|
epdconfig.digital_write(self.dc_pin, 0)
|
||||||
|
epdconfig.digital_write(self.cs_pin, 0)
|
||||||
|
epdconfig.spi_writebyte([command])
|
||||||
|
epdconfig.digital_write(self.cs_pin, 1)
|
||||||
|
|
||||||
|
def send_data(self, data):
|
||||||
|
epdconfig.digital_write(self.dc_pin, 1)
|
||||||
|
epdconfig.digital_write(self.cs_pin, 0)
|
||||||
|
epdconfig.spi_writebyte([data])
|
||||||
|
epdconfig.digital_write(self.cs_pin, 1)
|
||||||
|
|
||||||
|
def send_data2(self, data):
|
||||||
|
epdconfig.digital_write(self.dc_pin, 1)
|
||||||
|
epdconfig.digital_write(self.cs_pin, 0)
|
||||||
|
epdconfig.SPI.writebytes2(data)
|
||||||
|
epdconfig.digital_write(self.cs_pin, 1)
|
||||||
|
|
||||||
|
def ReadBusy(self):
|
||||||
|
logger.debug("e-Paper busy")
|
||||||
|
busy = epdconfig.digital_read(self.busy_pin)
|
||||||
|
while (busy == 1):
|
||||||
|
busy = epdconfig.digital_read(self.busy_pin)
|
||||||
|
epdconfig.delay_ms(20)
|
||||||
|
epdconfig.delay_ms(20)
|
||||||
|
logger.debug("e-Paper busy release")
|
||||||
|
|
||||||
|
def TurnOnDisplay(self):
|
||||||
|
self.send_command(0x22) # Display Update Control
|
||||||
|
self.send_data(0xF7)
|
||||||
|
self.send_command(0x20) # Activate Display Update Sequence
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
def TurnOnDisplay_Part(self):
|
||||||
|
self.send_command(0x22) # Display Update Control
|
||||||
|
self.send_data(0xCF)
|
||||||
|
self.send_command(0x20) # Activate Display Update Sequence
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
def TurnOnDisplay_4GRAY(self):
|
||||||
|
self.send_command(0x22) # Display Update Control
|
||||||
|
self.send_data(0xC7)
|
||||||
|
self.send_command(0x20) # Activate Display Update Sequence
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
def Lut(self, LUT):
|
||||||
|
self.send_command(0x32)
|
||||||
|
for i in range(105):
|
||||||
|
self.send_data(LUT[i])
|
||||||
|
|
||||||
|
self.send_command(0x03)
|
||||||
|
self.send_data(LUT[105])
|
||||||
|
|
||||||
|
self.send_command(0x04)
|
||||||
|
self.send_data(LUT[106])
|
||||||
|
self.send_data(LUT[107])
|
||||||
|
self.send_data(LUT[108])
|
||||||
|
|
||||||
|
self.send_command(0x2C)
|
||||||
|
self.send_data(LUT[109])
|
||||||
|
|
||||||
|
def init(self):
|
||||||
|
|
||||||
|
# EPD hardware init start
|
||||||
|
self.reset()
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
self.send_command(0x12) # SWRESET
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
self.send_command(0x0C)
|
||||||
|
self.send_data(0xAE)
|
||||||
|
self.send_data(0xC7)
|
||||||
|
self.send_data(0xC3)
|
||||||
|
self.send_data(0xC0)
|
||||||
|
self.send_data(0x80)
|
||||||
|
|
||||||
|
self.send_command(0x01)
|
||||||
|
self.send_data(0xA7)
|
||||||
|
self.send_data(0x02)
|
||||||
|
self.send_data(0x00)
|
||||||
|
|
||||||
|
self.send_command(0x11)
|
||||||
|
self.send_data(0x03)
|
||||||
|
|
||||||
|
self.send_command(0x44)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0xBF)
|
||||||
|
self.send_data(0x03)
|
||||||
|
|
||||||
|
self.send_command(0x45)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0xA7)
|
||||||
|
self.send_data(0x02)
|
||||||
|
|
||||||
|
self.send_command(0x3C)
|
||||||
|
self.send_data(0x05)
|
||||||
|
|
||||||
|
self.send_command(0x18)
|
||||||
|
self.send_data(0x80)
|
||||||
|
|
||||||
|
self.send_command(0x4E)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
|
||||||
|
self.send_command(0x4F)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
|
||||||
|
# EPD hardware init end
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def init_Part(self):
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.send_command(0x3C)
|
||||||
|
self.send_data(0x80)
|
||||||
|
|
||||||
|
self.Lut(self.Lut_Partial)
|
||||||
|
|
||||||
|
self.send_command(0x37)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x40)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
|
||||||
|
self.send_command(0x3C)
|
||||||
|
self.send_data(0x80)
|
||||||
|
|
||||||
|
self.send_command(0x22)
|
||||||
|
self.send_data(0xC0)
|
||||||
|
self.send_command(0x20)
|
||||||
|
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
def init_4GRAY(self):
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
self.ReadBusy()
|
||||||
|
self.send_command(0x12)
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
self.send_command(0x0C)
|
||||||
|
self.send_data(0xAE)
|
||||||
|
self.send_data(0xC7)
|
||||||
|
self.send_data(0xC3)
|
||||||
|
self.send_data(0xC0)
|
||||||
|
self.send_data(0x80)
|
||||||
|
|
||||||
|
self.send_command(0x01)
|
||||||
|
self.send_data(0xA7)
|
||||||
|
self.send_data(0x02)
|
||||||
|
self.send_data(0x00)
|
||||||
|
|
||||||
|
self.send_command(0x11)
|
||||||
|
self.send_data(0x03)
|
||||||
|
|
||||||
|
self.send_command(0x44)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0xBF)
|
||||||
|
self.send_data(0x03)
|
||||||
|
|
||||||
|
self.send_command(0x45)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0xA7)
|
||||||
|
self.send_data(0x02)
|
||||||
|
|
||||||
|
self.send_command(0x3C)
|
||||||
|
self.send_data(0x00)
|
||||||
|
|
||||||
|
self.send_command(0x18)
|
||||||
|
self.send_data(0x80)
|
||||||
|
|
||||||
|
self.send_command(0x4E)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
|
||||||
|
self.send_command(0x4F)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
|
||||||
|
self.Lut(self.LUT_DATA_4Gray)
|
||||||
|
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
def getbuffer(self, image):
|
||||||
|
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
|
||||||
|
buf = [0xFF] * (int(self.width / 8) * self.height)
|
||||||
|
image_monocolor = image.convert('1')
|
||||||
|
imwidth, imheight = image_monocolor.size
|
||||||
|
pixels = image_monocolor.load()
|
||||||
|
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
|
||||||
|
if imwidth == self.width and imheight == self.height:
|
||||||
|
logger.debug("Horizontal")
|
||||||
|
for y in range(imheight):
|
||||||
|
for x in range(imwidth):
|
||||||
|
# Set the bits for the column of pixels at the current position.
|
||||||
|
if pixels[x, y] == 0:
|
||||||
|
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
|
||||||
|
elif imwidth == self.height and imheight == self.width:
|
||||||
|
logger.debug("Vertical")
|
||||||
|
for y in range(imheight):
|
||||||
|
for x in range(imwidth):
|
||||||
|
newx = y
|
||||||
|
newy = self.height - x - 1
|
||||||
|
if pixels[x, y] == 0:
|
||||||
|
buf[int((newx + newy * self.width) / 8)] &= ~(0x80 >> (y % 8))
|
||||||
|
return buf
|
||||||
|
|
||||||
|
def getbuffer_4Gray(self, image):
|
||||||
|
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
|
||||||
|
buf = [0xFF] * (int(self.width / 4) * self.height)
|
||||||
|
image_monocolor = image.convert('L')
|
||||||
|
imwidth, imheight = image_monocolor.size
|
||||||
|
pixels = image_monocolor.load()
|
||||||
|
i = 0
|
||||||
|
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
|
||||||
|
if (imwidth == self.width and imheight == self.height):
|
||||||
|
logger.debug("Vertical")
|
||||||
|
for y in range(imheight):
|
||||||
|
for x in range(imwidth):
|
||||||
|
# Set the bits for the column of pixels at the current position.
|
||||||
|
if (pixels[x, y] == 0xC0):
|
||||||
|
pixels[x, y] = 0x80
|
||||||
|
elif (pixels[x, y] == 0x80):
|
||||||
|
pixels[x, y] = 0x40
|
||||||
|
i = i + 1
|
||||||
|
if (i % 4 == 0):
|
||||||
|
buf[int((x + (y * self.width)) / 4)] = (
|
||||||
|
(pixels[x - 3, y] & 0xc0) | (pixels[x - 2, y] & 0xc0) >> 2 | (
|
||||||
|
pixels[x - 1, y] & 0xc0) >> 4 | (pixels[x, y] & 0xc0) >> 6)
|
||||||
|
|
||||||
|
elif (imwidth == self.height and imheight == self.width):
|
||||||
|
logger.debug("Horizontal")
|
||||||
|
for x in range(imwidth):
|
||||||
|
for y in range(imheight):
|
||||||
|
newx = y
|
||||||
|
newy = self.height - x - 1
|
||||||
|
if (pixels[x, y] == 0xC0):
|
||||||
|
pixels[x, y] = 0x80
|
||||||
|
elif (pixels[x, y] == 0x80):
|
||||||
|
pixels[x, y] = 0x40
|
||||||
|
i = i + 1
|
||||||
|
if (i % 4 == 0):
|
||||||
|
buf[int((newx + (newy * self.width)) / 4)] = (
|
||||||
|
(pixels[x, y - 3] & 0xc0) | (pixels[x, y - 2] & 0xc0) >> 2 | (
|
||||||
|
pixels[x, y - 1] & 0xc0) >> 4 | (pixels[x, y] & 0xc0) >> 6)
|
||||||
|
return buf
|
||||||
|
|
||||||
|
def Clear(self):
|
||||||
|
buf = [0xFF] * (int(self.width / 8) * self.height)
|
||||||
|
self.send_command(0x24)
|
||||||
|
self.send_data2(buf)
|
||||||
|
|
||||||
|
self.TurnOnDisplay()
|
||||||
|
|
||||||
|
def display(self, image):
|
||||||
|
self.send_command(0x24)
|
||||||
|
self.send_data2(image)
|
||||||
|
|
||||||
|
self.TurnOnDisplay()
|
||||||
|
|
||||||
|
def display_Base(self, image):
|
||||||
|
self.send_command(0x24)
|
||||||
|
self.send_data2(image)
|
||||||
|
|
||||||
|
self.send_command(0x26)
|
||||||
|
self.send_data2(image)
|
||||||
|
|
||||||
|
self.TurnOnDisplay()
|
||||||
|
|
||||||
|
def display_Base_color(self, color):
|
||||||
|
if (self.width % 8 == 0):
|
||||||
|
Width = self.width // 8
|
||||||
|
else:
|
||||||
|
Width = self.width // 8 + 1
|
||||||
|
Height = self.height
|
||||||
|
self.send_command(0x24) # Write Black and White image to RAM
|
||||||
|
for j in range(Height):
|
||||||
|
for i in range(Width):
|
||||||
|
self.send_data(color)
|
||||||
|
|
||||||
|
self.send_command(0x26) # Write Black and White image to RAM
|
||||||
|
for j in range(Height):
|
||||||
|
for i in range(Width):
|
||||||
|
self.send_data(color)
|
||||||
|
# self.TurnOnDisplay()
|
||||||
|
|
||||||
|
def display_Partial(self, Image, Xstart, Ystart, Xend, Yend):
|
||||||
|
if ((Xstart % 8 + Xend % 8 == 8 & Xstart % 8 > Xend % 8) | Xstart % 8 + Xend % 8 == 0 | (
|
||||||
|
Xend - Xstart) % 8 == 0):
|
||||||
|
Xstart = Xstart // 8
|
||||||
|
Xend = Xend // 8
|
||||||
|
else:
|
||||||
|
Xstart = Xstart // 8
|
||||||
|
if Xend % 8 == 0:
|
||||||
|
Xend = Xend // 8
|
||||||
|
else:
|
||||||
|
Xend = Xend // 8 + 1
|
||||||
|
|
||||||
|
if (self.width % 8 == 0):
|
||||||
|
Width = self.width // 8
|
||||||
|
else:
|
||||||
|
Width = self.width // 8 + 1
|
||||||
|
Height = self.height
|
||||||
|
|
||||||
|
Xend -= 1
|
||||||
|
Yend -= 1
|
||||||
|
|
||||||
|
self.send_command(0x44)
|
||||||
|
self.send_data((Xstart * 8) & 0xff)
|
||||||
|
self.send_data((Xstart >> 5) & 0x01)
|
||||||
|
self.send_data((Xend * 8) & 0xff)
|
||||||
|
self.send_data((Xend >> 5) & 0x01)
|
||||||
|
self.send_command(0x45)
|
||||||
|
self.send_data(Ystart & 0xff)
|
||||||
|
self.send_data((Ystart >> 8) & 0x01)
|
||||||
|
self.send_data(Yend & 0xff)
|
||||||
|
self.send_data((Yend >> 8) & 0x01)
|
||||||
|
|
||||||
|
self.send_command(0x4E)
|
||||||
|
self.send_data((Xstart * 8) & 0xff)
|
||||||
|
self.send_data((Xstart >> 5) & 0x01)
|
||||||
|
self.send_command(0x4F)
|
||||||
|
self.send_data(Ystart & 0xff)
|
||||||
|
self.send_data((Ystart >> 8) & 0x01)
|
||||||
|
|
||||||
|
self.send_command(0x24)
|
||||||
|
for j in range(Height):
|
||||||
|
for i in range(Width):
|
||||||
|
if ((j > Ystart - 1) & (j < (Yend + 1)) & (i > Xstart - 1) & (i < (Xend + 1))):
|
||||||
|
self.send_data(Image[i + j * Width])
|
||||||
|
self.TurnOnDisplay_Part()
|
||||||
|
|
||||||
|
def display_4Gray(self, image):
|
||||||
|
self.send_command(0x24)
|
||||||
|
for i in range(0, 81600):
|
||||||
|
temp3 = 0
|
||||||
|
for j in range(0, 2):
|
||||||
|
temp1 = image[i * 2 + j]
|
||||||
|
for k in range(0, 2):
|
||||||
|
temp2 = temp1 & 0xC0
|
||||||
|
if (temp2 == 0xC0):
|
||||||
|
temp3 |= 0x00
|
||||||
|
elif (temp2 == 0x00):
|
||||||
|
temp3 |= 0x01
|
||||||
|
elif (temp2 == 0x80):
|
||||||
|
temp3 |= 0x01
|
||||||
|
else: # 0x40
|
||||||
|
temp3 |= 0x00
|
||||||
|
temp3 <<= 1
|
||||||
|
|
||||||
|
temp1 <<= 2
|
||||||
|
temp2 = temp1 & 0xC0
|
||||||
|
if (temp2 == 0xC0):
|
||||||
|
temp3 |= 0x00
|
||||||
|
elif (temp2 == 0x00):
|
||||||
|
temp3 |= 0x01
|
||||||
|
elif (temp2 == 0x80):
|
||||||
|
temp3 |= 0x01
|
||||||
|
else: # 0x40
|
||||||
|
temp3 |= 0x00
|
||||||
|
if (j != 1 or k != 1):
|
||||||
|
temp3 <<= 1
|
||||||
|
temp1 <<= 2
|
||||||
|
self.send_data(temp3)
|
||||||
|
|
||||||
|
self.send_command(0x26)
|
||||||
|
for i in range(0, 81600):
|
||||||
|
temp3 = 0
|
||||||
|
for j in range(0, 2):
|
||||||
|
temp1 = image[i * 2 + j]
|
||||||
|
for k in range(0, 2):
|
||||||
|
temp2 = temp1 & 0xC0
|
||||||
|
if (temp2 == 0xC0):
|
||||||
|
temp3 |= 0x00
|
||||||
|
elif (temp2 == 0x00):
|
||||||
|
temp3 |= 0x01
|
||||||
|
elif (temp2 == 0x80):
|
||||||
|
temp3 |= 0x00
|
||||||
|
else: # 0x40
|
||||||
|
temp3 |= 0x01
|
||||||
|
temp3 <<= 1
|
||||||
|
|
||||||
|
temp1 <<= 2
|
||||||
|
temp2 = temp1 & 0xC0
|
||||||
|
if (temp2 == 0xC0):
|
||||||
|
temp3 |= 0x00
|
||||||
|
elif (temp2 == 0x00):
|
||||||
|
temp3 |= 0x01
|
||||||
|
elif (temp2 == 0x80):
|
||||||
|
temp3 |= 0x00
|
||||||
|
else: # 0x40
|
||||||
|
temp3 |= 0x01
|
||||||
|
if (j != 1 or k != 1):
|
||||||
|
temp3 <<= 1
|
||||||
|
temp1 <<= 2
|
||||||
|
self.send_data(temp3)
|
||||||
|
|
||||||
|
self.TurnOnDisplay_4GRAY()
|
||||||
|
|
||||||
|
def sleep(self):
|
||||||
|
self.send_command(0x10) # DEEP_SLEEP
|
||||||
|
self.send_data(0x03)
|
||||||
|
|
||||||
|
epdconfig.delay_ms(2000)
|
||||||
|
epdconfig.module_exit()
|
299
inkycal/display/drivers/epd_13_in_3_colour.py
Normal file
299
inkycal/display/drivers/epd_13_in_3_colour.py
Normal file
@@ -0,0 +1,299 @@
|
|||||||
|
"""
|
||||||
|
* | File : epd13in3b.py
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Electronic paper driver
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2024-04-08
|
||||||
|
# | Info : python demo
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation 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
|
||||||
|
|
||||||
|
from inkycal.display.drivers import epdconfig
|
||||||
|
|
||||||
|
# Display resolution
|
||||||
|
EPD_WIDTH = 960
|
||||||
|
EPD_HEIGHT = 680
|
||||||
|
|
||||||
|
GRAY1 = 0xff # white
|
||||||
|
GRAY2 = 0xC0
|
||||||
|
GRAY3 = 0x80 # gray
|
||||||
|
GRAY4 = 0x00 # Blackest
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class EPD:
|
||||||
|
def __init__(self):
|
||||||
|
self.reset_pin = epdconfig.RST_PIN
|
||||||
|
self.dc_pin = epdconfig.DC_PIN
|
||||||
|
self.busy_pin = epdconfig.BUSY_PIN
|
||||||
|
self.cs_pin = epdconfig.CS_PIN
|
||||||
|
self.width = EPD_WIDTH
|
||||||
|
self.height = EPD_HEIGHT
|
||||||
|
if (epdconfig.module_init() != 0):
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# Hardware reset
|
||||||
|
def reset(self):
|
||||||
|
epdconfig.digital_write(self.reset_pin, 1)
|
||||||
|
epdconfig.delay_ms(20)
|
||||||
|
epdconfig.digital_write(self.reset_pin, 0)
|
||||||
|
epdconfig.delay_ms(2)
|
||||||
|
epdconfig.digital_write(self.reset_pin, 1)
|
||||||
|
epdconfig.delay_ms(20)
|
||||||
|
|
||||||
|
def send_command(self, command):
|
||||||
|
epdconfig.digital_write(self.dc_pin, 0)
|
||||||
|
epdconfig.digital_write(self.cs_pin, 0)
|
||||||
|
epdconfig.spi_writebyte([command])
|
||||||
|
epdconfig.digital_write(self.cs_pin, 1)
|
||||||
|
|
||||||
|
def send_data(self, data):
|
||||||
|
epdconfig.digital_write(self.dc_pin, 1)
|
||||||
|
epdconfig.digital_write(self.cs_pin, 0)
|
||||||
|
epdconfig.spi_writebyte([data])
|
||||||
|
epdconfig.digital_write(self.cs_pin, 1)
|
||||||
|
|
||||||
|
def send_data2(self, data):
|
||||||
|
epdconfig.digital_write(self.dc_pin, 1)
|
||||||
|
epdconfig.digital_write(self.cs_pin, 0)
|
||||||
|
epdconfig.SPI.writebytes2(data)
|
||||||
|
epdconfig.digital_write(self.cs_pin, 1)
|
||||||
|
|
||||||
|
def ReadBusy(self):
|
||||||
|
logger.debug("e-Paper busy")
|
||||||
|
busy = epdconfig.digital_read(self.busy_pin)
|
||||||
|
while (busy == 1):
|
||||||
|
busy = epdconfig.digital_read(self.busy_pin)
|
||||||
|
epdconfig.delay_ms(20)
|
||||||
|
epdconfig.delay_ms(20)
|
||||||
|
logger.debug("e-Paper busy release")
|
||||||
|
|
||||||
|
def TurnOnDisplay(self):
|
||||||
|
self.send_command(0x22) # Display Update Control
|
||||||
|
self.send_data(0xF7)
|
||||||
|
self.send_command(0x20) # Activate Display Update Sequence
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
def TurnOnDisplay_Part(self):
|
||||||
|
self.send_command(0x22) # Display Update Control
|
||||||
|
self.send_data(0xFF)
|
||||||
|
self.send_command(0x20) # Activate Display Update Sequence
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
def init(self):
|
||||||
|
# EPD hardware init start
|
||||||
|
self.reset()
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
self.send_command(0x12) # SWRESET
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
self.send_command(0x0C)
|
||||||
|
self.send_data(0xAE)
|
||||||
|
self.send_data(0xC7)
|
||||||
|
self.send_data(0xC3)
|
||||||
|
self.send_data(0xC0)
|
||||||
|
self.send_data(0x80)
|
||||||
|
|
||||||
|
self.send_command(0x01)
|
||||||
|
self.send_data(0xA7)
|
||||||
|
self.send_data(0x02)
|
||||||
|
self.send_data(0x00)
|
||||||
|
|
||||||
|
self.send_command(0x11)
|
||||||
|
self.send_data(0x03)
|
||||||
|
|
||||||
|
self.send_command(0x44)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0xBF)
|
||||||
|
self.send_data(0x03)
|
||||||
|
|
||||||
|
self.send_command(0x45)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0xA7)
|
||||||
|
self.send_data(0x02)
|
||||||
|
|
||||||
|
self.send_command(0x3C)
|
||||||
|
self.send_data(0x01)
|
||||||
|
|
||||||
|
self.send_command(0x18)
|
||||||
|
self.send_data(0x80)
|
||||||
|
|
||||||
|
self.send_command(0x4E)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
|
||||||
|
self.send_command(0x4F)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.send_data(0x00)
|
||||||
|
self.ReadBusy()
|
||||||
|
|
||||||
|
# EPD hardware init end
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def getbuffer(self, image):
|
||||||
|
# logger.debug("bufsiz = ",int(self.width/8) * self.height)
|
||||||
|
buf = [0xFF] * (int(self.width / 8) * self.height)
|
||||||
|
image_monocolor = image.convert('1')
|
||||||
|
imwidth, imheight = image_monocolor.size
|
||||||
|
pixels = image_monocolor.load()
|
||||||
|
# logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
|
||||||
|
if imwidth == self.width and imheight == self.height:
|
||||||
|
logger.debug("Horizontal")
|
||||||
|
for y in range(imheight):
|
||||||
|
for x in range(imwidth):
|
||||||
|
# Set the bits for the column of pixels at the current position.
|
||||||
|
if pixels[x, y] == 0:
|
||||||
|
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
|
||||||
|
elif imwidth == self.height and imheight == self.width:
|
||||||
|
logger.debug("Vertical")
|
||||||
|
for y in range(imheight):
|
||||||
|
for x in range(imwidth):
|
||||||
|
newx = y
|
||||||
|
newy = self.height - x - 1
|
||||||
|
if pixels[x, y] == 0:
|
||||||
|
buf[int((newx + newy * self.width) / 8)] &= ~(0x80 >> (y % 8))
|
||||||
|
return buf
|
||||||
|
|
||||||
|
def Clear(self):
|
||||||
|
self.send_command(0x24)
|
||||||
|
self.send_data2([0xFF] * (int(self.width / 8) * self.height))
|
||||||
|
self.send_command(0x26)
|
||||||
|
self.send_data2([0x00] * (int(self.width / 8) * self.height))
|
||||||
|
|
||||||
|
self.TurnOnDisplay()
|
||||||
|
|
||||||
|
def Clear_Base(self):
|
||||||
|
self.send_command(0x24)
|
||||||
|
self.send_data2([0xFF] * (int(self.width / 8) * self.height))
|
||||||
|
self.send_command(0x26)
|
||||||
|
self.send_data2([0x00] * (int(self.width / 8) * self.height))
|
||||||
|
|
||||||
|
self.TurnOnDisplay()
|
||||||
|
self.send_command(0x26)
|
||||||
|
self.send_data2([0xFF] * (int(self.width / 8) * self.height))
|
||||||
|
|
||||||
|
def display(self, blackimage, ryimage):
|
||||||
|
if (self.width % 8 == 0):
|
||||||
|
Width = self.width // 8
|
||||||
|
else:
|
||||||
|
Width = self.width // 8 + 1
|
||||||
|
Height = self.height
|
||||||
|
if (blackimage != None):
|
||||||
|
self.send_command(0x24)
|
||||||
|
self.send_data2(blackimage)
|
||||||
|
if (ryimage != None):
|
||||||
|
for j in range(Height):
|
||||||
|
for i in range(Width):
|
||||||
|
ryimage[i + j * Width] = ~ryimage[i + j * Width]
|
||||||
|
self.send_command(0x26)
|
||||||
|
self.send_data2(ryimage)
|
||||||
|
|
||||||
|
self.TurnOnDisplay()
|
||||||
|
|
||||||
|
def display_Base(self, blackimage, ryimage):
|
||||||
|
if (self.width % 8 == 0):
|
||||||
|
Width = self.width // 8
|
||||||
|
else:
|
||||||
|
Width = self.width // 8 + 1
|
||||||
|
Height = self.height
|
||||||
|
if (blackimage != None):
|
||||||
|
self.send_command(0x24)
|
||||||
|
self.send_data2(blackimage)
|
||||||
|
if (ryimage != None):
|
||||||
|
for j in range(Height):
|
||||||
|
for i in range(Width):
|
||||||
|
ryimage[i + j * Width] = ~ryimage[i + j * Width]
|
||||||
|
self.send_command(0x26)
|
||||||
|
self.send_data2(ryimage)
|
||||||
|
|
||||||
|
self.TurnOnDisplay()
|
||||||
|
|
||||||
|
self.send_command(0x26)
|
||||||
|
self.send_data2(blackimage)
|
||||||
|
|
||||||
|
def display_Partial(self, Image, Xstart, Ystart, Xend, Yend):
|
||||||
|
if ((Xstart % 8 + Xend % 8 == 8 & Xstart % 8 > Xend % 8) | Xstart % 8 + Xend % 8 == 0 | (
|
||||||
|
Xend - Xstart) % 8 == 0):
|
||||||
|
Xstart = Xstart // 8
|
||||||
|
Xend = Xend // 8
|
||||||
|
else:
|
||||||
|
Xstart = Xstart // 8
|
||||||
|
if Xend % 8 == 0:
|
||||||
|
Xend = Xend // 8
|
||||||
|
else:
|
||||||
|
Xend = Xend // 8 + 1
|
||||||
|
|
||||||
|
if (self.width % 8 == 0):
|
||||||
|
Width = self.width // 8
|
||||||
|
else:
|
||||||
|
Width = self.width // 8 + 1
|
||||||
|
Height = self.height
|
||||||
|
|
||||||
|
Xend -= 1
|
||||||
|
Yend -= 1
|
||||||
|
|
||||||
|
self.send_command(0x3C)
|
||||||
|
self.send_data(0x80)
|
||||||
|
|
||||||
|
self.send_command(0x44)
|
||||||
|
self.send_data((Xstart * 8) & 0xff)
|
||||||
|
self.send_data((Xstart >> 5) & 0x01)
|
||||||
|
self.send_data((Xend * 8) & 0xff)
|
||||||
|
self.send_data((Xend >> 5) & 0x01)
|
||||||
|
self.send_command(0x45)
|
||||||
|
self.send_data(Ystart & 0xff)
|
||||||
|
self.send_data((Ystart >> 8) & 0x01)
|
||||||
|
self.send_data(Yend & 0xff)
|
||||||
|
self.send_data((Yend >> 8) & 0x01)
|
||||||
|
|
||||||
|
self.send_command(0x4E)
|
||||||
|
self.send_data((Xstart * 8) & 0xff)
|
||||||
|
self.send_data((Xstart >> 5) & 0x01)
|
||||||
|
self.send_command(0x4F)
|
||||||
|
self.send_data(Ystart & 0xff)
|
||||||
|
self.send_data((Ystart >> 8) & 0x01)
|
||||||
|
|
||||||
|
self.send_command(0x24)
|
||||||
|
for j in range(Height):
|
||||||
|
for i in range(Width):
|
||||||
|
if ((j > Ystart - 1) & (j < (Yend + 1)) & (i > Xstart - 1) & (i < (Xend + 1))):
|
||||||
|
self.send_data(Image[i + j * Width])
|
||||||
|
self.TurnOnDisplay_Part()
|
||||||
|
|
||||||
|
self.send_command(0x26)
|
||||||
|
for j in range(Height):
|
||||||
|
for i in range(Width):
|
||||||
|
if ((j > Ystart - 1) & (j < (Yend + 1)) & (i > Xstart - 1) & (i < (Xend + 1))):
|
||||||
|
self.send_data(Image[i + j * Width])
|
||||||
|
|
||||||
|
def sleep(self):
|
||||||
|
self.send_command(0x10) # DEEP_SLEEP
|
||||||
|
self.send_data(0x03)
|
||||||
|
|
||||||
|
epdconfig.delay_ms(2000)
|
||||||
|
epdconfig.module_exit()
|
@@ -1,4 +1,6 @@
|
|||||||
supported_models = {
|
supported_models = {
|
||||||
|
"epd_13_in_3": (960, 680),
|
||||||
|
"epd_13_in_3_colour": (960, 680),
|
||||||
"epd_12_in_48": (1304, 984),
|
"epd_12_in_48": (1304, 984),
|
||||||
"epd_7_in_5_colour": (640, 384),
|
"epd_7_in_5_colour": (640, 384),
|
||||||
"9_in_7": (1200, 825),
|
"9_in_7": (1200, 825),
|
||||||
|
@@ -6,6 +6,7 @@ Copyright by aceinnolab
|
|||||||
import asyncio
|
import asyncio
|
||||||
import glob
|
import glob
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import os.path
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
@@ -72,13 +73,16 @@ class Inkycal:
|
|||||||
f"No settings.json file could be found in the specified location: {settings_path}")
|
f"No settings.json file could be found in the specified location: {settings_path}")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.info("Looking for settings.json file in /boot folder...")
|
found = False
|
||||||
try:
|
for location in settings.SETTINGS_JSON_PATHS:
|
||||||
with open('/boot/settings.json', mode="r") as settings_file:
|
if os.path.exists(location):
|
||||||
|
logger.info(f"Found settings.json file in {location}")
|
||||||
|
with open(location, mode="r") as settings_file:
|
||||||
self.settings = json.load(settings_file)
|
self.settings = json.load(settings_file)
|
||||||
|
found = True
|
||||||
except FileNotFoundError:
|
break
|
||||||
raise SettingsFileNotFoundError
|
if not found:
|
||||||
|
raise SettingsFileNotFoundError(f"No settings.json file could be found in {settings.SETTINGS_JSON_PATHS} and no explicit path was specified.")
|
||||||
|
|
||||||
self.disable_calibration = self.settings.get('disable_calibration', False)
|
self.disable_calibration = self.settings.get('disable_calibration', False)
|
||||||
if self.disable_calibration:
|
if self.disable_calibration:
|
||||||
|
@@ -12,3 +12,4 @@ from .inkycal_webshot import Webshot
|
|||||||
from .inkycal_xkcd import Xkcd
|
from .inkycal_xkcd import Xkcd
|
||||||
from .inkycal_fullweather import Fullweather
|
from .inkycal_fullweather import Fullweather
|
||||||
from .inkycal_tindie import Tindie
|
from .inkycal_tindie import Tindie
|
||||||
|
from .inkycal_vikunja import Vikunja
|
||||||
|
@@ -82,10 +82,11 @@ class Inkyimage:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def preview(image):
|
def preview(image):
|
||||||
"""Previews an image on gpicview (only works on Rapsbian with Desktop)."""
|
"""Previews an image on gpicview (only works on Rapsbian with Desktop)."""
|
||||||
path = "~/temp"
|
path = "/root/repos/Inkycal/temp"
|
||||||
image.save(path + "/temp.png")
|
image.save(path + "/temp.png")
|
||||||
os.system("gpicview " + path + "/temp.png")
|
print(f"previewing image at {path}/temp.png")
|
||||||
os.system("rm " + path + "/temp.png")
|
# os.system("gpicview " + path + "/temp.png")
|
||||||
|
# os.system("rm " + path + "/temp.png")
|
||||||
|
|
||||||
def _image_loaded(self):
|
def _image_loaded(self):
|
||||||
"""returns True if image was loaded"""
|
"""returns True if image was loaded"""
|
||||||
|
@@ -103,6 +103,9 @@ class Todoist(inkycal_module):
|
|||||||
all_active_tasks = self._api.get_tasks()
|
all_active_tasks = self._api.get_tasks()
|
||||||
|
|
||||||
logger.debug(f"all_projects: {all_projects}")
|
logger.debug(f"all_projects: {all_projects}")
|
||||||
|
print(f"all_projects: {all_projects}")
|
||||||
|
logger.debug(f"all_active_tasks: {all_active_tasks}")
|
||||||
|
print(f"all_active_tasks: {all_active_tasks}")
|
||||||
|
|
||||||
# Filter entries in all_projects if filter was given
|
# Filter entries in all_projects if filter was given
|
||||||
if self.project_filter:
|
if self.project_filter:
|
||||||
|
318
inkycal/modules/inkycal_vikunja.py
Normal file
318
inkycal/modules/inkycal_vikunja.py
Normal file
@@ -0,0 +1,318 @@
|
|||||||
|
"""
|
||||||
|
Inkycal Todoist Module
|
||||||
|
Copyright by aceinnolab
|
||||||
|
"""
|
||||||
|
import arrow
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from inkycal.modules.template import inkycal_module
|
||||||
|
from inkycal.custom import *
|
||||||
|
|
||||||
|
from todoist_api_python.api import TodoistAPI
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class LoginVikunja():
|
||||||
|
def __init__(self, username, password, totp_passcode=None, token=None, api_url='http://192.168.50.10:3456/api/v1/'):
|
||||||
|
self.username = username
|
||||||
|
self.password = password
|
||||||
|
self.totp_passcode = totp_passcode
|
||||||
|
self.token = None
|
||||||
|
self.api_url = api_url
|
||||||
|
self._access_token = token
|
||||||
|
if self._access_token is None:
|
||||||
|
self._access_token = self.get_token()
|
||||||
|
|
||||||
|
def _create_url(self, path):
|
||||||
|
return self.api_url + path
|
||||||
|
|
||||||
|
"""returns the token from the login request"""
|
||||||
|
def _post_login_request(self, username, password, totp_passcode):
|
||||||
|
login_url = self._create_url('login')
|
||||||
|
payload = {
|
||||||
|
'long_token': True,
|
||||||
|
'username': username,
|
||||||
|
'password': password,
|
||||||
|
'totp_passcode': totp_passcode
|
||||||
|
}
|
||||||
|
return requests.post(login_url, json=payload, timeout=5)
|
||||||
|
|
||||||
|
def _get_access_token(self):
|
||||||
|
if not self._access_token:
|
||||||
|
token_json = self._post_login_request(self.username, self.password, self.totp_passcode)
|
||||||
|
if token_json.status_code == 200:
|
||||||
|
token = json.loads(token_json.text)
|
||||||
|
self._access_token = token['token']
|
||||||
|
else:
|
||||||
|
raise Exception('Login failed')
|
||||||
|
return self._access_token
|
||||||
|
|
||||||
|
def get_token(self):
|
||||||
|
return self._get_access_token()
|
||||||
|
|
||||||
|
def get_headers(self):
|
||||||
|
return {'Authorization': 'Bearer ' + self._get_access_token()}
|
||||||
|
|
||||||
|
class ApiVikunja():
|
||||||
|
def __init__(self, username, password, totp_passcode=None, token=None, api_url='http://192.168.50.10:3456/api/v1/'):
|
||||||
|
self.username = username
|
||||||
|
self.password = password
|
||||||
|
self.totp_passcode = totp_passcode
|
||||||
|
self.token = None
|
||||||
|
self.api_url = api_url
|
||||||
|
self._cache = {'projects': None, 'tasks': None, 'labels': None}
|
||||||
|
self._login = LoginVikunja(username, password, totp_passcode, token, api_url)
|
||||||
|
def _create_url(self, path):
|
||||||
|
return self.api_url + path
|
||||||
|
|
||||||
|
def _to_json(self, response):
|
||||||
|
try:
|
||||||
|
return response.json()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f'Error parsing json: {e}')
|
||||||
|
raise e
|
||||||
|
|
||||||
|
def _get_json(self, url, params=None, headers=None):
|
||||||
|
if params is None:
|
||||||
|
params = {}
|
||||||
|
response = requests.get(url, params=params, headers=headers, timeout=5)
|
||||||
|
response.raise_for_status()
|
||||||
|
json_result = self._to_json(response)
|
||||||
|
total_pages = int(response.headers.get('x-pagination-total-pages', 1))
|
||||||
|
if total_pages > 1:
|
||||||
|
logger.debug('Trying to get all pages')
|
||||||
|
for page in range(2, total_pages + 1):
|
||||||
|
logger.debug(f'Getting page {page}')
|
||||||
|
params.update({'page': page})
|
||||||
|
response = requests.get(url, params=params, headers=headers, timeout=5)
|
||||||
|
response.raise_for_status()
|
||||||
|
json_result = json_result + self._to_json(response)
|
||||||
|
return json_result
|
||||||
|
|
||||||
|
def get_projects(self):
|
||||||
|
# if self._cache['projects'] is None:
|
||||||
|
self._cache['projects'] = self._get_json(self._create_url('projects'), headers=self._login.get_headers())
|
||||||
|
return self._cache['projects']
|
||||||
|
|
||||||
|
def get_tasks(self, exclude_completed=True):
|
||||||
|
# if self._cache['tasks'] is None:
|
||||||
|
url = self._create_url('tasks/all')
|
||||||
|
params = {'filter': 'done=false'} if exclude_completed else {}
|
||||||
|
self._cache['tasks'] = self._get_json(url, params, headers=self._login.get_headers()) or []
|
||||||
|
return self._cache['tasks']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Vikunja(inkycal_module):
|
||||||
|
"""Todoist api class
|
||||||
|
parses todos from the todoist api.
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = "Vikunja API - show your todos from Vikunja"
|
||||||
|
|
||||||
|
requires = {
|
||||||
|
'url-frontend': {
|
||||||
|
"label": "Please enter your Vikunja URL",
|
||||||
|
},
|
||||||
|
'url-backend': {
|
||||||
|
"label": "Please enter your Vikunja URL",
|
||||||
|
},
|
||||||
|
'username': {
|
||||||
|
"label": "Please enter your Vikunja username",
|
||||||
|
},
|
||||||
|
'password': {
|
||||||
|
"label": "Please enter your Vikunja password",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
optional = {
|
||||||
|
'project_filter': {
|
||||||
|
"label": "Show Todos only from following project (separated by a comma). Leave empty to show " +
|
||||||
|
"todos from all projects",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, config):
|
||||||
|
"""Initialize inkycal_rss module"""
|
||||||
|
|
||||||
|
super().__init__(config)
|
||||||
|
|
||||||
|
config = config['config']
|
||||||
|
|
||||||
|
# Check if all required parameters are present
|
||||||
|
for param in self.requires:
|
||||||
|
if param not in config:
|
||||||
|
raise Exception(f'config is missing {param}')
|
||||||
|
|
||||||
|
# module specific parameters
|
||||||
|
self.frontend_url = config['url-frontend']
|
||||||
|
self.backend_url = config['url-backend']
|
||||||
|
|
||||||
|
# if project filter is set, initialize it
|
||||||
|
if config['project_filter'] and isinstance(config['project_filter'], str):
|
||||||
|
self.project_filter = config['project_filter'].split(',')
|
||||||
|
else:
|
||||||
|
self.project_filter = config['project_filter']
|
||||||
|
|
||||||
|
# self._api = TodoistAPI(config['api_key'])
|
||||||
|
self._vikunja_api = ApiVikunja(config['username'], config['password'], None, None, config['url-backend'])
|
||||||
|
|
||||||
|
# give an OK message
|
||||||
|
logger.debug(f'{__name__} loaded')
|
||||||
|
|
||||||
|
def _validate(self):
|
||||||
|
"""Validate module-specific parameters"""
|
||||||
|
if not isinstance(self.api_key, str):
|
||||||
|
print('api_key has to be a string: "Yourtopsecretkey123" ')
|
||||||
|
|
||||||
|
def get_projects():
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
def generate_image(self):
|
||||||
|
"""Generate image for this module"""
|
||||||
|
|
||||||
|
# Define new image size with respect to padding
|
||||||
|
im_width = int(self.width - (2 * self.padding_left))
|
||||||
|
im_height = int(self.height - (2 * self.padding_top))
|
||||||
|
im_size = im_width, im_height
|
||||||
|
logger.debug(f'Image size: {im_size}')
|
||||||
|
|
||||||
|
# Create an image for black pixels and one for coloured pixels
|
||||||
|
im_black = Image.new('RGB', size=im_size, color='white')
|
||||||
|
im_colour = Image.new('RGB', size=im_size, color='white')
|
||||||
|
|
||||||
|
# Check if internet is available
|
||||||
|
if internet_available():
|
||||||
|
logger.info('Connection test passed')
|
||||||
|
else:
|
||||||
|
logger.error("Network not reachable. Please check your connection.")
|
||||||
|
raise NetworkNotReachableError
|
||||||
|
|
||||||
|
# Set some parameters for formatting todos
|
||||||
|
line_spacing = 1
|
||||||
|
text_bbox_height = self.font.getbbox("hg")
|
||||||
|
line_height = text_bbox_height[3] + line_spacing
|
||||||
|
line_width = im_width
|
||||||
|
max_lines = im_height // line_height
|
||||||
|
|
||||||
|
# Calculate padding from top so the lines look centralised
|
||||||
|
spacing_top = int(im_height % line_height / 2)
|
||||||
|
|
||||||
|
# Calculate line_positions
|
||||||
|
line_positions = [
|
||||||
|
(0, spacing_top + _ * line_height) for _ in range(max_lines)]
|
||||||
|
|
||||||
|
# Get all projects by name and id
|
||||||
|
# all_projects = self._api.get_projects()
|
||||||
|
# filtered_project_ids_and_names = {project.id: project.name for project in all_projects}
|
||||||
|
# all_active_tasks = self._api.get_tasks()
|
||||||
|
all_projects = self._vikunja_api.get_projects()
|
||||||
|
all_active_tasks = self._vikunja_api.get_tasks()
|
||||||
|
all_active_tasks = [task for task in all_active_tasks if task['done'] == False]
|
||||||
|
|
||||||
|
logger.debug(f"all_projects: {all_projects}")
|
||||||
|
logger.debug(f"all_active_tasks: {all_active_tasks}")
|
||||||
|
print(f"all_projects: {all_projects}")
|
||||||
|
print(f"all_active_tasks: {all_active_tasks}")
|
||||||
|
|
||||||
|
# Filter entries in all_projects if filter was given
|
||||||
|
if self.project_filter:
|
||||||
|
# filtered_projects = [project for project in all_projects if project.name in self.project_filter]
|
||||||
|
filtered_projects = [project for project in all_projects if project['title'] in self.project_filter]
|
||||||
|
filtered_project_ids_and_names = {project['id']: project['title'] for project in filtered_projects}
|
||||||
|
filtered_project_ids = [project for project in filtered_project_ids_and_names]
|
||||||
|
logger.debug(f"filtered projects: {filtered_projects}")
|
||||||
|
print(f"filtered projects: {filtered_projects}")
|
||||||
|
print(f"filtered_project_ids_and_names: {filtered_project_ids_and_names}")
|
||||||
|
print(f"filtered_project_ids: {filtered_project_ids}")
|
||||||
|
|
||||||
|
# If filter was activated and no project was found with that name,
|
||||||
|
# raise an exception to avoid showing a blank image
|
||||||
|
if not filtered_projects:
|
||||||
|
logger.error('No project found from project filter!')
|
||||||
|
logger.error('Please double check spellings in project_filter')
|
||||||
|
raise Exception('No matching project found in filter. Please '
|
||||||
|
'double check spellings in project_filter or leave'
|
||||||
|
'empty')
|
||||||
|
# filtered version of all active tasks
|
||||||
|
all_active_tasks = [task for task in all_active_tasks if task['project_id'] in filtered_project_ids]
|
||||||
|
|
||||||
|
# Simplify the tasks for faster processing
|
||||||
|
simplified = [
|
||||||
|
{
|
||||||
|
'name': task['title'],
|
||||||
|
'due': arrow.get(task['due_date']).format("D-MMM-YY") if 'due_date' in task and task['due_date'][:2] != '00' else "",
|
||||||
|
'priority': task['priority'],
|
||||||
|
'project': filtered_project_ids_and_names[task['project_id']]
|
||||||
|
}
|
||||||
|
for task in all_active_tasks
|
||||||
|
]
|
||||||
|
|
||||||
|
logger.debug(f'simplified: {simplified}')
|
||||||
|
print(f'simplified: {simplified}')
|
||||||
|
|
||||||
|
project_lengths = []
|
||||||
|
due_lengths = []
|
||||||
|
|
||||||
|
for task in simplified:
|
||||||
|
if task["project"]:
|
||||||
|
project_lengths.append(int(self.font.getlength(task['project']) * 1.1))
|
||||||
|
if task["due"]:
|
||||||
|
due_lengths.append(int(self.font.getlength(task['due']) * 1.1))
|
||||||
|
|
||||||
|
# Get maximum width of project names for selected font
|
||||||
|
project_offset = int(max(project_lengths)) if project_lengths else 0
|
||||||
|
|
||||||
|
# Get maximum width of project dues for selected font
|
||||||
|
due_offset = int(max(due_lengths)) if due_lengths else 0
|
||||||
|
|
||||||
|
# create a dict with names of filtered groups
|
||||||
|
groups = {group_name:[] for group_name in filtered_project_ids_and_names.values()}
|
||||||
|
for task in simplified:
|
||||||
|
group_of_current_task = task["project"]
|
||||||
|
if group_of_current_task in groups:
|
||||||
|
groups[group_of_current_task].append(task)
|
||||||
|
|
||||||
|
logger.debug(f"grouped: {groups}")
|
||||||
|
|
||||||
|
# Add the parsed todos on the image
|
||||||
|
cursor = 0
|
||||||
|
for name, todos in groups.items():
|
||||||
|
if todos:
|
||||||
|
for todo in todos:
|
||||||
|
if cursor < max_lines:
|
||||||
|
line_x, line_y = line_positions[cursor]
|
||||||
|
|
||||||
|
if todo['project']:
|
||||||
|
# Add todos project name
|
||||||
|
write(
|
||||||
|
im_colour, line_positions[cursor],
|
||||||
|
(project_offset, line_height),
|
||||||
|
todo['project'], font=self.font, alignment='left')
|
||||||
|
|
||||||
|
# Add todos due if not empty
|
||||||
|
if todo['due']:
|
||||||
|
write(
|
||||||
|
im_black,
|
||||||
|
(line_x + project_offset, line_y),
|
||||||
|
(due_offset, line_height),
|
||||||
|
todo['due'], font=self.font, alignment='left')
|
||||||
|
|
||||||
|
if todo['name']:
|
||||||
|
# Add todos name
|
||||||
|
write(
|
||||||
|
im_black,
|
||||||
|
(line_x + project_offset + due_offset, line_y),
|
||||||
|
(im_width - project_offset - due_offset, line_height),
|
||||||
|
todo['name'], font=self.font, alignment='left')
|
||||||
|
|
||||||
|
cursor += 1
|
||||||
|
else:
|
||||||
|
logger.error('More todos than available lines')
|
||||||
|
break
|
||||||
|
|
||||||
|
# return the images ready for the display
|
||||||
|
return im_black, im_colour
|
@@ -8,7 +8,6 @@ from htmlwebshot import WebShot
|
|||||||
from inkycal.custom import *
|
from inkycal.custom import *
|
||||||
from inkycal.modules.inky_image import Inkyimage as Images, image_to_palette
|
from inkycal.modules.inky_image import Inkyimage as Images, image_to_palette
|
||||||
from inkycal.modules.template import inkycal_module
|
from inkycal.modules.template import inkycal_module
|
||||||
from tests import Config
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ class Webshot(inkycal_module):
|
|||||||
"""Generate image for this module"""
|
"""Generate image for this module"""
|
||||||
|
|
||||||
# Create tmp path
|
# Create tmp path
|
||||||
tmpFolder = Config.TEMP_PATH
|
tmpFolder = "temp"
|
||||||
|
|
||||||
if not os.path.exists(tmpFolder):
|
if not os.path.exists(tmpFolder):
|
||||||
print(f"Creating tmp directory {tmpFolder}")
|
print(f"Creating tmp directory {tmpFolder}")
|
||||||
|
@@ -18,3 +18,5 @@ class Settings:
|
|||||||
PARALLEL_DRIVER_PATH = os.path.join(basedir, "display", "drivers", "parallel_drivers")
|
PARALLEL_DRIVER_PATH = os.path.join(basedir, "display", "drivers", "parallel_drivers")
|
||||||
TEMPORARY_FOLDER = os.path.join(basedir, "tmp")
|
TEMPORARY_FOLDER = os.path.join(basedir, "tmp")
|
||||||
VCOM = "2.0"
|
VCOM = "2.0"
|
||||||
|
# /boot/settings.json is path on older releases, while the latter is more the more recent ones
|
||||||
|
SETTINGS_JSON_PATHS = ["/boot/settings.json", "/boot/firmware/settings.json"]
|
||||||
|
@@ -15,7 +15,8 @@ class Config:
|
|||||||
get = os.environ.get
|
get = os.environ.get
|
||||||
|
|
||||||
# show generated images via preview?
|
# show generated images via preview?
|
||||||
USE_PREVIEW = False
|
# USE_PREVIEW = False
|
||||||
|
USE_PREVIEW = True
|
||||||
|
|
||||||
# ical_parser_test
|
# ical_parser_test
|
||||||
OPENWEATHERMAP_API_KEY = get("OPENWEATHERMAP_API_KEY")
|
OPENWEATHERMAP_API_KEY = get("OPENWEATHERMAP_API_KEY")
|
||||||
|
@@ -43,6 +43,22 @@
|
|||||||
"padding_x": 10,"padding_y": 10,"fontsize": 14,"language": "en"
|
"padding_x": 10,"padding_y": 10,"fontsize": 14,"language": "en"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"position": 4,
|
||||||
|
"name": "Vikunja",
|
||||||
|
"config": {
|
||||||
|
"size": [528, 300],
|
||||||
|
"url-frontend": "http://ff.mhrooz.xyz:8077/",
|
||||||
|
"url-backend": "http://192.168.50.10:3456/api/v1/",
|
||||||
|
"username": "iicd",
|
||||||
|
"password": "9297519Mhz.",
|
||||||
|
"project_filter": ["LMU", "Master Thesis"],
|
||||||
|
"padding_x": 10,
|
||||||
|
"padding_y": 10,
|
||||||
|
"fontsize": 12,
|
||||||
|
"language": "en"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
67
tests/test_inkycal_vikunja.py
Normal file
67
tests/test_inkycal_vikunja.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from inkycal.modules.inkycal_vikunja import LoginVikunja
|
||||||
|
from inkycal.modules.inkycal_vikunja import ApiVikunja
|
||||||
|
from inkycal.modules.inkycal_vikunja import Vikunja
|
||||||
|
from inkycal.modules.inky_image import Inkyimage
|
||||||
|
import unittest
|
||||||
|
from tests import Config
|
||||||
|
preview = Inkyimage.preview
|
||||||
|
merge = Inkyimage.merge
|
||||||
|
|
||||||
|
class TestLoginVikunja(unittest.TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
self.api_url = 'http://192.168.50.10:3456/api/v1/'
|
||||||
|
self.username = 'iicd'
|
||||||
|
self.password = '9297519Mhz.'
|
||||||
|
self.totp_passcode = None
|
||||||
|
def test_post_login_request(self):
|
||||||
|
login = LoginVikunja(self.username, self.password, self.totp_passcode, self.api_url)
|
||||||
|
token_json = login._post_login_request(self.username, self.password, self.totp_passcode)
|
||||||
|
self.assertTrue(token_json.status_code == 200)
|
||||||
|
|
||||||
|
class TestApiVikunja(unittest.TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
self.api_url = 'http://192.168.50.10:3456/api/v1/'
|
||||||
|
self.username = 'iicd'
|
||||||
|
self.password = '9297519Mhz.'
|
||||||
|
self.totp_passcode = None
|
||||||
|
self.api = ApiVikunja(self.username, self.password, self.totp_passcode, None, self.api_url)
|
||||||
|
|
||||||
|
def test_get_projects(self):
|
||||||
|
json_projects = self.api.get_projects()
|
||||||
|
# print(json.dumps(json_projects, indent=4))
|
||||||
|
self.assertTrue(json_projects)
|
||||||
|
|
||||||
|
def test_get_tasks(self):
|
||||||
|
json_tasks = self.api.get_tasks(exclude_completed=True)
|
||||||
|
print(json.dumps(json_tasks, indent=4))
|
||||||
|
self.assertTrue(json_tasks)
|
||||||
|
|
||||||
|
tests = [
|
||||||
|
{
|
||||||
|
"name": "Vikunja",
|
||||||
|
"config": {
|
||||||
|
"size": [400, 1000],
|
||||||
|
"url-frontend": "http://ff.mhrooz.xyz:8077/",
|
||||||
|
"url-backend": "http://192.168.50.10:3456/api/v1/",
|
||||||
|
"username": "iicd",
|
||||||
|
"password": "9297519Mhz.",
|
||||||
|
"project_filter": ["LMU", "Master Thesis"],
|
||||||
|
"padding_x": 10,
|
||||||
|
"padding_y": 10,
|
||||||
|
"fontsize": 12,
|
||||||
|
"language": "en"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
class TestVikunja(unittest.TestCase):
|
||||||
|
def test_generate_image(self):
|
||||||
|
for test in tests:
|
||||||
|
print(f'test {tests.index(test) + 1} generating image..')
|
||||||
|
module = Vikunja(test)
|
||||||
|
im_black, im_colour = module.generate_image()
|
||||||
|
print('OK')
|
||||||
|
if Config.USE_PREVIEW:
|
||||||
|
preview(merge(im_black, im_colour))
|
@@ -30,7 +30,7 @@ tests = [
|
|||||||
"forecast_interval": "daily",
|
"forecast_interval": "daily",
|
||||||
"units": "metric",
|
"units": "metric",
|
||||||
"hour_format": "12",
|
"hour_format": "12",
|
||||||
"use_beaufort": True,
|
"use_beaufort": False,
|
||||||
"padding_x": 10,
|
"padding_x": 10,
|
||||||
"padding_y": 10,
|
"padding_y": 10,
|
||||||
"fontsize": 12,
|
"fontsize": 12,
|
||||||
|
Reference in New Issue
Block a user