Compare commits

..

2 Commits

Author SHA1 Message Date
interfisch 693adf5ac1 add large font 2024-01-09 22:15:54 +01:00
interfisch b10b1005d2 add ota update 2024-01-07 22:37:45 +01:00
7 changed files with 415 additions and 290 deletions

View File

@ -2,12 +2,15 @@
#define FONTS_H
#include <Arduino.h>
const uint8_t font_width=6;
uint8_t font_spacing=1;
const uint8_t font_normal_width=6;
const uint8_t font_offset=33;
const uint8_t font_minecraftia[94][font_width]= {
const uint8_t font_normal_mean_width=5;
const uint8_t font_normal[94][font_normal_width]= { //minecraftia
{95,0,0,0,0,0}, // 33 !
{3,0,3,0,0,0}, // 34 "
{20,127,20,127,20,0}, // 35 #
@ -104,4 +107,106 @@ const uint8_t font_minecraftia[94][font_width]= {
{2,1,1,2,2,1}, // 126 ~
};
const uint8_t font_large_width=9;
const uint8_t font_large_offset=33;
const uint8_t font_large_mean_width=6;
const uint16_t font_large[94][9]= {
{0,0,0,1790,0,0,0,0,0}, // 33=!
{0,0,14,0,14,0,0,0,0}, // 34="
{0,272,2044,272,272,2044,272,0,0}, // 35=#
{0,796,1058,3107,1058,972,0,0,0}, // 36=$
{524,274,140,64,1568,2320,1544,0,0}, // 37=%
{896,1116,1058,1122,668,896,1120,0,0}, // 38=&
{0,0,0,8,6,0,0,0,0}, // 39='
{0,0,1016,1028,2050,0,0,0,0}, // 40=(
{0,0,2050,1028,1016,0,0,0,0}, // 41=)
{0,64,336,224,224,336,64,0,0}, // 42=*
{0,64,64,496,64,64,0,0,0}, // 43=+
{0,0,0,2048,1536,0,0,0,0}, // 44=,
{0,0,64,64,64,64,0,0,0}, // 45=-
{0,0,0,1536,0,0,0,0,0}, // 46=.
{0,1536,384,96,24,6,0,0,0}, // 47=/
{0,1020,1282,1218,1074,1034,1020,0,0}, // 48=0
{0,0,16,8,4,2046,0,0,0}, // 49=1
{0,1796,1154,1090,1058,1042,1036,0,0}, // 50=2
{0,516,1026,1058,1058,1058,988,0,0}, // 51=3
{0,96,80,72,68,2046,64,0,0}, // 52=4
{0,574,1058,1058,1058,1058,962,0,0}, // 53=5
{0,1016,1060,1058,1058,1058,960,0,0}, // 54=6
{0,2,2,1922,66,34,30,0,0}, // 55=7
{0,988,1058,1058,1058,1058,988,0,0}, // 56=8
{0,540,1058,1058,1058,1058,1020,0,0}, // 57=9
{0,0,0,1584,0,0,0,0,0}, // 58=:
{0,0,0,2048,1584,0,0,0,0}, // 59=;
{0,64,160,272,520,1028,0,0,0}, // 60=<
{0,160,160,160,160,160,160,0,0}, // 61==
{0,1028,520,272,160,64,0,0,0}, // 62=>
{0,12,2,1666,66,34,28,0,0}, // 63=?
{496,520,1156,1364,1364,1508,1288,240,0}, // 64=@
{0,2044,66,66,66,66,2044,0,0}, // 65=A
{0,2046,1058,1058,1058,1058,988,0,0}, // 66=B
{0,1020,1026,1026,1026,1026,516,0,0}, // 67=C
{0,2046,1026,1026,1026,516,504,0,0}, // 68=D
{0,2046,1058,1058,1058,1026,1026,0,0}, // 69=E
{0,2046,34,34,34,2,2,0,0}, // 70=F
{0,1020,1026,1026,1090,1090,964,0,0}, // 71=G
{0,2046,32,32,32,32,2046,0,0}, // 72=H
{0,1026,1026,2046,1026,1026,0,0,0}, // 73=I
{0,768,1024,1024,1024,1024,1022,0,0}, // 74=J
{0,2046,32,32,80,136,1798,0,0}, // 75=K
{0,2046,1024,1024,1024,1024,1024,0,0}, // 76=L
{2046,4,8,48,8,4,2046,0,0}, // 77=M
{0,2046,4,8,16,32,2046,0,0}, // 78=N
{0,1020,1026,1026,1026,1026,1020,0,0}, // 79=O
{0,2046,34,34,34,34,28,0,0}, // 80=P
{0,1020,1026,1026,1282,1538,4092,0,0}, // 81=Q
{0,2046,34,34,34,98,1948,0,0}, // 82=R
{0,524,1042,1058,1058,1090,900,0,0}, // 83=S
{2,2,2,2046,2,2,2,0,0}, // 84=T
{0,1022,1024,1024,1024,1024,1022,0,0}, // 85=U
{30,96,384,1536,384,96,30,0,0}, // 86=V
{2046,512,256,224,256,512,2046,0,0}, // 87=W
{0,1806,144,96,96,144,1806,0,0}, // 88=X
{6,24,32,1984,32,24,6,0,0}, // 89=Y
{0,1794,1154,1090,1058,1042,1038,0,0}, // 90=Z
{0,0,4094,2050,2050,0,0,0,0}, // 91=[
{0,6,24,96,384,1536,0,0,0}, // 92=Backslash
{0,0,2050,2050,4094,0,0,0,0}, // 93=]
{0,4,2,1,2,4,0,0,0}, // 94=^
{0,4096,4096,4096,4096,4096,4096,0,0}, // 95=_
{0,0,0,6,8,0,0,0,0}, // 96=`
{0,896,1104,1104,1104,1104,2016,0,0}, // 97=a
{0,2046,1040,1040,1040,1040,992,0,0}, // 98=b
{0,992,1040,1040,1040,1040,544,0,0}, // 99=c
{0,992,1040,1040,1040,1040,2046,0,0}, // 100=d
{0,992,1168,1168,1168,1168,736,0,0}, // 101=e
{0,32,2044,34,34,2,4,0,0}, // 102=f
{0,5088,9232,9232,9232,8720,8160,0,0}, // 103=g
{0,2046,16,16,16,16,2016,0,0}, // 104=h
{0,1040,1040,2036,1024,1024,0,0,0}, // 105=i
{0,6144,8192,8192,8192,8180,0,0,0}, // 106=j
{0,2046,128,128,128,320,1584,0,0}, // 107=k
{0,1026,1026,2046,1024,1024,0,0,0}, // 108=l
{2032,16,16,992,16,16,2016,0,0}, // 109=m
{0,2032,16,16,16,16,2016,0,0}, // 110=n
{0,992,1040,1040,1040,1040,992,0,0}, // 111=o
{0,16368,1040,1040,1040,1040,992,0,0}, // 112=p
{0,992,1040,1040,1040,1040,16368,0,0}, // 113=q
{0,2032,32,16,16,16,0,0,0}, // 114=r
{0,608,1168,1168,1168,1168,800,0,0}, // 115=s
{0,16,16,1020,1040,1040,0,0,0}, // 116=t
{0,1008,1024,1024,1024,1024,2032,0,0}, // 117=u
{48,192,768,1024,768,192,48,0,0}, // 118=v
{1008,1024,512,448,512,1024,1008,0,0}, // 119=w
{1040,544,320,128,320,544,1040,0,0}, // 120=x
{0,9200,9216,9216,9216,4608,4080,0,0}, // 121=y
{0,1552,1296,1168,1104,1072,1040,0,0}, // 122=z
{0,64,64,1980,2050,2050,0,0,0}, // 123={
{0,0,0,2014,0,0,0,0,0}, // 124=|
{0,2050,2050,1980,64,64,0,0,0}, // 125=}
{0,4,2,2,4,4,2,0,0}, // 126=~
};
#endif

View File

@ -65,13 +65,10 @@ public:
void setBuffer_byString(String data,String& error);
void setBuffer_byInt(String data,String& error);
void addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset);
void addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset, uint8_t pfont=0);
void setBuffer_Preset_Bumblebee();
void setBuffer_Preset_CTDO();
void setBuffer_Preset_Datamatrixctdo();
void setBuffer_Preset_1337();
void setBuffer_Preset_1359();
void loop_testDots();

View File

@ -0,0 +1,208 @@
#!/usr/bin/env python
#Script copied from .pio/libdeps/esp32doit-devkit-v1/Homie/scripts/ota_updater/ota_updater.py
#Changed to not add a "/" to the base topic (see function 'def base_topic_arg(s)')
from __future__ import division, print_function
import paho.mqtt.client as mqtt
import base64, sys, math
from hashlib import md5
# Global variable for total bytes to transfer
total = 0
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
if rc != 0:
print("Connection Failed with result code {}".format(rc))
client.disconnect()
else:
print("Connected with result code {}".format(rc))
client.subscribe("{base_topic}{device_id}/$state".format(**userdata)) # v3 / v4 devices
client.subscribe("{base_topic}{device_id}/$online".format(**userdata)) # v2 devices
print("Subscribe to")
print("{base_topic}{device_id}/$state".format(**userdata)) # v3 / v4 devices
print("{base_topic}{device_id}/$online".format(**userdata)) # v2 devices
print("Waiting for device to come online...")
# Called from on_message to print a progress bar
def on_progress(progress, total):
g_total = total
bar_width = 30
bar = int(bar_width*(progress/total))
print("\r[", '+'*bar, ' '*(bar_width-bar), "] ", progress, end='', sep='')
if (progress == total):
print()
sys.stdout.flush()
# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
global total
# decode string for python2/3 compatiblity
msg.payload = msg.payload.decode()
if msg.topic.endswith('$implementation/ota/status'):
status = int(msg.payload.split()[0])
if userdata.get("published"):
if status == 200:
on_progress(total, total)
print("Firmware uploaded successfully. Waiting for device to come back online.")
sys.stdout.flush()
elif status == 202:
print("Checksum accepted")
elif status == 206: # in progress
# state in progress, print progress bar
progress, total = [int(x) for x in msg.payload.split()[1].split('/')]
on_progress(progress, total)
elif status == 304: # not modified
print("Device firmware already up to date with md5 checksum: {}".format(userdata.get('md5')))
client.disconnect()
elif status == 403: # forbidden
print("Device ota disabled, aborting...")
client.disconnect()
elif (status > 300) and (status < 500):
print("Other error '" + msg.payload + "', aborting...")
client.disconnect()
else:
print("Other error '" + msg.payload + "'")
elif msg.topic.endswith('$fw/checksum'):
checksum = msg.payload
if userdata.get("published"):
if checksum == userdata.get('md5'):
print("Device back online. Update Successful!")
else:
print("Expecting checksum {}, got {}, update failed!".format(userdata.get('md5'), checksum))
client.disconnect()
else:
if checksum != userdata.get('md5'): # save old md5 for comparison with new firmware
userdata.update({'old_md5': checksum})
else:
print("Device firmware already up to date with md5 checksum: {}".format(checksum))
client.disconnect()
elif msg.topic.endswith('ota/enabled'):
if msg.payload == 'true':
userdata.update({'ota_enabled': True})
else:
print("Device ota disabled, aborting...")
client.disconnect()
elif msg.topic.endswith('$state') or msg.topic.endswith('$online'):
if (msg.topic.endswith('$state') and msg.payload != 'ready') or (msg.topic.endswith('$online') and msg.payload == 'false'):
return
# calcluate firmware md5
firmware_md5 = md5(userdata['firmware']).hexdigest()
userdata.update({'md5': firmware_md5})
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe("{base_topic}{device_id}/$implementation/ota/status".format(**userdata))
client.subscribe("{base_topic}{device_id}/$implementation/ota/enabled".format(**userdata))
client.subscribe("{base_topic}{device_id}/$fw/#".format(**userdata))
# Wait for device info to come in and invoke the on_message callback where update will continue
print("Waiting for device info...")
if ( not userdata.get("published") ) and ( userdata.get('ota_enabled') ) and \
( 'old_md5' in userdata.keys() ) and ( userdata.get('md5') != userdata.get('old_md5') ):
# push the firmware binary
userdata.update({"published": True})
topic = "{base_topic}{device_id}/$implementation/ota/firmware/{md5}".format(**userdata)
print("Publishing new firmware with checksum {}".format(userdata.get('md5')))
client.publish(topic, userdata['firmware'])
def main(broker_host, broker_port, broker_username, broker_password, broker_ca_cert, base_topic, device_id, firmware):
# initialise mqtt client and register callbacks
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
# set username and password if given
if broker_username and broker_password:
client.username_pw_set(broker_username, broker_password)
if broker_ca_cert is not None:
client.tls_set(
ca_certs=broker_ca_cert
)
# save data to be used in the callbacks
client.user_data_set({
"base_topic": base_topic,
"device_id": device_id,
"firmware": firmware
})
print("Base Topic:" +str(base_topic))
# start connection
print("Connecting to mqtt broker {} on port {}".format(broker_host, broker_port))
client.connect(broker_host, broker_port, 60)
# Blocking call that processes network traffic, dispatches callbacks and handles reconnecting.
client.loop_forever()
if __name__ == '__main__':
import argparse
print (sys.argv[1:])
parser = argparse.ArgumentParser(
description='ota firmware update scirpt for ESP8226 implemenation of the Homie mqtt IoT convention.')
# ensure base topic always ends with a '/'
def base_topic_arg(s):
s = str(s)
#if not s.endswith('/'):
# s = s + '/'
return s
# specify arguments
parser.add_argument('-l', '--broker-host', type=str, required=False,
help='host name or ip address of the mqtt broker', default="127.0.0.1")
parser.add_argument('-p', '--broker-port', type=int, required=False,
help='port of the mqtt broker', default=1883)
parser.add_argument('-u', '--broker-username', type=str, required=False,
help='username used to authenticate with the mqtt broker')
parser.add_argument('-d', '--broker-password', type=str, required=False,
help='password used to authenticate with the mqtt broker')
parser.add_argument('-t', '--base-topic', type=base_topic_arg, required=False,
help='base topic of the homie devices on the broker', default="homie/")
parser.add_argument('-i', '--device-id', type=str, required=True,
help='homie device id')
parser.add_argument('firmware', type=argparse.FileType('rb'),
help='path to the firmware to be sent to the device')
parser.add_argument("--broker-tls-cacert", default=None, required=False,
help="CA certificate bundle used to validate TLS connections. If set, TLS will be enabled on the broker conncetion"
)
# workaround for http://bugs.python.org/issue9694
parser._optionals.title = "arguments"
# get and validate arguments
args = parser.parse_args()
# read the contents of firmware into buffer
fw_buffer = args.firmware.read()
args.firmware.close()
firmware = bytearray()
firmware.extend(fw_buffer)
# Invoke the business logic
main(args.broker_host, args.broker_port, args.broker_username,
args.broker_password, args.broker_tls_cacert, args.base_topic, args.device_id, firmware)

View File

@ -45,8 +45,27 @@ void Image::setBuffer_solid(bool set)
flag_updating=true; //make update run
}
void Image::addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset)
void Image::addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset, uint8_t pfont)
{
uint8_t font_width;
uint8_t font_spacing;
switch (pfont){
case 0:
font_width=font_normal_width;
if (xoffset=255) { //centering?
xoffset=(COLUMNS-text.length()*(font_normal_mean_width+font_spacing))/2;
}
break;
case 1:
font_width=font_large_width;
if (xoffset=255) { //centering?
xoffset=(COLUMNS-text.length()*(font_large_mean_width+font_spacing))/2;
}
break;
}
uint8_t bufferxpos=xoffset;
for (uint8_t textpos=0;textpos<text.length();textpos++){
@ -59,7 +78,15 @@ void Image::addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset)
if (currentchar==' ') { //space
addBuffer=0; //empty
}else{
addBuffer=( (uint16_t)( font_minecraftia[(uint8_t)currentchar-font_offset][x] ) << yoffset);
switch (pfont) {
case 0:
addBuffer=( (uint16_t)( font_normal[(uint8_t)currentchar-font_offset][x] ) << yoffset);
break;
case 1:
addBuffer=( (uint16_t)( font_large[(uint8_t)currentchar-font_offset][x] ) << yoffset);
break;
}
if (addBuffer==0) {
emptycolumncounter++;
}else{
@ -160,95 +187,6 @@ backBuffer[74]=0b0000000000000000;
flag_updating=true; //make update run
}
void Image::setBuffer_Preset_CTDO() //CTDO
{
backBuffer[0]=0b0000000000000000;
backBuffer[1]=0b0000000000000000;
backBuffer[2]=0b0000000000000000;
backBuffer[3]=0b0000000000000000;
backBuffer[4]=0b0000000000000000;
backBuffer[5]=0b0000000000000000;
backBuffer[6]=0b0000000000000000;
backBuffer[7]=0b0000000111100000;
backBuffer[8]=0b0000001111111100;
backBuffer[9]=0b0000011111111110;
backBuffer[10]=0b0000111110111111;
backBuffer[11]=0b0001110000000111;
backBuffer[12]=0b0011110000000111;
backBuffer[13]=0b0011110000000111;
backBuffer[14]=0b0001111000000111;
backBuffer[15]=0b0000110000001111;
backBuffer[16]=0b0000000000000110;
backBuffer[17]=0b0000000000000000;
backBuffer[18]=0b0000000000000000;
backBuffer[19]=0b0000000000000000;
backBuffer[20]=0b0000000000000000;
backBuffer[21]=0b0000000000000110;
backBuffer[22]=0b0000000000001111;
backBuffer[23]=0b0000000000000111;
backBuffer[24]=0b0011000000000111;
backBuffer[25]=0b0111111100000111;
backBuffer[26]=0b0111111111111111;
backBuffer[27]=0b0011111111111111;
backBuffer[28]=0b0000001111111111;
backBuffer[29]=0b0000000000000111;
backBuffer[30]=0b0000000000000111;
backBuffer[31]=0b0000000000000111;
backBuffer[32]=0b0000000000001111;
backBuffer[33]=0b0000000000000110;
backBuffer[34]=0b0000000000000000;
backBuffer[35]=0b0000000000000000;
backBuffer[36]=0b0000000000000000;
backBuffer[37]=0b0000000000000000;
backBuffer[38]=0b0000000000000000;
backBuffer[39]=0b0000000000000110;
backBuffer[40]=0b0001100000001111;
backBuffer[41]=0b0011111111111111;
backBuffer[42]=0b0111111111111111;
backBuffer[43]=0b0111111111111111;
backBuffer[44]=0b1111111100001111;
backBuffer[45]=0b1110000000001111;
backBuffer[46]=0b1110000000001111;
backBuffer[47]=0b1110000000001110;
backBuffer[48]=0b1100000000001110;
backBuffer[49]=0b1110000000011110;
backBuffer[50]=0b1111100000011100;
backBuffer[51]=0b0111111111111000;
backBuffer[52]=0b0011111111110000;
backBuffer[53]=0b0000111111100000;
backBuffer[54]=0b0000000111000000;
backBuffer[55]=0b0000000000000000;
backBuffer[56]=0b0000000000000000;
backBuffer[57]=0b0000000000000000;
backBuffer[58]=0b0000000000000000;
backBuffer[59]=0b0000000000000000;
backBuffer[60]=0b0000000000000000;
backBuffer[61]=0b0000001111000000;
backBuffer[62]=0b0000011111110000;
backBuffer[63]=0b0000111111111000;
backBuffer[64]=0b0001111111111000;
backBuffer[65]=0b0011110000111100;
backBuffer[66]=0b0011100000011100;
backBuffer[67]=0b0011100000111110;
backBuffer[68]=0b0111100000011110;
backBuffer[69]=0b0011111001111100;
backBuffer[70]=0b0001111111111000;
backBuffer[71]=0b0000111111110000;
backBuffer[72]=0b0000011111100000;
backBuffer[73]=0b0000000000000000;
backBuffer[74]=0b0000000000000000;
flag_updating=true; //make update run
}
void Image::setBuffer_Preset_Datamatrixctdo() //Datamatrix ctdo.de
{
@ -334,169 +272,6 @@ backBuffer[74]=0b1111111111111111;
void Image::setBuffer_Preset_1337() //13:37
{
backBuffer[0]=0b1111111111111111;
backBuffer[1]=0b1111111111111111;
backBuffer[2]=0b1111111111111111;
backBuffer[3]=0b1111111111111111;
backBuffer[4]=0b1111111111111111;
backBuffer[5]=0b1111111111111111;
backBuffer[6]=0b1111111111111111;
backBuffer[7]=0b1111111111111111;
backBuffer[8]=0b1111111111111111;
backBuffer[9]=0b1111111111111111;
backBuffer[10]=0b1111111111111111;
backBuffer[11]=0b1111111111111111;
backBuffer[12]=0b1100111111100111;
backBuffer[13]=0b1100111111110111;
backBuffer[14]=0b1100111111110011;
backBuffer[15]=0b1100000000000011;
backBuffer[16]=0b1100000000000011;
backBuffer[17]=0b1100000000000011;
backBuffer[18]=0b1100111111111111;
backBuffer[19]=0b1100111111111111;
backBuffer[20]=0b1111111111111111;
backBuffer[21]=0b1111111111111111;
backBuffer[22]=0b1111111111111111;
backBuffer[23]=0b1110111111111111;
backBuffer[24]=0b1110111111110111;
backBuffer[25]=0b1100111111110111;
backBuffer[26]=0b1100111001110011;
backBuffer[27]=0b1100111001110011;
backBuffer[28]=0b1100111001110011;
backBuffer[29]=0b1110000000000111;
backBuffer[30]=0b1110000010000111;
backBuffer[31]=0b1111000111001111;
backBuffer[32]=0b1111111111111111;
backBuffer[33]=0b1111111111111111;
backBuffer[34]=0b1111111111111111;
backBuffer[35]=0b1111111111111111;
backBuffer[36]=0b1100011100011111;
backBuffer[37]=0b1100011100011111;
backBuffer[38]=0b1100011100011111;
backBuffer[39]=0b1111111111111111;
backBuffer[40]=0b1111111111111111;
backBuffer[41]=0b1111111111111111;
backBuffer[42]=0b1110111111111111;
backBuffer[43]=0b1110111111110111;
backBuffer[44]=0b1100111111110111;
backBuffer[45]=0b1100111001110011;
backBuffer[46]=0b1100111001110011;
backBuffer[47]=0b1100111001110011;
backBuffer[48]=0b1110000000000111;
backBuffer[49]=0b1110000010000111;
backBuffer[50]=0b1111000111001111;
backBuffer[51]=0b1111111111111111;
backBuffer[52]=0b1111111111111111;
backBuffer[53]=0b1111111111111111;
backBuffer[54]=0b1111111111110011;
backBuffer[55]=0b1111111111110011;
backBuffer[56]=0b1101111111110011;
backBuffer[57]=0b1100001111110011;
backBuffer[58]=0b1100000011110011;
backBuffer[59]=0b1111000000110011;
backBuffer[60]=0b1111111000000011;
backBuffer[61]=0b1111111110000011;
backBuffer[62]=0b1111111111100011;
backBuffer[63]=0b1111111111111111;
backBuffer[64]=0b1111111111111111;
backBuffer[65]=0b1111111111111111;
backBuffer[66]=0b1111111111111111;
backBuffer[67]=0b1111111111111111;
backBuffer[68]=0b1111111111111111;
backBuffer[69]=0b1111111111111111;
backBuffer[70]=0b1111111111111111;
backBuffer[71]=0b1111111111111111;
backBuffer[72]=0b1111111111111111;
backBuffer[73]=0b1111111111111111;
backBuffer[74]=0b1111111111111111;
flag_updating=true; //make update run
}
void Image::setBuffer_Preset_1359() //13:59
{
backBuffer[0]=0b1111111111111111;
backBuffer[1]=0b1111111111111111;
backBuffer[2]=0b1111111111111111;
backBuffer[3]=0b1111111111111111;
backBuffer[4]=0b1111111111111111;
backBuffer[5]=0b1111111111111111;
backBuffer[6]=0b1111111111111111;
backBuffer[7]=0b1111111111111111;
backBuffer[8]=0b1111111111111111;
backBuffer[9]=0b1111111111111111;
backBuffer[10]=0b1111111111111111;
backBuffer[11]=0b1111111111111111;
backBuffer[12]=0b1100111111100111;
backBuffer[13]=0b1100111111110111;
backBuffer[14]=0b1100111111110011;
backBuffer[15]=0b1100000000000011;
backBuffer[16]=0b1100000000000011;
backBuffer[17]=0b1100000000000011;
backBuffer[18]=0b1100111111111111;
backBuffer[19]=0b1100111111111111;
backBuffer[20]=0b1111111111111111;
backBuffer[21]=0b1111111111111111;
backBuffer[22]=0b1111111111111111;
backBuffer[23]=0b1110111111111111;
backBuffer[24]=0b1110111111110111;
backBuffer[25]=0b1100111111110111;
backBuffer[26]=0b1100111001110011;
backBuffer[27]=0b1100111001110011;
backBuffer[28]=0b1100111001110011;
backBuffer[29]=0b1110000000000111;
backBuffer[30]=0b1110000010000111;
backBuffer[31]=0b1111000111001111;
backBuffer[32]=0b1111111111111111;
backBuffer[33]=0b1111111111111111;
backBuffer[34]=0b1111111111111111;
backBuffer[35]=0b1111111111111111;
backBuffer[36]=0b1100011100011111;
backBuffer[37]=0b1100011100011111;
backBuffer[38]=0b1100011100011111;
backBuffer[39]=0b1111111111111111;
backBuffer[40]=0b1111111111111111;
backBuffer[41]=0b1111111111111111;
backBuffer[42]=0b1111111111111111;
backBuffer[43]=0b1110111100000011;
backBuffer[44]=0b1110111100000011;
backBuffer[45]=0b1100111100110011;
backBuffer[46]=0b1100111100110011;
backBuffer[47]=0b1100111100110011;
backBuffer[48]=0b1110011000110011;
backBuffer[49]=0b1110000001110011;
backBuffer[50]=0b1111000011111111;
backBuffer[51]=0b1111111111111111;
backBuffer[52]=0b1111111111111111;
backBuffer[53]=0b1111111111111111;
backBuffer[54]=0b1111111100011111;
backBuffer[55]=0b1110111000000111;
backBuffer[56]=0b1110111000000111;
backBuffer[57]=0b1100110011110011;
backBuffer[58]=0b1100110011110011;
backBuffer[59]=0b1100111011110011;
backBuffer[60]=0b1110011001100111;
backBuffer[61]=0b1110000000000111;
backBuffer[62]=0b1111000000001111;
backBuffer[63]=0b1111111111111111;
backBuffer[64]=0b1111111111111111;
backBuffer[65]=0b1111111111111111;
backBuffer[66]=0b1111111111111111;
backBuffer[67]=0b1111111111111111;
backBuffer[68]=0b1111111111111111;
backBuffer[69]=0b1111111111111111;
backBuffer[70]=0b1111111111111111;
backBuffer[71]=0b1111111111111111;
backBuffer[72]=0b1111111111111111;
backBuffer[73]=0b1111111111111111;
backBuffer[74]=0b1111111111111111;
flag_updating=true; //make update run
}
void Image::setBufferColumn(uint8_t _colnum, uint16_t _rowdata)
{
if (_colnum>=COLUMNS) {

View File

@ -28,6 +28,7 @@ bool orderHandler(const HomieRange& range, const String& value);
bool dataHandler(const HomieRange& range, const String& value);
bool controlHandler(const HomieRange& range, const String& value);
bool textHandler(const HomieRange& range, const String& value) ;
bool textLargeHandler(const HomieRange& range, const String& value) ;
bool clearFirstHandler(const HomieRange& range, const String& value);
bool optimizeClearHandler(const HomieRange& range, const String& value);
@ -47,12 +48,13 @@ void setup() {
Serial.begin(115200);
//Setup Homie
Homie_setFirmware("flipdot", "0.1.0");
Homie_setFirmware("flipdot", "0.1.2");
displayNode.advertise("preset").settable(presetHandler);
displayNode.advertise("data").settable(dataHandler);
displayNode.advertise("order").settable(orderHandler);
displayNode.advertise("control").settable(controlHandler);
displayNode.advertise("text").settable(textHandler);
displayNode.advertise("textlarge").settable(textLargeHandler);
settingsNode.advertise("clearfirst").settable(clearFirstHandler);
settingsNode.advertise("optimizeclear").settable(optimizeClearHandler);
settingsNode.advertise("optimizeset").settable(optimizeSetHandler);
@ -199,18 +201,9 @@ bool presetHandler(const HomieRange& range, const String& value) {
}else if(value == "bumblebee"){
flip.setBuffer_Preset_Bumblebee();
Homie.getLogger() << "Preset is bumblebee" << endl;
}else if(value == "ctdo"){
flip.setBuffer_Preset_CTDO();
Homie.getLogger() << "Preset is ctdo" << endl;
}else if(value == "datamatrixctdo"){
flip.setBuffer_Preset_Datamatrixctdo();
Homie.getLogger() << "Preset is datamatrixctdo" << endl;
}else if(value == "1337"){
flip.setBuffer_Preset_1337();
Homie.getLogger() << "Preset is 1337" << endl;
}else if(value == "1359"){
flip.setBuffer_Preset_1359();
Homie.getLogger() << "Preset is 1359" << endl;
}else if(value == "random"){
flip.setBuffer_random(50);
}else if(value == "uptime") {
@ -375,3 +368,18 @@ bool textHandler(const HomieRange& range, const String& value) {
return true;
}
bool textLargeHandler(const HomieRange& range, const String& value) {
Serial.print("Text Large payload="); Serial.println(value);
String row1=value;
Serial.print("Row="); Serial.println(row1);
flip.setBuffer_solid(0); //clear
flip.addBuffer_text(row1,255,0,1); //large font, centered
return true;
}

View File

@ -0,0 +1,12 @@
#!/bin/sh
# pip install paho-mqtt
# Enable OTA in config.json
# Do not forget to increment firmware version
if pio run ; then
echo "Build sucessful. Running ota update."
python ota_updater.py -l 10.0.0.1 -t "" -i "flipdot" .pio/build/esp32doit-devkit-v1/firmware.bin
else
echo "Build unsucessful. Not running ota update."
fi

View File

@ -5,29 +5,46 @@ screen = pygame.display.set_mode((640, 480))
clock = pygame.time.Clock()
done = False
persistance=False
fps=10
pixelsize=8
#font = pygame.font.SysFont("comicsansms", 72)
font = pygame.font.Font("Minecraftia-Regular.ttf", 8*pixelsize);
#fontname="font_normal"
#font = pygame.font.Font("Minecraftia-Regular.ttf", fontsize*pixelsize);
#fontsize=8
#pixelsW=6
#pixelsH=8
#offset=(0,0)
fontname="font_large"
fontsize=16
pixelsW=9
pixelsH=8*2
offset=(0,8)
font = pygame.font.Font("Sweet16mono.ttf", fontsize*pixelsize); # https://github.com/kmar/Sweet16Font
pixelsW=6
pixelsH=8
asciioffset=33
asciiend=126
ascii = asciioffset
fontname="font_minecraftia"
file = open("output.txt", "w") # write mode
file.write("const uint8_t font_width="+str(pixelsW)+";\n");
file.write("const uint8_t font_offset="+str(asciioffset)+";\n");
file.write("const uint8_t "+fontname+"_width="+str(pixelsW)+";\n");
file.write("const uint8_t "+fontname+"_offset="+str(asciioffset)+";\n");
#file.write("uint8_t "+fontname+"["+str(asciiend-asciioffset+1)+"]["+str(pixelsW)+"];\n")
file.write("const uint8_t "+fontname+"["+str(asciiend-asciioffset+1)+"]["+str(pixelsW)+"]= {\n")
file.write("const uint"+str(pixelsH)+"_t "+fontname+"["+str(asciiend-asciioffset+1)+"]["+str(pixelsW)+"]= {\n")
screen.fill((255, 255, 255))
screencleared=False
while not done:
for event in pygame.event.get():
@ -36,17 +53,20 @@ while not done:
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
done = True
screen.fill((255, 255, 255))
for y in range(pixelsH):
for x in range(pixelsW):
color=(250,250,250)
if (x+y)%2==0:
color=(200,200,200)
pygame.draw.rect(screen, color, pygame.Rect(pixelsize*x, pixelsize*y, pixelsize, pixelsize))
if not screencleared or not persistance:
screencleared=True
screen.fill((255, 255, 255))
for y in range(pixelsH):
for x in range(pixelsW):
color=(250,250,250)
if (x+y)%2==0:
color=(200,200,200)
pygame.draw.rect(screen, color, pygame.Rect(pixelsize*x, pixelsize*y, pixelsize, pixelsize))
text = font.render(chr(ascii), True, (0, 0, 0))
screen.blit(text,(0,-pixelsize*2))
screen.blit(text,(0+offset[0],-pixelsize*2+offset[1]))
print("ascii="+str(ascii)+" char="+chr(ascii))
'''
@ -90,7 +110,7 @@ while not done:
done=True
pygame.display.flip()
clock.tick(30)
clock.tick(fps)
file.write("};")
file.close()