From 72b953b354bd9ab23d29bb3d6921e1ac66e0f9e6 Mon Sep 17 00:00:00 2001 From: Black Coffee Date: Mon, 3 Oct 2022 17:18:53 +0100 Subject: [PATCH] Got basic dashboard layout working --- .../gerty/templates/gerty/index.html | 6 ++++ lnbits/extensions/gerty/views_api.py | 29 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lnbits/extensions/gerty/templates/gerty/index.html b/lnbits/extensions/gerty/templates/gerty/index.html index a59bf15d..d341ce98 100644 --- a/lnbits/extensions/gerty/templates/gerty/index.html +++ b/lnbits/extensions/gerty/templates/gerty/index.html @@ -175,6 +175,11 @@

Use the toggles below to control what your Gerty will display

+ + = enabled_screen_count) else p + 1; @@ -170,6 +171,8 @@ async def get_screen_text(screen_num: int, screens_list: dict, gerty): logger.debug('screen_slug') logger.debug(screen_slug) # text = [] + if screen_slug == "dashboard": + text = await get_dashboard(gerty) if screen_slug == "lnbits_wallets_balance": text = await get_lnbits_wallet_balances(gerty) elif screen_slug == "fun_satoshi_quotes": @@ -208,6 +211,28 @@ async def get_screen_text(screen_num: int, screens_list: dict, gerty): text = await get_placeholder_text() return text +# Get the dashboard screen +async def get_dashboard(gerty): + text = [] + # XC rate + text.append(get_text_item_dict("19,255", 40, 145, 161)) + text.append(get_text_item_dict("BTCUSD price", 15, 155, 199)) + # balance + text.append(get_text_item_dict("Alice's wallet balance", 15, 524, 50)) + text.append(get_text_item_dict("102,101", 40, 524, 126)) + text.append(get_text_item_dict("Bob's wallet balance", 15, 524, 211)) + text.append(get_text_item_dict("102", 40, 524, 286)) + + # Mempool fees + text.append(get_text_item_dict("756,885", 40, 115, 416)) + text.append(get_text_item_dict("Current block height", 15, 115, 456)) + + # difficulty adjustment time + text.append(get_text_item_dict("7 days, 2 hours, 0 minutes", 15, 514, 390)) + text.append(get_text_item_dict("until next difficulty adjustment", 12, 514, 420)) + + return text + async def get_lnbits_wallet_balances(gerty): # Get Wallet info @@ -290,10 +315,10 @@ def get_text_item_dict(text: str, font_size: int, x_pos: int = None, y_pos: int # wrap the text wrapper = textwrap.TextWrapper(width=line_width) word_list = wrapper.wrap(text=text) - logger.debug("number of chars = {0}".format(len(text))) + # logger.debug("number of chars = {0}".format(len(text))) multilineText = '\n'.join(word_list) - logger.debug("number of lines = {0}".format(len(word_list))) + # logger.debug("number of lines = {0}".format(len(word_list))) # logger.debug('multilineText') # logger.debug(multilineText)