Arduino Code
// AppGosu for smart phone
#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
if( app.eventMousePressRect(1)) {
app.image("appledOn.png", 120, 220, 250, 380);
digitalWrite(LED, HIGH); // LED on
}
if( app.eventMousePressRect(2)) {
app.image("appledOff.png", 120, 220, 250, 380);
digitalWrite(LED, LOW); // LED off
}
}
//---------------------------------------------------------
void myStart(void) {
// user starting code here
app.clearAll();
app.background(0,0,0);
app.textSize(50);
app.fill(255,255,255);
app.text("-- mousePressRect --", 20, 50);
// mousePressRect
//app.rect(120,220,250,200);
//app.fill(255,155,155);
//app.rect(120,420,250,200);
app.mousePressRect(120, 220, 250, 200, 1);
app.mousePressRect(120, 420, 250, 200, 2);
app.image("appledOff.png", 120, 220, 250, 380);
}
No comments:
Post a Comment