Register / Login  |  Desktop view  |  Jump to bottom of page

tcMenu Arduinio library » Set Cursor position changes after menu is displayed.

Author: ScubaSteve
09/07/2021 20:45:03
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();
}

Author: ScubaSteve
09/07/2021 20:50:31
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
Description After menu timeout.
Filesize 460 Kbytes
Downloaded 46936 time(s)
[Disk] Download

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

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


Author: ScubaSteve
09/07/2021 20:59:02
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
Description No description given
Filesize 9 Kbytes
Downloaded 46653 time(s)
[Disk] Download


Author: ScubaSteve
09/07/2021 21:54:19
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
Description No description given
Filesize 245 Kbytes
Downloaded 46549 time(s)
[Disk] Download


Author: davetcc
10/07/2021 09:14:49
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.

Author: davetcc
11/07/2021 15:38:42
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



Author: ScubaSteve
12/07/2021 22:08:16
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

Author: davetcc
14/07/2021 08:31:53
 
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.




Register / Login  |  Desktop view  |  Jump to top of page