Browse Source

Add reboot() for Raspberry Pi on <x> press

master
Krisjanis Rijnieks 8 years ago
parent
commit
5f3ea80088
  1. 12
      src/Application/Application.cpp
  2. 3
      src/Application/Application.h
  3. 4
      src/ofxPiMapper.cpp
  4. 3
      src/ofxPiMapper.h

12
src/Application/Application.cpp

@ -153,6 +153,10 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
case 'n':
setNextPreset();
break;
case 'x':
reboot();
break;
default:
// All the other keypresses are handled by the application state onKeyPressed
@ -296,6 +300,14 @@ void Application::setNextPreset(){
setPreset(activePreset);
}
void Application::reboot(){
#ifdef TARGET_RASPBERRY_PI
system("sudo shutdown -r now");
#else
ofLogNotice("Application::reboot()", "Supported only on Raspberry Pi");
#endif
}
bool Application::loadXmlSettings(string fileName){
if(!ofFile::doesFileExist(fileName)){
ofLogError("Application::loadXmlSettings()") << fileName << " does not exist";

3
src/Application/Application.h

@ -124,6 +124,9 @@ class Application : public KeyListener {
void setPreset(unsigned int i);
void setNextPreset();
// System commands
void reboot();
protected:
void setState(ApplicationBaseMode * st);

4
src/ofxPiMapper.cpp

@ -150,6 +150,10 @@ void ofxPiMapper::setNextSource(){
_application.setNextSource();
}
void ofxPiMapper::reboot(){
_application.reboot();
}
void ofxPiMapper::saveProject(){
_application.saveProject();
}

3
src/ofxPiMapper.h

@ -65,6 +65,9 @@ class ofxPiMapper {
// Sources, selected surface
void setNextSource();
// System commands
void reboot();
private:
ofx::piMapper::Application _application;

Loading…
Cancel
Save