Hi Florian,
Yes I am using emfile for our embedded file system. You can move it to the emFile forum. Just want to get some help with this issue is all. I have tried different stuff. Nothing seems to be working.
Best regards,
BMD
Hi Florian,
Yes I am using emfile for our embedded file system. You can move it to the emFile forum. Just want to get some help with this issue is all. I have tried different stuff. Nothing seems to be working.
Best regards,
BMD
Hi,
I am using an SD card as external memory to access images and text files. I have come across an issue that I do not quite understand how I could solve.
1. I have two text files A is 1.2kB and B is 1.5kB. When I access the A, I am able to read all the strings on there and when I try to access the B, I am not able to retrieve a few strings in the end.
2. I tried looking at both files and counting the characters with spaces and found out that I was able to read the same number of characters from file B as that of file A.
3. I tried doing it the other way around and I was able to read all the strings on File B and then File A.
I think I am having issues with memory allocation but I am not sure how to solve it.
If anyone here came across a similar issue and can give me some pointers, I'd much appreciate it.
Thank you,
BMD
Florian,
Thank you so much for your response.
1. So you are suggesting that I put my code which I am executing during NOTIFICATION_RELEASED also under WM_NOTIFICATION_MOVED_OUT???
2. Thank you for the suggestion. Will try that out.
Best regards,
BMD
Hi,
I have been working with emWin for quite sometime now. I am currently using buttons for some functionalities in my project. I have a couple of things I would like to get technical answers for.
1. I have found that sometimes even after the button is released, it wouldn't send NOTIFICATION_RELEASED. This happens only when the buttons are pressed at the edges. Is there a way to solve this problem?
2. I am displaying images and text boxes. Since the image isn't performing any functions, when pressed on it, creates a touch beep just like functioning part of the scree. Is there a way to disable this so I don't hear a beep when a non-functional object is pressed?
I look forward to hearing from you. Appreciate all the help.
Thanks and regards,
BMD
Sven,
Thank you so much for helping me out in figuring a better way to do things.
I tried to remove the automatic memory devices but that's causing bitmaps on buttons on each screen to flicker. Can you help me understand what could be causing this?
Thanks and regards,
BMD
Sven,
Appreciate the response. Thank you so much.
Also, when the image is touched, it clears the entire scree. The only I know to stop that from happening is to disable the image. Is there any other efficient way of doing this?
Best regards,
BMD
Sven,
Thank you for quick response. Please see attached code and Images I am currently using.
Best regards,
BMD
#include "DIALOG.h"
#include "FS.h"
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] =
{
{WINDOW_CreateIndirect, "", TOOLS_3_SCREEN_WINDOW, 0, 0, 320, 240, 0, 0, 0},
{HEADER_CreateIndirect, "", TOOLS_3_SCREEN_HEADER, 0, 0, 320, 40, 0, 0, 0},
{BUTTON_CreateIndirect, "", SERVICE_BUTTON, 25, 40, 185, 35, 0, 0, 0},
{BUTTON_CreateIndirect, "", ABOUT_BUTTON, 25, 90, 185, 35, 0, 0, 0},
{IMAGE_CreateIndirect, "", SERVICE_ICON, 260, 40, 35, 35, 0, 0, 0},
{IMAGE_CreateIndirect, "", ABOUT_ICON, 260, 90, 35, 35, 0, 0, 0}
};
static void _cbServiceIcon(WM_MESSAGE* pMsg)
{
if(pMsg->MsgId == WM_PAINT)
{
drawBMP_ExternalMemory("Service.bmp");
}// end if
else
{
IMAGE_Callback(pMsg);
}// end else
}// end function _cbServiceIcon
static void _cbAboutIcon(WM_MESSAGE* pMsg)
{
if(pMsg->MsgId == WM_PAINT)
{
drawBMP_ExternalMemory("About.bmp");
}// end if
else
{
IMAGE_Callback(pMsg);
}// end else
}// end function _cbAboutIcon
static void _cbTools3Screen(WM_MESSAGE* pMsg)
{
BUTTON_Handle hButton;
HEADER_Handle hHeader;
IMAGE_Handle hImage;
WM_HWIN hWin;
int Id;
int NCode;
hWin = pMsg->hWin;
switch(pMsg->MsgId)
{
case WM_PAINT:
// Draw the background. This is quite important because otherwise we would
// still see the child window although it gets deleted.
GUI_SetBkColor(GUI_BEIGE_BACKGROUND);
GUI_Clear();
break;
case WM_INIT_DIALOG:
// Initialize Tools header object.
hHeader = WM_GetDialogItem(hWin, TOOLS_3_SCREEN_HEADER);
WM_ClrHasTrans(hHeader);
HEADER_SetFont(hHeader, GUI_FONT_20B_1);
HEADER_SetTextColor(hHeader, GUI_BLACK);
HEADER_AddItem(hHeader, 320, "Tools", GUI_TA_CENTER);
// Initialize Service button object.
hButton = WM_GetDialogItem(hWin, SERVICE_BUTTON);
WM_ClrHasTrans(hButton);
BUTTON_SetText(hButton, "Service");
// Initialize About button object.
hButton = WM_GetDialogItem(hWin, ABOUT_BUTTON);
WM_ClrHasTrans(hButton);
BUTTON_SetText(hButton, "About");
// Initialize Service icon object.
hImage = WM_GetDialogItem(hWin, SERVICE_ICON);
WM_ClrHasTrans(hImage);
WM_SetCallback(hImage, _cbServiceIcon);
// Initialize About icon object.
hImage = WM_GetDialogItem(hWin, ABOUT_ICON);
WM_ClrHasTrans(hImage);
WM_SetCallback(hImage, _cbAboutIcon);
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
CurrentButton.Id = Id;
CurrentButton.State = CLICKED;
break;
case WM_NOTIFICATION_RELEASED:
CurrentButton.State = RELEASED;
WM_DeleteWindow(hWin);
switch(Id)
{
case SERVICE_BUTTON:
serviceScreen();
break;
case ABOUT_BUTTON:
aboutScreen();
break;
case BACK_3_BUTTON:
tools2Screen();
break;
case HOME_3_BUTTON:
mainScreen();
}// end switch
}// end switch
break;
default:
WM_DefaultProc(pMsg);
}// end switch
}// end function _cbTools3Screen
void tools3Screen(void)
{
// Check if recommended memory for the sample is available.
if(GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY)
{
return;
}// end if
// Use memory devices for all windows.
#if GUI_SUPPORT_MEMDEV
WM_SetCreateFlags(WM_CF_MEMDEV);
WM_EnableMemdev(WM_HBKWIN);
#endif
WM_MULTIBUF_Enable(TRUE); // Enable multibuffering prior to drawing the screen.
GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbTools3Screen, 0,
0, 0);
}// end function tools3Screen
Display More
#include "cytypes.h"
#include "FS.h"
#include "GUI.h"
int getDataBMP(void* p, const uint8** ppData, unsigned NumBytes, uint32 Off)
{
#define MAX_LINE_BYTES 640 // 320 pixels, 16-bit color.
static uint8 acBuffer[MAX_LINE_BYTES];
int16 NumBytesRead;
FS_FILE* pFile;
pFile = (FS_FILE *)p;
// Check buffer size.
if(NumBytes > MAX_LINE_BYTES)
{
NumBytes = MAX_LINE_BYTES;
}// end if
// Set file pointer to the required position.
FS_SetFilePos(pFile, Off, FS_FILE_BEGIN);
NumBytesRead = FS_FRead(acBuffer, 1, NumBytes, pFile); // Read data into buffer.
*ppData = (const uint8 *)acBuffer; // Set data pointer to the beginning of the buffer.
return NumBytesRead; // Return number of available bytes.
}// end function getDataBMP
void drawBMP_ExternalMemory(const char * filename)
{
FS_FILE * pFile;
pFile = FS_FOpen(filename, "rb"); // Open the file.
// Draw the bmp image by passing a pointer to the file handle and the GetData
// function.
GUI_BMP_DrawEx(getDataBMP, pFile, 0, 0);
FS_FClose(pFile); // Close the file.
}
Display More
Hi,
I have been using emWin for quite sometime now and haven't come across this before. On a window widget I am displaying few 2 buttons and 2 images. For some reason I see 2nd image in the background of first image. I checked the parameters and made sure I am not displaying the image twice. I have been using the same procedure on a couple other windows but haven't had any problems with it.
I'd really appreciate it if someone came across this problem and could help me or any suggestions will do.
Thank you,
BMD
Florian,
Thank you for looking into it. Really appreciate it.
But I am initializing emWin and emFile in another file before calling Maintask().
I have tried the XBF font sample. That works perfectly fine. But now I am trying to incorporate it into widgets and that doesn't seem to work at all whatsoever.
Best regards,
BMD
HI Florian,
Appreciate all your help. So I tried the following code but I don't see anything on the display whatsoever. Could you please tell me where I am possibly going wrong?
Thank you for all your help.
Best regards,
BMD
/*********************************************************************
* SEGGER Microcontroller GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2020 SEGGER Microcontroller GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V6.10 - Graphical user interface for embedded applications **
emWin is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File : GUI_SetExternalFont_XBF.c
Purpose : Sample that demonstrates how to create a custom font
from an external .XBF file
This sample supports both usage on a Windows PC as well
as usage on a target device using emFile.
Requirements: WindowManager - ( )
MemoryDevices - ( )
AntiAliasing - ( )
VNC-Server - ( )
PNG-Library - ( )
TrueTypeFonts - ( )
---------------------------END-OF-HEADER------------------------------
*/
#include "DIALOG.h"
#include "FS.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define FILE_PATH "Font.xbf"
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _GetData
*/
static int _GetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer)
{
FS_FILE * pFile;
int NumBytesRead;
pFile = (FS_FILE *)pVoid;
//
// Set file pointer to the requested position
//
if(FS_SetFilePos(pFile, Off, FS_FILE_BEGIN))
{
return 1; // Error
}
//
// Read font data
//
NumBytesRead = FS_FRead(pBuffer, 1, NumBytes, pFile);
if (NumBytesRead == 0)
{
return 1; // Error
}
if (NumBytesRead != NumBytes)
{
return 1; // Error
}
return 0; // Ok
}
/*********************************************************************
*
* _cbBk
*/
static void _cbBk(WM_MESSAGE * pMsg) {
FS_FILE * pFile;
static GUI_RECT Rect;
static GUI_FONT Font;
static GUI_XBF_DATA Data;
WM_HWIN hItem;
switch (pMsg->MsgId) {
case WM_CREATE:
//
// Create file handle
//
pFile = FS_FOpen(FILE_PATH, "rb");
//
// Create the font from the XBF file
// The font and xbf data will be loaded into the two variables created above.
// This data has to be valid during the time we use the font.
//
GUI_XBF_CreateFont((GUI_FONT*)&Font, &Data, GUI_XBF_TYPE_PROP_AA4_EXT, _GetData, &pFile);
hItem = BUTTON_CreateEx(10, 10, 160, 40, pMsg->hWin, WM_CF_SHOW, 0, 0);
BUTTON_SetFont(hItem, &Font);
BUTTON_SetText(hItem, "A button");
break;
case WM_PAINT:
GUI_SetBkColor(GUI_RED);
GUI_Clear();
break;
case WM_DELETE:
//
// Close file handle
//
FS_FClose(pFile);
//
// When the font is no longer currently used, it should be deleted.
//
GUI_XBF_DeleteFont(&Font);
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
//
// Init emWin.
//
GUI_Init();
WM_MULTIBUF_Enable(1);
WM_CreateWindowAsChild(0, 0, LCD_GetXSize(), LCD_GetYSize(), WM_HBKWIN, WM_CF_SHOW, _cbBk, 0);
// while (1) {
// GUI_Delay(100);
// }
}
/*************************** End of file ****************************/
Display More
Florian,
I have tried that example but for some reason it doesn't work on widgets.
Is there a way to set this external Font as default font or this function has to be called every time a new screen is drawn?
Best regards,
BMD
Hi,
Can anyone tell me if there is a workaround CreateFile for non-OS systems?
Thanks and regards,
BMD
Sven,
Thank you for your response. I got confused with things. It's sorted now. Appreciate your help.
Best regards,
BMD
Hi,
Could someone tell me what is the maximum number of buttons a window can have? what can be done if I have to have more than the maximum?
Any help is appreciated.
Thanks and regards,
BMD
Sven,
That works. Thank you so much.
Best regards,
BMD
Hi,
Is there a way to disable parent window or it's components when child window is active?
I can disable each widget separately. Just wondering if there is an efficient way to do this??
Any help is appreciated.
Thanks and regards,
BMD
Thank you , Florian
Hi,
I am trying to display a text box on top of an image widget. Is this possible using emWin?
Appreciate any pointers or help with this regard.
Thanks and regards,
BMD
Sven,
Much appreciate the response but I cannot use createfile because I am using a non OS system. Is there a way to get around that?
Thanks and regards,
BMD
Could someone help me understand if I am getting the steps right to display XBF font from SDcard in a widget. Or is there somewhere I can look at, as to how to implement XBF fonts on widgets?
Appreciate any help.
Thanks and regards,
BMD