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

@ -154,6 +154,10 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
setNextPreset(); setNextPreset();
break; break;
case 'x':
reboot();
break;
default: default:
// All the other keypresses are handled by the application state onKeyPressed // All the other keypresses are handled by the application state onKeyPressed
_state->onKeyPressed(this, args); _state->onKeyPressed(this, args);
@ -296,6 +300,14 @@ void Application::setNextPreset(){
setPreset(activePreset); 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){ bool Application::loadXmlSettings(string fileName){
if(!ofFile::doesFileExist(fileName)){ if(!ofFile::doesFileExist(fileName)){
ofLogError("Application::loadXmlSettings()") << fileName << " does not exist"; 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 setPreset(unsigned int i);
void setNextPreset(); void setNextPreset();
// System commands
void reboot();
protected: protected:
void setState(ApplicationBaseMode * st); void setState(ApplicationBaseMode * st);

4
src/ofxPiMapper.cpp

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

3
src/ofxPiMapper.h

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

Loading…
Cancel
Save