[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 


This forum is read only and new users cannot register, please ask all new questions either using GitHub discussions, or in Arduino forum tagging @davetcc.

Set Cursor position changes after menu is displayed. RSS feed
Forum Index » tcMenu Arduinio library
Author Message
ScubaSteve


Joined: May 14, 2021
Messages: 30
Offline
Hi Dave.

I've got a strange one here. I boiled all of it down to some sample code, but I'll explain it and add some pictures before attaching the ZIP for a demo.

I'm doing an initial display grab to prevent the menu from appearing at boot. This screen would normally have status information, and a press of the encoder brings up the menu. After the timeout, the status screen should re-appear.

This is working, with an exception. The position of text on the screen is different after the first time the menu displays. Things appear to be moving "up".

To demonstrate, I'm displaying a series of underscores and dashes, right at the bottom of the display. The underscores are purposefully cut off, in order to demonstrate the movement.

-_-_-_-_ ...

At startup, you only see the dashes:

- - - - - ...

This is the expected behavior. After clicking the encoder and getting the menu, the screen will shift up some pixels, and you'll see the whole string:

-_-_-_-_

Is this a bug? Am I doing something wrong?

#include "tc-cursor_menu.h"
#include <Wire.h>
#include <Adafruit_GFX.h>
#define MENU_TIMEOUT 5

U8G2_SH1106_128X64_NONAME_F_HW_I2C gfx(U8G2_R0, U8X8_PIN_NONE, U8X8_PIN_NONE, U8X8_PIN_NONE);

void welcome(unsigned int encoderValue, RenderPressMode clicked) {
if (clicked) {
renderer.giveBackDisplay();
}

gfx.clearBuffer();
gfx.setCursor(5, 65);
gfx.print("_-_-_-_-_-_-_-_-_-_-_-");
gfx.sendBuffer();
}

void setup() {
Wire.begin();
gfx.begin();
setupMenu();
renderer.setResetCallback(onMenuBeingReset);
renderer.setResetIntervalTimeSeconds(MENU_TIMEOUT);
renderer.takeOverDisplay(welcome);
}

void onMenuBeingReset() {
renderer.takeOverDisplay(welcome);
}

void loop(void) {
taskManager.runLoop();
}
ScubaSteve


Joined: May 14, 2021
Messages: 30
Offline
Image "1" is the initial screen at power-on.

I pressed the encoder, which displayed the menu (Image "2").

When the menu times out, the same code that displayed Image 1 looks like this (Image "3").

Note the images seem to display in the opposite order.... go bottom up. =)
[Thumb - tcmenu-3.jpg]
 Filename tcmenu-3.jpg [Disk] Download
 Description After menu timeout.
 Filesize 460 Kbytes
 Downloaded:  46936 time(s)

[Thumb - tcmenu-2.jpg]
 Filename tcmenu-2.jpg [Disk] Download
 Description Menu after pressing encoder
 Filesize 487 Kbytes
 Downloaded:  47269 time(s)

[Thumb - tcmenu-1.jpg]
 Filename tcmenu-1.jpg [Disk] Download
 Description Boot
 Filesize 605 Kbytes
 Downloaded:  46423 time(s)

ScubaSteve


Joined: May 14, 2021
Messages: 30
Offline
Here's a zipfile for the demo.

Note I am not using the Title features in Mono/OLED and have "Border Size of Title", "Spacing between title and first item" set to 0, and "No Title" selected. I haven't experimented with the title feature to determine if using the title makes the issue different. I'll try and do that today.

TCMenu version is 2.13, Mac. Library stream is BETA, and is current.
 Filename tc-cursor.zip [Disk] Download
 Description No description given
 Filesize 9 Kbytes
 Downloaded:  46653 time(s)

ScubaSteve


Joined: May 14, 2021
Messages: 30
Offline
I can confirm the issue persists when using the title feature in the theme, as well. Below were the settings I tested with.
[Thumb - Screen Shot 2021-07-09 at 5.52.30 PM.png]
 Filename Screen Shot 2021-07-09 at 5.52.30 PM.png [Disk] Download
 Description No description given
 Filesize 245 Kbytes
 Downloaded:  46549 time(s)

davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
Quick reply from my mobile - in your take over display code you may need to reset if top left or baseline mode is being used with set cursor. That would adjust the position by about 1 line.
davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
I suspect that this is down to text alignment. Please check which text alignment you are expecting and ensure that you change to that mode in the take display callback. IE take a look at:

setFontPosBaseline
setFontPosBottom
setFontPosTop
setFontPosCenter


ScubaSteve


Joined: May 14, 2021
Messages: 30
Offline
Hi Dave.

Your initial reply was the pointer in the right direction. Adding setFontPosBottom() to my display takeover put things back the way they should be. This is the default setting.

It appears interacting with tcMenu results in that setting getting changed.

Might want to consider adding that in some of your takeover examples, something in release notes, or storing and restoring that setting?

Thanks for pointing me the right way!!

Steve
davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
Might want to consider adding that in some of your takeover examples, something in release notes, or storing and restoring that setting?


Agreed, I'll make it clearer in the documentation that when you take over the display, no assumptions should be made about the current state of every setting including the font position.
 
Forum Index » tcMenu Arduinio library
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.