code at dwebcamp 2022, probably wont have more changes for a bit

This commit is contained in:
trav 2022-08-24 18:34:56 -04:00
parent 424e9c1272
commit b0b13a0769
2 changed files with 34 additions and 13 deletions

View File

@ -19,7 +19,7 @@ import configparser
import pyqrcode
import qrcode
from tinydb import TinyDB, Query
from PIL import Image,ImageDraw,ImageFont
from PIL import Image,ImageDraw,ImageFont,ImageEnhance
## INITIALIZE ##
@ -29,7 +29,7 @@ buttonshim.set_pixel(0xFF, 0x00, 0xFF)
#intervalTime is how many seconds before moving to next image (300 = 5 minutes)
#sync time is how many seconds before refreshing the DB from SSB
#this should be moved into the config file...
intervalTime = 1800
intervalTime = 200
syncTime = 3600
#keep track of where we are moving through intervalTime, syncTime and where we are in the db, and what flier we're currently displaying
timeIndex = 1200
@ -151,15 +151,19 @@ def pulse(speed):
buttonshim.set_pixel(0x00, int(0xff * scale), 0x00)
time.sleep(1)
for scale in range(0, speed):
if scale >= 1:
scale = scale / speed
buttonshim.set_pixel(int(0xff * scale), int(0xff * scale), 0x00)
for scale in range(speed, 0,-1):
if scale >= 1:
scale = scale / speed
buttonshim.set_pixel(int(0xff * scale), int(0xff * scale), 0x00)
buttonshim.set_pixel(0xFF, 0x00, 0x00)
time.sleep(.02)
buttonshim.set_pixel(0xFF, 0xFF, 0x00)
time.sleep(.02)
buttonshim.set_pixel(0x00, 0xFF, 0x00)
time.sleep(.02)
buttonshim.set_pixel(0xFF, 0xFF, 0x00)
time.sleep(.02)
time.sleep(1)
## MAIN LOOP ##
while True:
#iterate through syncTime and image time
@ -436,7 +440,8 @@ while True:
draw.text((2, 240), 'photostrip posted', font = font18, fill = 255)
draw.text((2, 260), 'to SSB', font = font18, fill = 255)
epd.display(epd.getbuffer(Limage))
# move dbIndex to current photo so that reprint works right
dbIndex = dbCount
#post only locally and print
@ -471,7 +476,8 @@ while True:
draw.text((2, 240), 'PHOTO POSTED', font = font18, fill = 255)
draw.text((2, 260), 'to this device only', font = font18, fill = 255)
epd.display(epd.getbuffer(Limage))
# move dbIndex to current photo so that reprint works right
dbIndex = dbCount

View File

@ -3,11 +3,26 @@
#ok so this script should take an argument of an image and posts it
#add blob
blobID=$(cat $1 | ssb-server blobs.add)
blobID=$(cat $1 | ssb-server blobs.add) || exit 1
#echo $blobID
#publish blob
#key=$(ssb-server publish --type post --text "![upload.bmp($blobID)]"
ssb-server publish --type post --text "a new photo from #dweb-camp 2022! ![photo.bmp]($blobID)" --mentions.0.name photo.bmp --mentions.0.type image/bmp
#ssb-server publish --type post --text "a new photo from #dweb-camp 2022! ![photo.bmp]($blobID)" --mentions.0.name photo.jpg --mentions.0.type image/bmp --mentions.0.link
ssb-server publish . <<EOF
{
"type":"post",
"text":"a new photo from #dweb-camp 2022! ![photo.jpg]($blobID)",
"mentions": [
{
"name": "photo.jpg",
"type": "image/jpeg",
"link": "$blobID"
},
{"link":"#dweb-camp"}
]
}
EOF