Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to dynamically load different xml settings files #145

Open
olivercrush opened this issue May 15, 2018 · 10 comments
Open

How to dynamically load different xml settings files #145

olivercrush opened this issue May 15, 2018 · 10 comments
Labels

Comments

@olivercrush
Copy link

Hi,

I would like to know how I can dynamically change the xml settings file. I would basically like to change some surfaces and sources when I press a button. Is there a way to easily do that ? I saw that there is a preset system too but I'm not really sure what it does and how it works.

Thank you in advance for your response, you did a great job on this project !

@kr15h
Copy link
Owner

kr15h commented May 15, 2018

You mean dynamically load another xml file? There is the function ofxPiMapper::loadProject(std::string filename). Try that. There might be issues, since the ofxOMXPlayer in the background might not unload video files properly and it would eat up memory. If you use it with images, should work fine. Got to do something with this OMX player...

@olivercrush
Copy link
Author

Yes I tried calling loadProject in my ofApp.cpp, but it freezes everything and I have to reboot my pi. I can't even get back to the command interface to see the debug messages so it's hard to tell where exactly the problem occurs. And I don't even use videos in my mapping, there are just images

@kr15h
Copy link
Owner

kr15h commented May 15, 2018

Yes, I guess that is a valid issue. The thing with pressets is that you can store multiple projects in one xml file. You could try that approach. You just have to add another <surfaces>...</surfaces> block after the one that is there. That is for now.

@kr15h kr15h added the bug label May 15, 2018
@olivercrush
Copy link
Author

Oh ok thanks, I will look into it. I guess I can switch between presets with the setPreset() method ?

@kr15h
Copy link
Owner

kr15h commented May 22, 2018

Yes.

@pietrondo
Copy link

is possible to have this "function" in the example? (so if i press 7 i load preset 1, 8 load preset 2 ecc..?)
thx

@olivercrush
Copy link
Author

olivercrush commented May 23, 2018

Here, I can give you my ofApp's keyPressed method for an example. You just have to have several surfaces which contains your configurations in your ofxpimapper.xml

void ofApp::keyPressed(int key) {

	switch (key) {
		case 'q':
			mapper.setPreset(0);
			break;

		case 'w':
			mapper.setPreset(1);
			break;

		case 'e':
			mapper.setPreset(2);
			break;

		case 'r':
			mapper.setPreset(3);
			break;

		case 't':
			mapper.setPreset(4);
			break;

		case 'y':
			mapper.setPreset(5);
			break;

		case 'u':
			mapper.setPreset(6);
			break;

		case 'i':
			mapper.setPreset(7);
			break;

		case 'o':
			mapper.setPreset(8);
			break;

		case 'p':
			mapper.setPreset(9);
			break;

		case 'a':
			mapper.setPreset(10);
			break;

		case 's':
			mapper.setPreset(11);
			break;

		default:
			mapper.keyPressed(key);
			break;
	}
	usleep(10);
}

@kr15h
Copy link
Owner

kr15h commented May 24, 2018

Yes, this is how it is meant to be. One can override internal ofxPiMapper shortcuts.

@pietrondo
Copy link

pietrondo commented May 24, 2018 via email

@kr15h
Copy link
Owner

kr15h commented May 24, 2018

You can also take a look at the example_pocketvj ofApp.cpp and use that to remap your keys. But I would prefer the config file solution proposed by @pietrondo myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants