little help with ADS7843

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Sat May 18, 2013 1:42 pm

Yes Tectu I do have other code as I was only using the example code as a guide.
I have worked out that I can use GWIN and i am starting to redesign with it.
Just one thing, I cannot access the Doxygen pages on your site to get more info as I am tying to work with gwinDrawString is there a alternative location for the documentation?

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Sat May 18, 2013 1:45 pm

Just found it..
The link on the bottom of your GWIN Window page is,
http://chibios-gfx.com/doxygen/group___g_w_i_n.html
The address that worked is,
http://chibios-gfx.com/doxygen_master/g ... w_i_n.html
Thanks Google :roll:
I have had a look at it but how do I set the font so i can use gwinDrawString?

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: little help with ADS7843

Postby Tectu » Sat May 18, 2013 2:12 pm

Thank you very much for finding the dead link. I have replaced it with a link to the general doxygen page since we offer both - the latest stable and latest master doxygen build.

I am not sure if I understand your question about the font. The button docs show an example how to open a font and use it afterwards. It also describes that you have to enable the font in your gfxconf.h.
There some more demo code showing how to deal with fonts.


~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Sat May 18, 2013 2:16 pm

I have progressed a bit further I have set the font but when i try to draw string, Only the first letter of the string will appear.
I am using this,

Code: Select all

font = gdispOpenFont("Larger");
GW1 = gwinCreateWindow(NULL, 20, 10, 150, 460);
gwinSetColor(GW1, Black);
gwinSetBgColor(GW1, White);
gwinSetFont(GW1,font);
gwinClear(GW1);
gwinDrawString(GW1, 20, 150, "Dawe");

And it outputs only - D

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: little help with ADS7843

Postby Tectu » Sat May 18, 2013 2:18 pm

It looks like the rest of your string would be drawn outside of the window. You can check that by disabling the clipping in your gfxconf.h. Please do this just for testing. Make sure you enable it afterwards again.
The clipper doesn't draw anything that gets drawn outside of the corresponding widget are.


~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Sat May 18, 2013 2:29 pm

Ok,
I have disabled CLIP and the problem still persists, The "D" is drawn in the top left of the window so it should not be to large for the window area.
My full code is as follows,

Code: Select all

#include "ch.h"
#include "hal.h"
#include "gfx.h"
#include "chprintf.h"
static GButtonObject         gClear;
static GButtonObject         gSet;
static GListener         gl;
GHandle GW1, GW2;
static WORKING_AREA(SampleWA, 128);

/*
 * LED flashing thread.
 */
static msg_t SampleThread(void *arg) {
//Set Pad Mode's
palSetPadMode(GPIOC,15,PAL_MODE_OUTPUT_PUSHPULL);
font_t      font;
font = gdispOpenFont("Larger");
GW1 = gwinCreateWindow(NULL, 20, 10, 150, 460);
GW2 = gwinCreateWindow(NULL, 200, 100, 400, 370);
gwinSetColor(GW1, Black);
gwinSetBgColor(GW1, White);
gwinSetColor(GW2, White);
gwinSetBgColor(GW2, Blue);
gwinSetFont(GW1,font);
gwinClear(GW1);
gwinClear(GW2);
gwinFillCircle(GW1, 20, 200, 15);
gwinDrawString(GW1, 1, 1, "Dawe");
  while (TRUE) {
palSetPad(GPIOC,15);

     chThdSleepMilliseconds(500);
    palClearPad(GPIOC,15);
    chThdSleepMilliseconds(500);
  }
}
int main(void) {
   GSourceHandle         gs, gsClear, gsSet;
   GEvent            *pe;
   GEventMouse         *pem;
   GEventGWinButton      *peb;
   coord_t            swidth, sheight;
   GHandle            ghc, ghClear, ghSet;
   font_t            font;

   /* initialize the hardware and the OS */
   halInit();
   chSysInit();

   /* initialize the LCD */
   gdispInit();
   gdispClear(Black);

   /* Get the display dimensions */
   swidth = gdispGetWidth();
   sheight = gdispGetHeight();
   ghClear = ghSet = 0;

   /* choose our font */
   font = gdispOpenFont("Larger Double");

   /* Initialize the mouse */
   geventListenerInit(&gl);
   gs = ginputGetMouse(0);
    gdispClear(Black);
   /* create the "clear" button */
   ghClear = gwinCreateButton(&gClear, 660, 50, 100, 50, font, GBTN_NORMAL);
   gwinSetButtonText(ghClear, "Clear", FALSE);
   gsClear = gwinGetButtonSource(ghClear);
   geventAttachSource(&gl, gsClear, 0);
   gwinAttachButtonMouse(ghClear, 0);

   /* create the "set" button */
   ghSet = gwinCreateButton(&gSet, 660, 101, 100, 50, font, GBTN_NORMAL);
   gwinSetButtonText(ghSet, "Set", FALSE);
   gsSet = gwinGetButtonSource(ghSet);
   geventAttachSource(&gl, gsSet, 0);
   gwinAttachButtonMouse(ghSet, 0);

   /* draw the buttons */
   gwinButtonDraw(ghClear);
   gwinButtonDraw(ghSet);
    (void)chThdCreateStatic(SampleWA, sizeof(SampleWA),
                             NORMALPRIO, SampleThread, NULL);
   while(TRUE) {
      pe = geventEventWait(&gl, TIME_INFINITE);

      /* button pressed... */
      if (pe->type == GEVENT_GWIN_BUTTON) {
         peb = (GEventGWinButton *)pe;
         if (peb->button == ghSet)
            palSetPad(GPIOD, 12);
         else if (peb->button == ghClear)
            palClearPad(GPIOD, 12);
      }
   }

   return 0;
}

Also I have discovered that when I use the DrawString the code stops.
The buttons do not work and the output that I toggle also stops, But without the DrawString everything works..

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Sat May 18, 2013 2:42 pm

Ok the thread continues now the working area was not large enough and also the string is working..
Thanks

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: little help with ADS7843

Postby Tectu » Sat May 18, 2013 2:50 pm

Yeah, a too small stack size is the next issue. It can allocate enough memory to draw the D but not for the rest. Is now everything working? I guess you could fix your touchscreen as well?


~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Sat May 18, 2013 3:04 pm

Yes the touch screen is working your advice on the PAL mode's was the trick.
Things are all working now :D
Is there a way to make gwinFillArea color the same as the background not the foreground color so I can display as sample every second
I have got it to work like this,
gwinSetColor(GW1, White);
gwinFillArea(GW1,1, 30, 150, 10);
gwinSetColor(GW1, Black);
It would be nice to be able to dictate the fill color as in gdisp.

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Sat May 18, 2013 4:03 pm

Hay Techu,
How do i change the main thread stack size i cannot find any info..


Return to “LCD Driver and Graphic Framework”

Who is online

Users browsing this forum: No registered users and 3 guests