Jump to content

tubbutec

Members
  • Content Count

    18
  • Joined

  • Last visited

About tubbutec

  • Rank
    Newbie

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Had not seen vsnprintg! thanks
  2. An other small contribution to ugfx. This function is a sprintf wrapper for GWidget objects. It automatically allocates the memory needed for the formatted text. Can be used to display values in labels, in custom draw routines which display the current slider value, etc.... I use this with ARM-GCC in C99 mode, no idea if this compiles on other platforms... Example: int val = 100; gwinPrintfSetText(ghLabel1,"The value is: %d", val); Code: #include <stdarg.h> #define gw ((GWidgetObject *)gh) void gwinPrintfSetText(GHandle gh, char * fmt,...) { if (!(gh->flags & GWIN_FLG_WIDGET)) return; // Dispose of the old string if ((gh->flags & GWIN_FLG_ALLOCTXT)) { gh->flags &= ~GWIN_FLG_ALLOCTXT; if (gw->text) { gfxFree((void *)gw->text); gw->text = ""; } } // Alloc the new text char *str; va_list va; va_start (va, fmt); int size = vsnprintf(NULL, 0, fmt, va); //determine size used by printf if ((str = gfxAlloc(size+1))) { gh->flags |= GWIN_FLG_ALLOCTXT; vsprintf(str, fmt, va); } gw->text = (const char *)str; va_end (va); _gwinUpdate(gh); }
  3. tubbutec

    Missing events

    Thanks for the great support, Will try to use a simple event queue side by side with the existing ugfx event system
  4. tubbutec

    Missing events

    Hi, thanks a lot for this clarification. Here is a typical example in my application: I am using hardware buttons which send events when pressed and released. I am not using the toggle driver, but a driver derived from it. If I now press two or more buttons simultaneously, sometimes not all of the events will be received. An other example is a modified list widget, which sends events while (smooth) scrolling. Would you say I am misusing the GEVENT module here? In previous applications I used a very simple fixed size FIFO event queue to prevent these issues, but here my events only had a size of one byte. I understand that would probably not be practical with GEVENT.. Thanks a lot!
  5. tubbutec

    Missing events

    Hi, in my application I use the ugfx event system and often notice that an event is missing. My understanding is that if a new event occurs before the old one was processed it overrides the old event. Unfortunately this is quite fatal for my application. How can I prevent this? Do I have to implement some kind of event queue? Or can the sender at least detect somehow that there is an unprocessed event and send the new one later? thanks
  6. No update, I am still using the driver I posted
  7. that sounds promising, thanks a lot!
  8. Hi, when writing extensions to ugfx - be it a custom draw routine, or a new gdisp function - I often encountered the following problem. Usually I would put my own code into separate files and not touch the ugfx code at all. This allows to easily update ugfx, while all the custom stuff remains untouched. I believe this is the intended behaviour. However in the functions I write I often would like to access functions which already exist in ugfx, but are declared static so it is not accessible from outside the file. Copying these functions and place them in my own file seems to be wasteful. I wonder what the recommended procedure is in such a case? For example in my gdispGFillStringBoxAutoScale function (see other thread) I needed to access functions from gdisp.c and gdisp_fonts.c. An other example is a custom draw routine for gwinSlider which uses SliderCalcPosFromDPos I came up with different solutions, but they all require a modification of the ugfx source. But maybe there is an obvious way I did not think about? 1) Remove 'static' from the original code and access the function with 'external' 2) Place an include hook at the end of all ugfx files. Here the user can include additional files which are then in scope of the ugfx file. This however does not allow to use functions from different ugfx flies.. thanks a lot !
  9. Hi, I have a little attribution to ugfx. This function draws a text in a given box, similar to gdispGFillStringBox, but the optimal font is chosen so the text fits into the box with the least lines. The user can select a subset of fonts by passing a font name with a wildcard in place of the size. Example 'DejaVuSans*' This function must be placed in gdisp.c and gdisp.h as it uses static functions declared there.One must also place a copy of 'matchfont2' function (from gdisp_font.c) in gdisp.c, since it is declared static as well. I hope someone can make use of this and I am of course looking forward to comments. If anyone is interested: I also have a version of this that saves the wrapping parameters, so faster redraw is possible... gdisp.h /** \brief Draws a string vertically centered within the specified box. The font size is chosen to make sure the whole text fits in the box * \pre GDISP_NEED_TEXT and GDISP_NEED_TEXT_WORDWRAP must be TRUE in your gfxconf.h * \note This uses word wrap to find the largest font to determine how many lines are needed. Fonts are passed using their short name with wildcard * * instead of the number. e.g.: DejaVuSans* * Text will not be rendered if it could not be fitted inside the specified box * * \param g The display to use * \param x,y The position for the text * \param cx,cy The width and height of the box * \param str The string to draw * \param fontNames Short name of fonts to use + wildcard * * \param color The color to use * \param bgcolor The background color to use * \param justify Justify the text left, center or right within the box * \return bool_t Returns TRUE if the text could be fitted inside the box, FALSE otherwise * */ #if GDISP_NEED_TEXT_WORDWRAP bool_t gdispGFillStringBoxAutoScale(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, const char* fontNames, color_t color, color_t bgcolor, justify_t justify); #define gdispFillStringBoxAutoScale(x,y,cx,cy,s,f,c,b,j) gdispGFillStringBoxAutoScale(GDISP,x,y,cx,cy,s,f,c,b,j) #endif //NEEDS_WORDWRAP #if GDISP_NEED_TEXT_WORDWRAP bool_t gdispGFillStringBoxAutoScale(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, const char* fontNames, color_t color, color_t bgcolor, justify_t justify) { wrapParameters_t wrapParameters; font_t resFont = 0; uint16_t resLines = 0; MUTEX_ENTER(g); g->p.cx = cx; g->p.cy = cy; g->t.clipx0 = g->p.x = x; g->t.clipy0 = g->p.y = y; g->t.clipx1 = x+cx; g->t.clipy1 = y+cy; g->t.color = color; g->t.bgcolor = g->p.color = bgcolor; TEST_CLIP_AREA(g) { // background fill fillarea(g); //get available fonts const struct mf_font_list_s *fp = mf_get_font_list(); for(;fp ;fp = fp->next) //iterate over all fonts { if((fp->font->line_height <= cy) && matchfont2(fontNames,fp->font->short_name)) { // Count the number of lines needed by this font uint16_t nbrLines = 0; mf_wordwrap(fp->font, cx, str, mf_countline_callback, &nbrLines); if(cy / nbrLines >= fp->font->line_height) //is there space for this font? { //find the largest fitting font if((resFont == 0) || (fp->font->line_height > resFont->line_height)) { resFont = fp->font; resLines = nbrLines; } } } } if(!resFont) //found no font that fits all the text in this area return FALSE; /* Select the anchor position */ switch(justify) { case justifyCenter: x += (cx + 1) / 2; break; case justifyRight: x += cx; break; default: // justifyLeft x += resFont->baseline_x; break; } /* Render */ wrapParameters.x = x; wrapParameters.y = y; wrapParameters.font = resFont; wrapParameters.justify = justify; wrapParameters.g = g; g->t.font = resFont; wrapParameters.y += (cy+1 - resLines*resFont->height)/2; mf_wordwrap(resFont, cx, str, mf_fillline_callback, &wrapParameters); } autoflush(g); MUTEX_EXIT(g); return TRUE; } #endif //NEEDS_WORDWRAP /From gdisp_font.c, can not access, because it is static so there is a copy here.. static bool_t matchfont2(const char *pattern, const char *name) { while(1) { switch (pattern[0]) { case '*': if (name[0] == 0) return pattern[1] == 0; if (pattern[1] == name[0]) pattern++; else name++; break; case 0: return name[0] == 0; default: if (name[0] != pattern[0]) return FALSE; pattern++; name++; break; } } }
  10. Just realized there is a fully working cygwin toolchain coming with ugfx-studio - used it and it works. Leaving this thread here for reference..
  11. Hi, I am trying to build ugfx on Win7 (64bit) and followed the guide in the wiki: http://wiki.ugfx.org/index.php/Your_First_Compile_-_Windows Could not find the exact packages mentioned in the wiki (I guess they are called differently now). The gcc version closest to the one mentioned in the makefile I could download using the installer was i686-w64-mingw32-gcc instead of i686-pc-mingw32-gcc changed the makefile accordingly. The code builds, but the linker shows the following error: Linking .build/testProject.exe /cygdrive/c/Users/280grad/AppData/Local/Temp/cckDx1MV.ltrans0.ltrans.o:cckDx1MV.ltrans0.o:(.text+0x2380): multiple definition of `main' /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):/usr/src/debug/mingw64-i686-runtime-4.0.6-1/crt/crt0_c.c:17: first defined here /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o): In function `main': /usr/src/debug/mingw64-i686-runtime-4.0.6-1/crt/crt0_c.c:18: undefined reference to `WinMain@16' collect2: error: ld returned 1 exit status make: *** [../uGFX/tools/gmake_scripts/compiler_gcc.mk:284: .build/testProject.exe] Error 1 I tried both the 32bit and 64bit version of cygwin, but with the same result. Any help would be very much apprechiated Thanks a lot
  12. Thanks a lot for the insight. (and by the way thanks for developing this great library!
  13. Hi, had a look at the gfxSleepMicroseconds which is used by some drivers initialisation code. I believe the resolution is not in µs, in fact I would guess the actual delay for any value below 1000µs is a constant very small delay. This might actually cause troubles, if a small delay below 1ms is needed... from gos_x_threads.c: void gfxSleepMicroseconds(delaytime_t ms) { systemticks_t starttm, delay; // Safety first switch (ms) { case TIME_IMMEDIATE: return; case TIME_INFINITE: while(1) gfxYield(); return; } // Convert our delay to ticks delay = gfxMillisecondsToTicks(ms/1000); starttm = gfxSystemTicks(); do { gfxYield(); } while (gfxSystemTicks() - starttm < delay); } I don't have a good solution to create µs delays (yet), but the function is kind of misleading as it suggests it is able to perform µs delays...
  14. Probably the most important info here: The existing FT5x06 driver is fully compatible with the FT6x06 (or at least with the FT6206 I tested). Added a few register defines from the data sheet which are however currently not used by the driver, and changed 'FT5x06' to 'FT6x06' everywhere. Certainly not the greatest contribution, but maybe some find this helpful... FT6x06 driver.zip
  15. Hi I am working on an implementation of a keyboard matrix input. It works and I would like to contribute it to ugfx, but as I am very new to its architecture and don't understand every aspect, I am sure some things need to be changed... The driver takes care of selecting row lines, reading the corresponding column. It performs debouncing and manages the event stuff. Limitations so far: -Only one instance is supported. -Maximum column width is 8, but this can be changed easily by replacing a uint8_t with an uint16_t Functions select_row(uint8_t row) deselect_row(uint8_t row) read_column() need to be defined in the board file, I also attached an example which is running on my STM32F4 I do have a couple of questions: (1) I have some defines that contain the number of rows and columns in the matrix: #define KEY_MATRIX_ROWS 8 #define KEY_MATRIX_COLS 8 Naturally I would place this into the board file, as this is very board specific, but it is also needed in the high level driver (key_matrix.c) Which is the right place to define these constants? (2) Did I correctly implement the event handling? it does work, but it is all very new to me.. Thanks a lot and I hope someone else can use this ugfx_key_matrix_early_beta.zip
×
×
  • Create New...