initial customization tests via nvs
This commit is contained in:
parent
f70a9608ac
commit
0da357ce07
102
Moozy_firmware.ino
Normal file
102
Moozy_firmware.ino
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
Moozy_firmware by Laurent CLAUDE
|
||||
2023-09
|
||||
Licence GPL v3 or later
|
||||
|
||||
*/
|
||||
|
||||
#include "USB.h"
|
||||
#include "USBHIDMouse.h"
|
||||
#include "USBHIDKeyboard.h"
|
||||
#include <Preferences.h>
|
||||
USBHIDMouse Mouse;
|
||||
USBHIDKeyboard Keyboard;
|
||||
Preferences moozyPrefs;
|
||||
|
||||
// set pin numbers for the five buttons:
|
||||
const int upButton = 14;
|
||||
const int downButton = 13;
|
||||
const int leftButton = 14;
|
||||
const int rightButton = 12;
|
||||
const int mouseButton = 0;
|
||||
|
||||
bool keypressed = false;
|
||||
int cursorspeed, speed1, speed2, speed3;
|
||||
String input1, input2, input3;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
// initialize the buttons' inputs:
|
||||
pinMode(upButton, INPUT_PULLUP);
|
||||
pinMode(downButton, INPUT_PULLUP);
|
||||
pinMode(leftButton, INPUT_PULLUP);
|
||||
pinMode(rightButton, INPUT_PULLUP);
|
||||
pinMode(mouseButton, INPUT_PULLUP);
|
||||
|
||||
// retrieve settings from memory
|
||||
moozyPrefs.begin("myapp", true); //namespace / true = RO MODE
|
||||
speed1 = moozyPrefs.getInt("speed1");
|
||||
speed2 = moozyPrefs.getInt("speed2");
|
||||
speed3 = moozyPrefs.getInt("speed3");
|
||||
input1 = moozyPrefs.getString("input1");
|
||||
input2 = moozyPrefs.getString("input2");
|
||||
input3 = moozyPrefs.getString("input3");
|
||||
|
||||
cursorspeed = speed2 / 10;
|
||||
|
||||
// Affichage des valeurs récupérer 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("Entrée 1 : ");
|
||||
Serial.println(input1);
|
||||
Serial.print("Entrée 2 : ");
|
||||
Serial.println(input2);
|
||||
Serial.print("Entrée 3 : ");
|
||||
Serial.println(input3);
|
||||
|
||||
moozyPrefs.end();
|
||||
|
||||
// initialize mouse control:
|
||||
Mouse.begin();
|
||||
Keyboard.begin();
|
||||
USB.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// use serial input to control the mouse:
|
||||
if (Serial.available() > 0) {
|
||||
char inChar = Serial.read();
|
||||
|
||||
switch (inChar) {
|
||||
case 'r':
|
||||
// move mouse right
|
||||
Mouse.move(40, 0);
|
||||
break;
|
||||
case 'm':
|
||||
// perform mouse left click
|
||||
Mouse.click(MOUSE_LEFT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((digitalRead(upButton) == HIGH) && (digitalRead(mouseButton))) {
|
||||
keypressed = false;
|
||||
} else {
|
||||
//if (keypressed == false) {
|
||||
if (digitalRead(upButton) == LOW) {
|
||||
Mouse.move(0, -cursorspeed);
|
||||
}
|
||||
if (digitalRead(mouseButton) == LOW) {
|
||||
Mouse.move(0, cursorspeed);
|
||||
}
|
||||
Keyboard.releaseAll();
|
||||
keypressed = true;
|
||||
delay(5);
|
||||
}
|
||||
//}
|
||||
}
|
33
README.md
33
README.md
@ -1,2 +1,35 @@
|
||||
# Moozy_firmware
|
||||
> A mouse and keyboard application easily customizable for people with disabilities.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
## Hardware
|
||||
|
||||
ESP32-S3
|
||||
|
||||
|
||||
## Usage example
|
||||
|
||||
Turns almost any hardware into a USB mouse/keyboard device
|
||||
|
||||
|
||||
## Development setup
|
||||
|
||||
It's the beginning
|
||||
|
||||
|
||||
## Release History
|
||||
|
||||
* 0.0.1
|
||||
* Work in progress
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Please see <https://moozy.click>
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Distributed under the GNU GPLv3 license. See LICENSE for more information.
|
||||
|
Loading…
x
Reference in New Issue
Block a user