Skip to content

Instantly share code, notes, and snippets.

@jaimehrubiks
Created April 1, 2019 17:06
Show Gist options
  • Save jaimehrubiks/5fcee38bd64674721fe966d0a1127dcf to your computer and use it in GitHub Desktop.
Save jaimehrubiks/5fcee38bd64674721fe966d0a1127dcf to your computer and use it in GitHub Desktop.
Teensy Android Pattern AutoDraw
int moveDelay = 0;
void setup() {
delay(1000);
wakeUp();
delay(1000);
revealPin();
delay(1000);
pattern(120,1050*1,200*1);
}
void loop() {
}
void wakeUp(){
moveXrel(100);
}
void positionTo(int x, int y){
for(int i = 0 ; i < 10 ; i++) Mouse.move(-100,-100);
moveXrel(x);
moveYrel(y);
}
void revealPin(){
positionTo(50,1500);
delay(10);
Mouse.press();
delay(10);
moveYrel(-690);
delay(10);
Mouse.release();
}
void area(){
moveXrel(-30);
moveYrel(-30);
for(int i=0;i<60;i+=10){
moveXrel(10);
vline();
}
moveXrel(-30);
moveYrel(30);
}
void vline(){
moveYrel(60);
moveYrel(-60);
}
void pattern(int startX, int startY, int patternDistance){
positionTo(startX,startY);
//positionTo(140,1000);
delay(1000);
Mouse.press();
area();
moveXrel(patternDistance);
area();
delay(200);
moveYrel(patternDistance);
area();
delay(200);
moveXrel(patternDistance);
area();
delay(200);
moveYrel(-patternDistance);
area();
delay(200);
Mouse.release();
}
void moveXrel(int x){
int dir=1, i=0;
if (x<0){
dir = -1;
x*=-1;
}
for(i=0;i<x;i+=2){
Mouse.move(2*dir,0);
delay(moveDelay);
}
if(i!=x) Mouse.move(dir,0);
}
void moveYrel(int x){
int dir=1, i=0;
if (x<0){
dir = -1;
x*=-1;
}
for(i=0;i<x;i+=2){
Mouse.move(0,2*dir);
delay(moveDelay);
}
if(i!=x) Mouse.move(0,dir);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment