clicks ok, moves ok, debounce ok, norepeat ok
This commit is contained in:
parent
e6a467b2ad
commit
83e189d187
@ -16,43 +16,36 @@ Preferences moozyPrefs;
|
||||
// Variable and constant declarations
|
||||
// ----------------------------------
|
||||
|
||||
// set pin numbers for the five inputs:
|
||||
const int PinInput1 = 9;
|
||||
const int PinInput2 = 10;
|
||||
const int PinInput3 = 11;
|
||||
const int PinInput4 = 12;
|
||||
const int PinInput5 = 13;
|
||||
const int PinInput6 = 14;
|
||||
// set pin numbers for each inputs:
|
||||
const int PinInput1 = 1;
|
||||
const int PinInput2 = 2;
|
||||
const int PinInput3 = 3;
|
||||
#define LedMoozy 48
|
||||
|
||||
bool keypressed = false;
|
||||
unsigned long debouncetime;
|
||||
bool keypressed = false, doNotRepeat = false;
|
||||
int cursorspeed, speed1, speed2, speed3;
|
||||
int currentspeed = 2;
|
||||
String todo, fctinput1, fctinput2, fctinput3, fctinput4, fctinput5, fctinput6;
|
||||
String todo, fctinput1, fctinput2, fctinput3;
|
||||
|
||||
/*
|
||||
// Interrupt Service Routine
|
||||
// -------------------------
|
||||
void ISR_Inputs () {
|
||||
if (!digitalRead(PinInput1)) { todo = fctinput1; Serial.print("I1"); }
|
||||
if (!digitalRead(PinInput1)) { todo = fctinput1; }
|
||||
if (!digitalRead(PinInput2)) { todo = fctinput2; }
|
||||
if (!digitalRead(PinInput3)) { todo = fctinput3; }
|
||||
if (!digitalRead(PinInput4)) { todo = fctinput4; }
|
||||
if (!digitalRead(PinInput5)) { todo = fctinput5; }
|
||||
if (!digitalRead(PinInput6)) { todo = fctinput6; }
|
||||
Serial.print("Interruption");
|
||||
}
|
||||
}*/
|
||||
|
||||
// Initialisations
|
||||
// ---------------
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
// initialize the buttons' inputs:
|
||||
pinMode(PinInput1, INPUT_PULLUP);
|
||||
pinMode(PinInput2, INPUT_PULLUP);
|
||||
pinMode(PinInput3, INPUT_PULLUP);
|
||||
pinMode(PinInput4, INPUT_PULLUP);
|
||||
pinMode(PinInput5, INPUT_PULLUP);
|
||||
pinMode(PinInput6, INPUT_PULLUP);
|
||||
pinMode(LedMoozy, OUTPUT);
|
||||
|
||||
// retrieve settings from flash nvs
|
||||
moozyPrefs.begin("myapp", true); //namespace / true = RO MODE
|
||||
@ -62,33 +55,10 @@ void setup() {
|
||||
fctinput1 = moozyPrefs.getString("input1");
|
||||
fctinput2 = moozyPrefs.getString("input2");
|
||||
fctinput3 = moozyPrefs.getString("input3");
|
||||
fctinput4 = moozyPrefs.getString("input4");
|
||||
fctinput5 = moozyPrefs.getString("input5");
|
||||
fctinput6 = moozyPrefs.getString("input6");
|
||||
moozyPrefs.end();
|
||||
|
||||
cursorspeed = speed2 / 10;
|
||||
|
||||
// Affichage des valeurs récupérées en Flash // pour débug
|
||||
Serial.println("Les valeurs en Flash/EEPROM :");
|
||||
Serial.print("Vitesse 1 : ");
|
||||
Serial.println(speed1);
|
||||
Serial.print("Vitesse 2 : ");
|
||||
Serial.println(speed2);
|
||||
Serial.print("Vitesse 3 : ");
|
||||
Serial.println(speed3);
|
||||
Serial.print("Fct entrée 1 : ");
|
||||
Serial.println(fctinput1);
|
||||
Serial.print("Fct entrée 2 : ");
|
||||
Serial.println(fctinput2);
|
||||
Serial.print("Fct entrée 3 : ");
|
||||
Serial.println(fctinput3);
|
||||
Serial.print("Fct entrée 4 : ");
|
||||
Serial.println(fctinput4);
|
||||
Serial.print("Fct entrée 5 : ");
|
||||
Serial.println(fctinput5);
|
||||
Serial.print("Fct entrée 6 : ");
|
||||
Serial.println(fctinput6);
|
||||
cursorspeed = speed2 / 20;
|
||||
debouncetime = millis();
|
||||
|
||||
// initialize mouse control:
|
||||
Mouse.begin();
|
||||
@ -96,41 +66,63 @@ void setup() {
|
||||
USB.begin();
|
||||
|
||||
// initialize interruptions
|
||||
attachInterrupt(digitalPinToInterrupt(PinInput1), ISR_Inputs, CHANGE);
|
||||
/*attachInterrupt(digitalPinToInterrupt(PinInput1), ISR_Inputs, CHANGE);
|
||||
attachInterrupt(digitalPinToInterrupt(PinInput2), ISR_Inputs, CHANGE);
|
||||
attachInterrupt(digitalPinToInterrupt(PinInput3), ISR_Inputs, CHANGE);
|
||||
attachInterrupt(digitalPinToInterrupt(PinInput4), ISR_Inputs, CHANGE);
|
||||
attachInterrupt(digitalPinToInterrupt(PinInput5), ISR_Inputs, CHANGE);
|
||||
attachInterrupt(digitalPinToInterrupt(PinInput6), ISR_Inputs, CHANGE);
|
||||
attachInterrupt(digitalPinToInterrupt(PinInput3), ISR_Inputs, CHANGE);*/
|
||||
|
||||
// To say Hello on startup
|
||||
digitalWrite(LedMoozy, true);
|
||||
delay(150);
|
||||
digitalWrite(LedMoozy, false);
|
||||
delay(150);
|
||||
digitalWrite(LedMoozy, true);
|
||||
delay(150);
|
||||
digitalWrite(LedMoozy, false);
|
||||
}
|
||||
|
||||
// Main loop
|
||||
// -------------
|
||||
void loop() {
|
||||
if (todo =="LC") { dolc(); }
|
||||
if (todo =="LCD") { dolcd(); }
|
||||
if (todo =="LCH") { dolch(); }
|
||||
if (todo =="RC") { dorc(); }
|
||||
if (todo =="RCD") { dorcd(); }
|
||||
if (todo =="RCH") { dorch(); }
|
||||
if (todo =="up") { moveup(); }
|
||||
if (todo =="down") { movedown(); }
|
||||
if (todo =="right") { moveright(); }
|
||||
if (todo =="left") { moveleft(); }
|
||||
if (todo =="upright") { moveupright(); }
|
||||
if (todo =="upleft") { moveupleft(); }
|
||||
if (todo =="downright") { movedownright(); }
|
||||
if (todo =="downleft") { movedownleft(); }
|
||||
if (todo =="scrollup") { doscrollup(); }
|
||||
if (todo =="scrolldown") { doscrolldown(); }
|
||||
if (todo =="speed1") { tospeed1(); }
|
||||
if (todo =="speed2") { tospeed2(); }
|
||||
if (todo =="speed3") { tospeed3(); }
|
||||
if (todo =="speedinc") { incspeed(); }
|
||||
if (todo =="speeddec") { decspeed(); }
|
||||
if (todo =="mode1") { tomode1(); }
|
||||
if (todo =="mode2") { tomode2(); }
|
||||
if (todo =="mode3") { tomode3(); }
|
||||
if (!digitalRead(PinInput1)) { todo = fctinput1; }
|
||||
if (!digitalRead(PinInput2)) { todo = fctinput2; }
|
||||
if (!digitalRead(PinInput3)) { todo = fctinput3; }
|
||||
|
||||
if ((todo != "") & (millis() > debouncetime + 100)) {
|
||||
if ((todo =="LC") & (!doNotRepeat)) {doNotRepeat = true; dolc(); }
|
||||
if ((todo =="LCD") & (!doNotRepeat)) {doNotRepeat = true; dolcd(); }
|
||||
if ((todo =="LCH") & (!doNotRepeat)) {doNotRepeat = true; dolch(); }
|
||||
if ((todo =="RC") & (!doNotRepeat)) {doNotRepeat = true; dorc(); }
|
||||
if ((todo =="RCD") & (!doNotRepeat)) {doNotRepeat = true; dorcd(); }
|
||||
if ((todo =="RCH") & (!doNotRepeat)) {doNotRepeat = true; dorch(); }
|
||||
|
||||
if (todo =="up") { moveup(); }
|
||||
if (todo =="down") { movedown(); }
|
||||
if (todo =="right") { moveright(); }
|
||||
if (todo =="left") { moveleft(); }
|
||||
if (todo =="upright") { moveupright(); }
|
||||
if (todo =="upleft") { moveupleft(); }
|
||||
if (todo =="downright") { movedownright(); }
|
||||
if (todo =="downleft") { movedownleft(); }
|
||||
|
||||
if (todo =="scrollup") { doscrollup(); }
|
||||
if (todo =="scrolldown") { doscrolldown(); }
|
||||
|
||||
if ((todo =="speed1") & (!doNotRepeat)) {doNotRepeat = true; tospeed1(); }
|
||||
if ((todo =="speed2") & (!doNotRepeat)) {doNotRepeat = true; tospeed2(); }
|
||||
if ((todo =="speed3") & (!doNotRepeat)) {doNotRepeat = true; tospeed3(); }
|
||||
|
||||
if (todo =="speedinc") { incspeed(); }
|
||||
if (todo =="speeddec") { decspeed(); }
|
||||
|
||||
if ((todo =="mode1") & (!doNotRepeat)) {doNotRepeat = true; tomode1(); }
|
||||
if ((todo =="mode2") & (!doNotRepeat)) {doNotRepeat = true; tomode2(); }
|
||||
if ((todo =="mode3") & (!doNotRepeat)) {doNotRepeat = true; tomode3(); }
|
||||
|
||||
debouncetime = millis();
|
||||
}
|
||||
|
||||
todo = "";
|
||||
if ((digitalRead(PinInput1)) & (digitalRead(PinInput2)) & (digitalRead(PinInput3))) { doNotRepeat = false; }
|
||||
|
||||
digitalWrite(LedMoozy, false);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Moozy_firmware
|
||||
> A mouse and keyboard application easily customizable for people with disabilities.
|
||||
> A mouse and keyboard application easily customizable for everyone.
|
||||
|
||||
8 directions by digital inputs, digital and analog joysticks, 3 speeds, right and left single, double and hold clicks, vertical scrolling, keyboard shortcuts, multimedia keys.
|
||||
|
||||
|
@ -2,12 +2,13 @@
|
||||
void donothing() { // Do nothing
|
||||
}
|
||||
void dolc() { // Do a left click
|
||||
Mouse.release();
|
||||
Mouse.click(MOUSE_LEFT);
|
||||
Mouse.release();
|
||||
Serial.print("Clic gauche");
|
||||
todo = "";
|
||||
}
|
||||
void dolcd() { // Do a double left click
|
||||
Mouse.release();
|
||||
Mouse.press(MOUSE_LEFT);
|
||||
delay(50);
|
||||
Mouse.release();
|
||||
@ -25,10 +26,12 @@ void dolch() { // Do a left click and hold
|
||||
}
|
||||
}
|
||||
void dorc() { // Do a right click
|
||||
Mouse.release();
|
||||
Mouse.click(MOUSE_RIGHT);
|
||||
Mouse.release();
|
||||
}
|
||||
void dorcd() { // Do a double right click
|
||||
Mouse.release();
|
||||
Mouse.press(MOUSE_RIGHT);
|
||||
delay(50);
|
||||
Mouse.release();
|
||||
@ -46,29 +49,37 @@ void dorch() { // Do a left click and hold
|
||||
}
|
||||
}
|
||||
void moveup() { // Move the mouse cursor up
|
||||
Mouse.move(0, cursorspeed);
|
||||
Mouse.move(0, -cursorspeed);
|
||||
digitalWrite(LedMoozy, true);
|
||||
delay(5);
|
||||
}
|
||||
void movedown() { // Move the mouse cursor down
|
||||
Mouse.move(0, -cursorspeed);
|
||||
Mouse.move(0, cursorspeed);
|
||||
digitalWrite(LedMoozy, true);
|
||||
delay(5);
|
||||
}
|
||||
void moveright() { // Move the mouse cursor to the right
|
||||
Mouse.move(cursorspeed, 0);
|
||||
digitalWrite(LedMoozy, true);
|
||||
delay(5);
|
||||
}
|
||||
void moveleft() { // Move the mouse cursor to the left
|
||||
Mouse.move(cursorspeed, 0);
|
||||
Mouse.move(-cursorspeed, 0);
|
||||
digitalWrite(LedMoozy, true);
|
||||
delay(5);
|
||||
}
|
||||
void moveupright() { // Move the mouse cursor to the diag up and right
|
||||
Mouse.move(cursorspeed, cursorspeed);
|
||||
}
|
||||
void moveupleft() { // Move the mouse cursor to the diag up and left
|
||||
Mouse.move(-cursorspeed, cursorspeed);
|
||||
}
|
||||
void movedownright() { // Move the mouse cursor to the diag down and right
|
||||
Mouse.move(cursorspeed, -cursorspeed);
|
||||
}
|
||||
void movedownleft() { // Move the mouse cursor to the diag down and left
|
||||
void moveupleft() { // Move the mouse cursor to the diag up and left
|
||||
Mouse.move(-cursorspeed, -cursorspeed);
|
||||
}
|
||||
void movedownright() { // Move the mouse cursor to the diag down and right
|
||||
Mouse.move(cursorspeed, cursorspeed);
|
||||
}
|
||||
void movedownleft() { // Move the mouse cursor to the diag down and left
|
||||
Mouse.move(-cursorspeed, cursorspeed);
|
||||
}
|
||||
void doscrollup() { // Move the wheel cursor up
|
||||
Mouse.move(0, 0, cursorspeed);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user