Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
gemu2015 committed Jan 13, 2024
1 parent fbc314e commit f3b0b50
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/lib_display/Xlatb_RA8876-gemu-1.0/RA8876.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "driver/spi_master.h"
#endif

#include "tasmota_options.h"

#undef SPRINT
#define SPRINT(A) {char str[32];sprintf(str,"val: %d ",A);Serial.println((char*)str);}

Expand Down Expand Up @@ -147,11 +149,14 @@ enum ExternalFontFamily
typedef uint8_t FontFlags;
#define RA8876_FONT_FLAG_XLAT_FULLWIDTH 0x01 // Translate ASCII to Unicode fullwidth forms


#ifndef RA8876_SPI_SPEED
// 1MHz. TODO: Figure out actual speed to use
// Data sheet section 5.2 says maximum SPI clock is 50MHz.
//#define RA8876_SPI_SPEED 10000000
#define RA8876_SPI_SPEED 25000000
//#define RA8876_SPI_SPEED 10000000
//#define RA8876_SPI_SPEED 25000000
#define RA8876_SPI_SPEED 40000000
#endif

// With SPI, the RA8876 expects an initial byte where the top two bits are meaningful. Bit 7
// is A0, bit 6 is WR#. See data sheet section 7.3.2 and section 19.
Expand Down
71 changes: 71 additions & 0 deletions pio-tools/grepmodule-firmware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Import("env")

import os
import shutil
import tasmotapiolib
import binascii


#MODULE_SYNC = 0x55aaFC4A

if env["PIOPLATFORM"] != "espressif32" :

def grep_module(source, target, env):
#print("searching binary for module ")
# create string with location and file names based on variant
bin_file = tasmotapiolib.get_final_bin_path(env)
dir_path = os.path.dirname(bin_file)

start = 0
size = 0
with open(bin_file, "rb") as fp:
while (msync := fp.read(4)):
if start == 1:
size += 4

if start == 1:
fwp.write(msync)

if msync[0] == 0x4a and msync[1] == 0xfc and msync[2] == 0xaa and msync[3] == 0x55:
xarch = fp.read(4)
arch = int.from_bytes(xarch, "little")
xtype = fp.read(4)
type = int.from_bytes(xtype, "little")
if arch == 0 and type <= 4:
#print("found start sync")
start = 1
dummy = fp.read(4)
xname = fp.read(16)
fname = xname.decode('ascii')
name = fname.replace('\x00','')
mod_file = dir_path + "/" + name + ".bin"
if os.path.isfile(mod_file):
os.remove(mod_file)
fwp = open(mod_file, "wb")
fwp.write(msync)
fwp.write(xarch)
fwp.write(xtype)
fwp.write(dummy)
fwp.write(xname)
size += 28

if msync[0] == 0x55 and msync[1] == 0xaa and msync[2] == 0xfc and msync[3] == 0x4a:
start = 2
size += 4
#print("found end sync")
# set module size
fwp.seek(40)
sizeb = size.to_bytes( 4, "little" )
fwp.write(sizeb)
fwp.close()
break


if start == 2:
print("extracted module: "+name)
if size > 8192:
print("module size error")


#if not tasmotapiolib.is_env_set(tasmotapiolib.DISABLE_BIN_GZ, env):
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [grep_module])

0 comments on commit f3b0b50

Please sign in to comment.