Skip to content

Instantly share code, notes, and snippets.

@qzane
Last active April 22, 2018 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qzane/1007f9ed3c0b61f0fe2bb0bede4f35c2 to your computer and use it in GitHub Desktop.
Save qzane/1007f9ed3c0b61f0fe2bb0bede4f35c2 to your computer and use it in GitHub Desktop.
FEH auto play script for arduino leonardo
#include<Mouse.h>
//sleep 5;sudo ./arduino --board arduino:avr:leonardo --upload ~/arduino/touch/touch.ino --port /dev/ttyACM7
void setup(){
delay(5000);
Mouse.begin();
}
void tap(unsigned long x,unsigned long y){
int tmpX, tmpY;
x = x / 3; //I dont know why, x, y is in pixel
y = y / 3;
delay(350);
for(int i=0;i<10;++i)
Mouse.move(-125,-125); //signed char
while(x>0 || y>0){
tmpX = min(x, 125);
tmpY = min(y, 125);
Mouse.move(tmpX, tmpY);
x -= tmpX;
y -= tmpY;
delay(3);
}
Mouse.press();
delay(30);
Mouse.release();
}
void sleep(unsigned long time){
delay(time * 1000);
}
void loop(){
tap(540,900);
sleep(0.5);
tap(540,1200);
sleep(0.5);
tap(540,900);
for(int i=0;i<22;++i){
tap(540,900);
sleep(0.2);}
sleep(0.5);
tap(460,1480);
sleep(0.2);
tap(460,1280);
sleep(0.1);
tap(460,1280);
sleep(0.3);
tap(850,1800);
sleep(0.3);
tap(500,960);
sleep(9);
delay(random(6000));
tap(500,960);
sleep(5);
delay(random(3000));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment