diff options
Diffstat (limited to 'menuApp')
| -rw-r--r-- | menuApp/src/ofApp.cpp | 41 | ||||
| -rw-r--r-- | menuApp/src/ofApp.h | 6 |
2 files changed, 41 insertions, 6 deletions
diff --git a/menuApp/src/ofApp.cpp b/menuApp/src/ofApp.cpp index 2eda0b6..c1f7860 100644 --- a/menuApp/src/ofApp.cpp +++ b/menuApp/src/ofApp.cpp @@ -16,7 +16,7 @@ std::string replaceStrChar(std::string str, const std::string& replace, char ch) return str; // return our new string. } -void ofApp::loadInstagramFeed(){ +bool ofApp::loadInstagramFeed(){ /* std::string test[5]; @@ -39,6 +39,8 @@ void ofApp::loadInstagramFeed(){ int slot=0; map<std::string,menuItem> newmenu; + + bool newInteresting=false; if (!instagram.getImageURL().empty()) { @@ -94,7 +96,7 @@ void ofApp::loadInstagramFeed(){ imagepool[id]=ofImage(); //ofLog(OF_LOG_NOTICE) << menutag << " " << slot << " " << caption << price << " " << id; - + newInteresting=true; } if (!imagepool[id].isAllocated()) { @@ -118,15 +120,24 @@ void ofApp::loadInstagramFeed(){ } } lastPoll=ofGetElapsedTimef(); + + if (newInteresting){ + isGrabbed=false; + } + + return newInteresting; } //-------------------------------------------------------------- void ofApp::setup(){ +/* std::string str ("€"); ofLog(OF_LOG_NOTICE) << "code for € is " << ((int)str.at(0)) << " not " << 0xA4; ofLog(OF_LOG_NOTICE) << "-30 as uint8_t is " << ((int)((uint8_t)-30)); +*/ + items.resize(IMAGE_SLOTS); ofTrueTypeFont::setGlobalDpi(150); @@ -155,11 +166,15 @@ void ofApp::setup(){ //load ofSetFrameRate(5); + + lastPoll=POLL_INTERVAL; + + primed=false; } //-------------------------------------------------------------- void ofApp::update(){ - ofBackground(255); + //ofBackground(255); } @@ -167,6 +182,10 @@ void ofApp::update(){ void ofApp::draw(){ ofSetColor(255,255,255); + if(ofGetElapsedTimef()-lastPoll>POLL_INTERVAL) { + loadInstagramFeed(); + } + ofPushMatrix(); //Store the coordinate system nexessary for some reason background.draw(0,0,1080*FACTOR,1920*FACTOR); //ofGetWidth(),ofGetHeight()); ofPopMatrix(); //Restore the coordinate system @@ -186,6 +205,8 @@ ofPopMatrix(); //Restore the coordinate system //some kind of rendering bug with textsuite means it has to go last or everything is dim + bool imageWaiting=false; + if (!items.empty()) { for (int i = 0; i < items.size(); i++) { @@ -204,6 +225,8 @@ ofPopMatrix(); //Restore the coordinate system myText.setColor(255,255,255,255); myText.drawCenter(imgx+((imgsize*FACTOR)/2),imgy+((imgsize+textcolinset+(FONTSPACING*2))*FACTOR),2); } + else imageWaiting=true; + col++; if (col==cols){ col=0; @@ -216,8 +239,16 @@ ofPopMatrix(); //Restore the coordinate system overlay.draw(0,0,1080*FACTOR,1920*FACTOR); //ofGetWidth(),ofGetHeight()); //don't work on a horiz screen?? ofDisableAlphaBlending(); - if(ofGetElapsedTimef()-lastPoll>POLL_INTERVAL) { - loadInstagramFeed(); + if (primed){ + ofImage img; + img.grabScreen(0, 0, ofGetWidth(), ofGetHeight()); + img.save(SCREENGRABFILEPATH); + primed=false; + } + + if (!isGrabbed&&!imageWaiting) { + primed=true; + isGrabbed=true; } } diff --git a/menuApp/src/ofApp.h b/menuApp/src/ofApp.h index 1c1f747..c9a9892 100644 --- a/menuApp/src/ofApp.h +++ b/menuApp/src/ofApp.h @@ -11,6 +11,7 @@ #define FONTSPACING FONTSIZE*2.3 // 30 #define POLL_INTERVAL 60.0 #define MENUTAG "#hangdai" +#define SCREENGRABFILEPATH "../../../../../../../../home/tim/Dropbox/menugrab/menu.png" class menuItem { public: @@ -48,7 +49,10 @@ class ofApp : public ofBaseApp{ ofxThreadedImageLoader getImages; std::string menutag; - void loadInstagramFeed(); + bool loadInstagramFeed(); + + bool isGrabbed; + bool primed; //this is a weird one float lastPoll; |
