Example : image button

Example  :  image  button



Arduino Code

// AppGosu  for smart phone
// Auto starting when bluetooth connected

#include "AppGosu.h"
AppGosu app;

int LED = 13;

void setup() {    

    pinMode(LED,OUTPUT);
    digitalWrite(LED, HIGH); // LED on
 
    app.start();
    app.setDelayCmd(20);  // max speed 20ms

    myStart();
}

void loop() { 
} // end of loop

//---------------------------------------------------------
void serialEvent() {
      app.serialMessage();
      EventLoop();
}
void EventLoop() {
    if( app.btConnected()) {   // for auto starting
        myStart();
    }
  
    // user event code here
    app.textSize(30);
  
        if( app.eventImageButton(1)) {
            app.clearImageButton(1);
            app.imageButton("appledOff.png","appledOn.png", 120, 220, 250, 380, 2);
            digitalWrite(LED, LOW); // LED off                
        }
        if( app.eventImageButton(2)) {
            app.clearImageButton(2);
            app.imageButton("appledOn.png","appledOff.png", 120, 220, 250, 380, 1);
            digitalWrite(LED,HIGH); // LED on
        }
        if( app.eventButton(1)) {
            app.background(0,0,0);
        }

}
//---------------------------------------------------------
void myStart(void) {
    // user starting code here
 
    app.clearAll();
    app.background(0,0,0);
    app.textSize(50);
    app.fill(255,255,255);
    app.text("--- imageButton ---", 20, 50);
  
    // imageButton

    app.imageButton("appledOn.png","appledOff.png", 120, 220, 250, 380, 1);
    app.button(" OK ", 170, 700, 150, 80, 1);
}




No comments: