Jump to content

problem regarding display orientation


debayan

Recommended Posts

HI...i m new to this forum and this s my 1st post. I m using ugfx on a DM-LCD35RT along with a EMBEST ST32F4 DISCOVERY kit . My issue is when i m rotating the display with the command :

gdispControl(GDISP_CONTROL_ORIENTATION, (void*)GDISP_ROTATE_90);

the individual letters of the text of any created button is getting mirrored or flipped . For example if the button text in gh.text="pi", then on rotating by 90 degrees, the "p" becomes "q". I m not getting any clue from the header files to rectify this problem so plz help....

Thanks in advance..

Link to comment
Share on other sites

Hello debayan and welcome to the forum,

I just grabbed my embest board and flashed a working button example. Then I rotated the display and everything is still working nicely:

gdispSetOrientation(GDISP_ROTATE_90);

Could you please attach your code? On what release are you? I tried it out with the current master.

~ Tectu

Link to comment
Share on other sites

#include "gfx.h"
//#include "func.h"
static GListener gl;
static GHandle GW1,GB1,GB2,GR1,GR2,GC1;
static GHandle create_button(int x,int y,int w,int h)
{
GHandle GH;
GWidgetInit butt1;
butt1.customDraw = 0;
butt1.customParam = 0;
butt1.customStyle = 0;
//strcpy(rad1.text,t);
butt1.text="OPEN";
butt1.g.show = TRUE;
butt1.g.x = x;butt1.g.y = y;
butt1.g.width = w;butt1.g.height = h;
GH=gwinButtonCreate(NULL,&butt1);
return GH;
}
static GHandle create_radio(int x,int y,int w,int h)
{
GHandle GH;
GWidgetInit rad1;
rad1.customDraw = 0;
rad1.customParam = 0;
rad1.customStyle = 0;
//strcpy(rad1.text,t);
rad1.text="START";
rad1.g.show = TRUE;
rad1.g.x = x;rad1.g.y = y;
rad1.g.width = w;rad1.g.height = h;
GH=gwinRadioCreate(NULL,&rad1,0);
return GH;
}

static void create_console(int x,int y,int w,int h)
{
GWindowInit con1;
con1.x=x;con1.y=y;
con1.width=w;con1.height=h;
con1.show=TRUE;
GC1 = gwinConsoleCreate(NULL, &con1);
}
int main(void)
{
GEvent* pe;
uint8_t count=0;
char msg[8]="WELCOME";
const char name[6]="START";
const char name1[5]="STOP";
const char name2[5]="Back";
uint8_t i=0,j=120;
font_t font1,font2;
gfxInit();
//gdispSetOrientation(GDISP_ROTATE_90);
gdispClear(Lime);
font1 = gdispOpenFont("UI2 Double");
font2 = gdispOpenFont("Small");
GWindowInit w1;
w1.x=0;w1.y=0;
w1.width=320;w1.height=240;
GW1=gwinWindowCreate(NULL,&w1);
gwinSetBgColor(GW1,Red);
gwinClear(GW1);
gwinSetFont(GW1,font1);
gfxSleepMilliseconds(2000);
while(j<=225)
{
gwinDrawChar(GW1,j,100,msg[i]);
i++;
j+=15;
gfxSleepMilliseconds(500);
}
gfxSleepMilliseconds(1000);
// Set the widget defaults
gwinSetDefaultFont(font2);
gwinSetDefaultStyle(&BlackWidgetStyle, FALSE);
gdispClear(White);

// Attach the mouse input
gwinAttachMouse(0);
gdispClear(Red);
gdispSetOrientation(GDISP_ROTATE_90);
// create the widget

GB1=create_button(120,100,100,40);


geventListenerInit(&gl);
gwinAttachListener(&gl);
//geventListenerInit(&gl1);
//gwinAttachListener(&gl1);
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
switch(pe->type){
case GEVENT_GWIN_BUTTON:
if (((GEventGWinButton*)pe)->button == GB1) {
gdispClear(Purple);

GR1=create_radio(20,180,100,40);
gwinSetText(GR1,name,FALSE);
GR2= create_radio(180,180,100,40);
gwinSetText(GR2,name1,FALSE);
create_console(0,40,320,60);
gwinSetBgColor(GC1,Red);
gwinClear(GC1);
GB2=create_button(280,10,40,20);
gwinSetText(GB2,name2,FALSE);
}
if (((GEventGWinButton*)pe)->button == GB2) {
gwinDestroy(GR1);
gwinDestroy(GR2);
gwinDestroy(GC1);
gdispClear(Navy);
gwinRedraw(GB1);
}
break;
case GEVENT_GWIN_RADIO:
if(((GEventGWinRadio*)pe)->radio==GR1){
//if (palReadPad(GPIOA, GPIOA_BUTTON)){
//tdispSetCursor(40,40);
//gdispSetOrientation(GDISP_ROTATE_180);
count+=1;
gwinPrintf(GC1,"LEDs are toggling..and count=%d\n",count);
palSetPadMode(GPIOD, GPIOD_LED4, PAL_MODE_OUTPUT_PUSHPULL);
while(1){
palSetPad(GPIOD,GPIOD_LED4);
gfxSleepMilliseconds(500);
palClearPad(GPIOD,GPIOD_LED4);
gfxSleepMilliseconds(500);
if(((GEventGWinRadio*)pe)->radio==GR2)
break;
}
}
if(((GEventGWinRadio*)pe)->radio==GR2)
{
gwinPrintf(GC1,"Green led has stopped blinking..\n");
//palSetPadMode(GPIOD, GPIOD_LED6, PAL_MODE_OUTPUT_PUSHPULL);
palSetPad(GPIOD, GPIOD_LED4);
pe->type=0;
}
break;

default:
break;
}
}
return 0;
}




I am using the current release too..

Thanks..

Link to comment
Share on other sites

I've just run your code and it works well up tp this point: display changes orientation form 0 to 90 and button "OPEN" (create_button) is properly drawn. (After clicking the button app hangs, but maybe it's because I refused to provide memcpy to uGFX;)) I have newest uGFX and ChibiOS/RT possible. Do you get any strange warnings during compiling? Do you have your gfxconf.h and board files up to date?

Link to comment
Share on other sites

Yes, the code runs here too.

Also, I suggest you to use GIF images for animations like your "WELCOME" text, if you have the required amount of memory. Furthermore, you don't need to create a window all over screen. This is automatically done when you initialize GWIN.

You're also using the old fonts. Make sure you read the blog from time to time.

~ Tectu

Link to comment
Share on other sites

Hi...Actually the code is running well in my setup too but the issue is the button text is getting flipped whenever i m changing the orientation from 0 to 90. If you aren't facing such issues with the same code, then maybe i need an updated version. Plz suggest something.

Thanks...

Link to comment
Share on other sites

i dont get any warning during compilation and its pretty clean. I hav an updated gfxconf.h and board file. The only issue i face is flipping of the button text or rather of any gwidget, otherwise the program runs smoothly. Can u plz provide me a link of the latest UGFX release with all the new fonts and drivers?

Thanks..

Link to comment
Share on other sites

Hi....i downloaded the latest release of UGFX. Now although the button text issue is fixed but now my program hangs on clicking "OPEN" (as u said in an earlier post)...so how to fix dis??Plz help... :( ...bdw i use the same compiler u mentioned...

Thanks.....

Link to comment
Share on other sites

Now I see. The problem appears when you try to do this:

gdispSetOrientation(GDISP_ROTATE_90);
create_button(); // or whatever that draws button with text
gdispSetOrientation(GDISP_ROTATE_0);

Tectu: what should be done/executed to handle this type of operation properly? Some gwinResize/gwinRedraw functions maybe?

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

As i said in an earlier post, my code is still hanging when i change the display orientation from 0 to 90. Although the button is rotating nicely but the code is getting hanged at a click of the button. It would be very nice if anybody could help me. :)

Thanks & Regards...

Link to comment
Share on other sites

  • 2 weeks later...

This smells of being a stack issue. Try increasing the size of your runtime stack.

Looking at the code fragment below however, it looks like you are rotating to 90, performing some operations and then rotating back to 0.

If so, this may have all sorts of strange effects as the window has been created in one orientation but is being operated in a different orientation. This is definitely an untested (and probably unsupported). In general, gwin windows should be operated in the same orientation that they are created.

Link to comment
Share on other sites

Your original font problem likely stems from a bug in the GDISP driver for the EMBEST board with bitmap displaying.

When in 90 degree mode it is likely that the bitmap routines are not rotating bitmap displays correctly.

The new font code does not use bitmap routines and so the problem has "appeared" to go away with the new font code. It will still exhibit however if you try to display any bitmaps.

Tectu, can you please test bitmaps on the EMBEST in the rotated configuration as I don't have this type of hardware?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...