I need to draw a curve according to the input point. Every time I input a point curve to the left, the GUI_AA_DrawLine method between the point and the point is used to draw a line, so the whole curve is not very smooth, not beautiful enough, I want to ask you There is no better way to handle it and achieve a smooth curve.
How to draw a smooth curve by point input
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
-
Hi,
Since version 5.44 of emWin it is possible to draw splines resulting in smooth curves.
Here is a short example:
C Source Code
- #include "GUI.h"
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define TEMP_MULTIPLY 5
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- static const int _axi[] = {
- 0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240
- };
- static const int _ayi[3][13] = {
- { 8, 7, 6, 7, 8, 11, 14, 16, 18, 16, 13, 9, 7 },
- { 7, 7, 6, 6, 8, 11, 14, 15, 15, 14, 13, 8, 7 },
- { 7, 6, 5, 4, 5, 8, 9, 12, 14, 12, 11, 8, 6 }
- };
- static GUI_COLOR _aColor[] = {
- GUI_RED, GUI_GREEN, GUI_LIGHTBLUE
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * _DrawSplines
- */
- static void _DrawSplines(void) {
- GUI_HMEM hSpline;
- U32 NumPoints;
- int aTemp[3][13];
- int i, j;
- for (i = 0; i < GUI_COUNTOF(_ayi); i++) {
- for (j = 0; j < GUI_COUNTOF(_ayi[i]); j++) {
- aTemp[i][j] = _ayi[i][j] * TEMP_MULTIPLY * -1;
- }
- NumPoints = GUI_COUNTOF(_axi);
- hSpline = GUI_SPLINE_Create(_axi, aTemp[i], NumPoints);
- GUI_SetColor(_aColor[i]);
- GUI_SetDrawMode(GUI_DM_TRANS);
- GUI_SPLINE_DrawAA(hSpline, 20, 100, 0);
- GUI_SPLINE_DrawAA(hSpline, 20, 150, 3);
- GUI_SetDrawMode(GUI_DM_NORMAL);
- GUI_SPLINE_DrawAA(hSpline, 20, 200, 0);
- GUI_SPLINE_DrawAA(hSpline, 20, 250, 3);
- GUI_SPLINE_Delete(hSpline);
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * MainTask
- */
- void MainTask(void) {
- GUI_Init();
- _DrawSplines();
- while (1) {
- GUI_Delay(100);
- }
- }
SvenPlease read the forum rules before posting.
Keep in mind, this is *not* a support forum.
Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
Should you be entitled to support you can contact us via our support system: segger.com/ticket/
Or you can contact us via e-mail. -
SEGGER - Schoenen wrote:
Hi,
Since version 5.44 of emWin it is possible to draw splines resulting in smooth curves.
Here is a short example:
C Source Code
- #include "GUI.h"
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define TEMP_MULTIPLY 5
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- static const int _axi[] = {
- 0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240
- };
- static const int _ayi[3][13] = {
- { 8, 7, 6, 7, 8, 11, 14, 16, 18, 16, 13, 9, 7 },
- { 7, 7, 6, 6, 8, 11, 14, 15, 15, 14, 13, 8, 7 },
- { 7, 6, 5, 4, 5, 8, 9, 12, 14, 12, 11, 8, 6 }
- };
- static GUI_COLOR _aColor[] = {
- GUI_RED, GUI_GREEN, GUI_LIGHTBLUE
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * _DrawSplines
- */
- static void _DrawSplines(void) {
- GUI_HMEM hSpline;
- U32 NumPoints;
- int aTemp[3][13];
- int i, j;
- for (i = 0; i < GUI_COUNTOF(_ayi); i++) {
- for (j = 0; j < GUI_COUNTOF(_ayi[i]); j++) {
- aTemp[i][j] = _ayi[i][j] * TEMP_MULTIPLY * -1;
- }
- NumPoints = GUI_COUNTOF(_axi);
- hSpline = GUI_SPLINE_Create(_axi, aTemp[i], NumPoints);
- GUI_SetColor(_aColor[i]);
- GUI_SetDrawMode(GUI_DM_TRANS);
- GUI_SPLINE_DrawAA(hSpline, 20, 100, 0);
- GUI_SPLINE_DrawAA(hSpline, 20, 150, 3);
- GUI_SetDrawMode(GUI_DM_NORMAL);
- GUI_SPLINE_DrawAA(hSpline, 20, 200, 0);
- GUI_SPLINE_DrawAA(hSpline, 20, 250, 3);
- GUI_SPLINE_Delete(hSpline);
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * MainTask
- */
- void MainTask(void) {
- GUI_Init();
- _DrawSplines();
- while (1) {
- GUI_Delay(100);
- }
- }
Sven
-
SEGGER - Schoenen wrote:
Hi,
Since version 5.44 of emWin it is possible to draw splines resulting in smooth curves.
Here is a short example:
C Source Code
- #include "GUI.h"
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define TEMP_MULTIPLY 5
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- static const int _axi[] = {
- 0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240
- };
- static const int _ayi[3][13] = {
- { 8, 7, 6, 7, 8, 11, 14, 16, 18, 16, 13, 9, 7 },
- { 7, 7, 6, 6, 8, 11, 14, 15, 15, 14, 13, 8, 7 },
- { 7, 6, 5, 4, 5, 8, 9, 12, 14, 12, 11, 8, 6 }
- };
- static GUI_COLOR _aColor[] = {
- GUI_RED, GUI_GREEN, GUI_LIGHTBLUE
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * _DrawSplines
- */
- static void _DrawSplines(void) {
- GUI_HMEM hSpline;
- U32 NumPoints;
- int aTemp[3][13];
- int i, j;
- for (i = 0; i < GUI_COUNTOF(_ayi); i++) {
- for (j = 0; j < GUI_COUNTOF(_ayi[i]); j++) {
- aTemp[i][j] = _ayi[i][j] * TEMP_MULTIPLY * -1;
- }
- NumPoints = GUI_COUNTOF(_axi);
- hSpline = GUI_SPLINE_Create(_axi, aTemp[i], NumPoints);
- GUI_SetColor(_aColor[i]);
- GUI_SetDrawMode(GUI_DM_TRANS);
- GUI_SPLINE_DrawAA(hSpline, 20, 100, 0);
- GUI_SPLINE_DrawAA(hSpline, 20, 150, 3);
- GUI_SetDrawMode(GUI_DM_NORMAL);
- GUI_SPLINE_DrawAA(hSpline, 20, 200, 0);
- GUI_SPLINE_DrawAA(hSpline, 20, 250, 3);
- GUI_SPLINE_Delete(hSpline);
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * MainTask
- */
- void MainTask(void) {
- GUI_Init();
- _DrawSplines();
- while (1) {
- GUI_Delay(100);
- }
- }
Sven
I will like to use the spline features and I tried your example on both custom hardware and an STM32 Demoboard (STM32F46G-DISCO) and in both cases it gives me a linker errors:
Source Code
- compiling splines_app.c...
- linking...
- STM32746G_DISCOVERY\Exe\Project.axf: Error: L6218E: Undefined symbol GUI_SPLINE_Create (referred from splines_app.o).
- STM32746G_DISCOVERY\Exe\Project.axf: Error: L6218E: Undefined symbol GUI_SPLINE_Delete (referred from splines_app.o).
- STM32746G_DISCOVERY\Exe\Project.axf: Error: L6218E: Undefined symbol GUI_SPLINE_DrawAA (referred from splines_app.o).
- Not enough information to list image symbols.
- Not enough information to list load addresses in the image map.
Emwin version is GUI_VERSION 54401.
Am I missing anything?
Thank you.
Mark -
Hi Mark,
That's interesting, I have checked V5.44a but the spline related functions are present.
Did you updated from an older version to 5.44a?
Maybe something went wrong in this process.
If can get hands on a newer version you should give that a try.
Regards,
SvenPlease read the forum rules before posting.
Keep in mind, this is *not* a support forum.
Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
Should you be entitled to support you can contact us via our support system: segger.com/ticket/
Or you can contact us via e-mail. -
SEGGER - Schoenen wrote:
Hi Mark,
That's interesting, I have checked V5.44a but the spline related functions are present.
Did you updated from an older version to 5.44a?
Maybe something went wrong in this process.
If can get hands on a newer version you should give that a try.
Regards,
Sven
First I've tried updating an older library version (5.40) to the last present on the STM32Cube_FW_F7_V1.15.0 which is the 5.44 mentioned before.
The result was I got those linker errors.
Then I've tried using your example on the "Animation example" on the same package STM32Cube_FW_F7_V1.15.0 on the STM32 Demoboard mentioned before.
The result was the same.
On the GUI.h file the prototype functions are present though.
I'll try downloading a newer version from emWin website then.
Regards,
Mark -
@SEGGER - Schoenen
Let me please know if there are any other ways to use an STM32 with a newer version of emWin libraries, at least to test those new features.
Thank you again.
Regards,
Mark -
I have the same issue. I need to use this feature on STM32F469iDiscovery. I´m using STM32Cube_FW_V1.24.2.
In the GUI.h i see the prototypes like this:
C Source Code
- /*********************************************************************
- *
- * Splines
- */
- GUI_HMEM GUI_SPLINE_Create (const int * px, const int * py, unsigned NumPoints);
- void GUI_SPLINE_Draw (GUI_HMEM hSpline, int x, int y);
- void GUI_SPLINE_Delete (GUI_HMEM hSpline);
- I16 GUI_SPLINE_GetY (GUI_HMEM hSpline, unsigned Index, float * py);
- unsigned GUI_SPLINE_GetXSize(GUI_HMEM hSpline);
- void GUI_SPLINE_DrawAA (GUI_HMEM hSpline, int x, int y, unsigned Width);
- /*********************************************************************
rm-none-eabi-gcc -o "Display.elf" @"objects.list" -l:STemWin_CM4_OS_wc32_ot_ARGB.a -mcpu=cortex-m4 -T"../STM32F469NIHx_FLASH.ld" --specs=nosys.specs -Wl,-Map="Display.map" -Wl,--gc-sections -static -L../Middlewares/ST/STemWin/Lib --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
STemWin/App/MainWindow.o: In function `_cbDialog':
/Users/christiansager/klanghabitat_quantum/firmware/firmware quantum/Display/Debug/../STemWin/App/MainWindow.c:121: undefined reference to `GUI_SPLINE_Create'
collect2: error: ld returned 1 exit status
make: *** [makefile:61: Display.elf] Error 1
Question:
1. How can i identify the exact version of the "STemWIN_CM4_OS_wc32_ot_ARGB.a"?
2. Is there a way to solve this issue?
3. Can i upgrade somehow the lib?
THX
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0