From fc721f05371851bf4de3d2311f2516b5b6ddf554 Mon Sep 17 00:00:00 2001 From: sirrow Date: Tue, 8 Sep 2020 18:30:11 +0900 Subject: [PATCH] Use 1ms timer and table for scheduling --- connect_switch.ino | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/connect_switch.ino b/connect_switch.ino index 41a3d39..edd5352 100644 --- a/connect_switch.ino +++ b/connect_switch.ino @@ -3,7 +3,20 @@ int loopCount = 0; int state = 0; +int table[40] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +int index = 0; +void perms() { + if (table[index] == 1){ + SwitchControlLibrary().PressButtonA(); + } + if (table[index] == 2){ + SwitchControlLibrary().ReleaseButtonA(); + } + + index = (index + 1) % 40; +} +/* void button() { if (state == 0) { SwitchControlLibrary().PressButtonA(); @@ -14,11 +27,12 @@ void button() { state = 0; } } +*/ void setup() { SwitchControlLibrary(); - MsTimer2::set(20, button); + MsTimer2::set(1, perms); MsTimer2::start(); }