cancel
Showing results for 
Search instead for 
Did you mean: 

Rendering frequency spectrum

Petr3
Associate III

Hello,

i want to render frequency spectrum FFT in the small area of screen and handle touch in this area. This should be done by some custom widget/container. Can you help me how to do it?

 

Best Regards,

Petr

12 REPLIES 12

Hello @Petr3 ,

 

I assume you put your FFT graph inside a custom container.
You can just call

setTouchable(true);

in the setupScreen function of that custom container to enable touch on it.
This way you will be able to use the handleDragEvent and HandleClickEvent.

If you want to see how to use these 2 functions, have a look at this custom container example .

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

Hello @Petr3 ,

 

Have you been able to move forward on your project?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
Petr3
Associate III

Hello @GaetanGodart ,

yes a little bit. I created some space for dynamic bitmaps in the third bank of my SDRAM(in the second bank it doesn't work probably due to some TouchGFX protection/usage, screen buffer is located in the first bank):

 

FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
    : FrontendApplicationBase(m, heap)
{
#ifdef SIMULATOR
    const uint32_t cacheSize = 0x100000; //1 MB, as example
    uint16_t* const cacheStartAddr = (uint16_t*)malloc(cacheSize);
    Bitmap::setCache(cacheStartAddr, cacheSize, 4);
#else
    // Place cache start address in SDRAM at address 0x60400000;
    uint16_t* const cacheStartAddr = (uint16_t*)0x60400000;
    const uint32_t cacheSize = 0x100000; //1 MB, as example
    Bitmap::setCache(cacheStartAddr, cacheSize,4);
#endif
}

 

 

Next i insterted manually image13 in my ScreenView:

 

private:
    Image image13;

 

 

Then i created bitmap in setupScreen:

 

void SDRScreenView::setupScreen()
{
	SDRScreenViewBase::setupScreen();

	BitmapId bmpId;

	//Create (16bit) dynamic bitmap of size 100x150
	const int width = 600;
	const int height = 300;
	bmpId = Bitmap::dynamicBitmapCreate(600, 300, Bitmap::RGB565);

	//set all pixels white
	if (bmpId != BITMAP_INVALID)
	{
	   memset(Bitmap::dynamicBitmapGetAddress(bmpId), 0xFF, width*height*2);
	}

	//Make Image widget show the dynamic bitmap
	image13.setBitmap(Bitmap(bmpId));

	//Position image and add to View
	image13.setXY(100, 100);
	add(image13);
}

 

 

And finally fill it with single color:

 

void SDRScreenView::setWifi(bool state)
{
	IMAGES_wifi_active.setVisible(state);
	IMAGES_wifi_active.invalidate();
	static bool state_prev;
	if (state != state_prev)
	{
		static BitmapId bmpId;
		const int width = 600;
		const int height = 300;
		Bitmap::dynamicBitmapDelete(bmpId);
		bmpId = Bitmap::dynamicBitmapCreate(600, 300, Bitmap::RGB565);
		if (bmpId != BITMAP_INVALID)
		{
		   if(state) memset(Bitmap::dynamicBitmapGetAddress(bmpId), 0xFF, width*height*2);
		   else memset(Bitmap::dynamicBitmapGetAddress(bmpId), 0x55, width*height*2);
		}
		image13.setBitmap(Bitmap(bmpId));
		image13.invalidate();
		//image13.setXY(100, 100);
		//add(image13);
	}
	state_prev = state;
}

 

 

The big rectangle is showed and changes color based on state variable.

Now i want to continue with create some touch "zones" inside this rectangle and call functions based on different locations inside of it.