Commit aec9074c authored by yuichitamiya's avatar yuichitamiya
Browse files

add drone

parent f9dce5d3
Pipeline #243642 passed with stage
in 2 minutes and 13 seconds
# find_keyboard_shortcut
- [Google Map](https://support.google.com/maps/answer/6396990?hl=en&co=GENIE.Platform%3DDesktop)
- Press Ctrl + /. A list of shortcuts will appear on your screen.
- Google earth
- [Browser](https://support.google.com/earth/answer/7365025?hl=en)
- [Pro App](https://support.google.com/earth/answer/148115?hl=en)
- [Google spreadshet](https://support.google.com/docs/answer/181110?hl=en&co=GENIE.Platform%3DDesktop#zippy=)
- [Chrome](https://support.google.com/chrome/answer/157179?hl=en&co=GENIE.Platform%3DDesktop#zippy=)
- [YouTube](https://support.google.com/youtube/answer/7631406?hl=en)
- [Zoom](https://support.zoom.us/hc/en-us/articles/205683899)
- [mac OS](https://support.apple.com/en-us/HT201236)
- [Windows](https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec)
- [Ubuntu](https://help.ubuntu.com/stable/ubuntu-help/shell-keyboard-shortcuts.html.en)
---
## TinyUSB Mouse and Keyboard
[TinyUSB_Mouse_and_Keyboard library](https://github.com/cyborg5/TinyUSB_Mouse_and_Keyboard/)
### Mouse Functions
```
Mouse.click(MOUSE_LEFT); //do LEFT click
Mouse.click(); //do LEFT click by default
Mouse.click(MOUSE_RIGHT); //do RIGHT click
Mouse.click(MOUSE_MIDDLE); //do MIDDLE click
Mouse.move(50,0); //movie in all four directions
Mouse.move(0,50);
Mouse.move(-50,0);
Mouse.move(0,-50);
Mouse.move(0,0,-5); //scroll down and up
Mouse.move(0,0,5); //move(x, y, wheel)
Mouse.press(MOUSE_LEFT); //hold the left button
Mouse.move(50,0,0); //drag
Mouse.release(MOUSE_LEFT); //release the button
Mouse.click(MOUSE_RIGHT); //try a right click
Mouse.move(-30,-30); //move away from the right-click menu that popped up
Mouse.click(MOUSE_LEFT); //do a left click to clear the pop-up
Status(); //print the buttons status
Mouse.press(MOUSE_LEFT); //press each button, print status, then release all
Mouse.press(MOUSE_RIGHT);
Mouse.press(MOUSE_MIDDLE);
Status();
Mouse.release(MOUSE_ALL);
```
### Keyboard Functions
```
Keyboard.write('a'); //press and release 'a' key
uint8_t Multiple[3]= {'1','2','3'};
Keyboard.write(Multiple,3); //multiple keys sequentially from a buffer
Keyboard.print("456"); //print a string
Keyboard.println("789"); //print another string with a line
Keyboard.press(KEY_LEFT_SHIFT); //hold down the shift
Keyboard.println("a uppercase sentence"); //this will be all caps
Keyboard.release(KEY_LEFT_SHIFT); //release the shift
Keyboard.println ("back to lowercase");
Keyboard.press(KEY_LEFT_SHIFT); //press shift
Keyboard.println("1234"); //some text
Keyboard.releaseAll(); //release all
Keyboard.println("1234"); //not shifted
Keyboard.print("A mistake"); //will attempt to erase this
delay(1000);
Keyboard.press(KEY_LEFT_CTRL); //will attempt control-z
Keyboard.write('z');
Keyboard.releaseAll(); //release the control key
```
### Keyboard codes
```
macOS
- command key: KEY_LEFT_GUI
- control key: KEY_LEFT_CTRL
Windows and Linux
- Windows key: KEY_LEFT_GUI
- Control key: KEY_LEFT_CTRL
// use this option for macOS
char ctrlKey = KEY_LEFT_GUI;
// use this option for Windows and Linux
//char ctrlKey = KEY_LEFT_CTRL;
Keyboard.press(ctrlKey);
```
```
#define KEY_LEFT_CTRL 0x80
#define KEY_LEFT_SHIFT 0x81
#define KEY_LEFT_ALT 0x82
#define KEY_LEFT_GUI 0x83
#define KEY_RIGHT_CTRL 0x84
#define KEY_RIGHT_SHIFT 0x85
#define KEY_RIGHT_ALT 0x86
#define KEY_RIGHT_GUI 0x87
#define KEY_UP_ARROW 0xDA
#define KEY_DOWN_ARROW 0xD9
#define KEY_LEFT_ARROW 0xD8
#define KEY_RIGHT_ARROW 0xD7
#define KEY_BACKSPACE 0xB2
#define KEY_TAB 0xB3
#define KEY_RETURN 0xB0
#define KEY_ESC 0xB1
#define KEY_INSERT 0xD1
#define KEY_DELETE 0xD4
#define KEY_PAGE_UP 0xD3
#define KEY_PAGE_DOWN 0xD6
#define KEY_HOME 0xD2
#define KEY_END 0xD5
#define KEY_CAPS_LOCK 0xC1
#define KEY_F1 0xC2
#define KEY_F2 0xC3
#define KEY_F3 0xC4
#define KEY_F4 0xC5
#define KEY_F5 0xC6
#define KEY_F6 0xC7
#define KEY_F7 0xC8
#define KEY_F8 0xC9
#define KEY_F9 0xCA
#define KEY_F10 0xCB
#define KEY_F11 0xCC
#define KEY_F12 0xCD
#define KEY_F13 0xF0
#define KEY_F14 0xF1
#define KEY_F15 0xF2
#define KEY_F16 0xF3
#define KEY_F17 0xF4
#define KEY_F18 0xF5
#define KEY_F19 0xF6
#define KEY_F20 0xF7
#define KEY_F21 0xF8
#define KEY_F22 0xF9
#define KEY_F23 0xFA
#define KEY_F24 0xFB
```
......@@ -40,6 +40,12 @@ download Eagle [sch](../eagle/QT/QT.sch)|[brd](../eagle/QT/QT.brd)
#include "Adafruit_FreeTouch.h"
```
[TinyUSB_Mouse_and_Keyboard](https://github.com/cyborg5/TinyUSB_Mouse_and_Keyboard/)
```
#include <TinyUSB_Mouse_and_Keyboard.h>
```
### Arduino Sketch
[download ino](./Xiao_QT_keyboard.ino)
......
......@@ -49,243 +49,238 @@ download Eagle [sch](../eagle/b2/b2.sch)|[brd](../eagle/b2/b2.brd)
### Arduino Sketch
[download ino](../sketch/map2_for_b2/map2_for_b2.ino)
```
/*
XIAO USB Keyboard.example.
http://yuichitamiya.fabcloud.io/fab16/How_to/program/
Google map help
https://support.google.com/maps/answer/6396990?co=GENIE.Platform%3DDesktop&hl=ja
Ctrl+/ to show help menu
*/
// https://github.com/cyborg5/TinyUSB_Mouse_and_Keyboard
#include <TinyUSB_Mouse_and_Keyboard.h>
//HID KEYCODE
//https://www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardmodifiers/
//uint8_t pins[] = { A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 }; //A9:no-use,A10:JACK_L
uint8_t pins[] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 10}; //9:no-use, 10:JACK_L
uint8_t pincount = sizeof(pins)/sizeof(pins[0]);
/*
Board 2
|8|4|3|
|6|<|>|
|5|0|1|
|7|x|2|
*/
uint8_t Key0;
uint8_t Key1;
uint8_t Key2;
uint8_t Key3;
uint8_t Key4;
uint8_t Key5;
uint8_t Key6;
uint8_t Key7;
uint8_t Key8;
uint8_t Key10;
void setup() {
Keyboard.begin();
// led pin
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
// Set up pin as input
for (uint8_t i=0; i<pincount; i++)
{
pinMode(pins[i], INPUT_PULLUP);// pinMode(0, INPUT_PULLUP); 0 to 8
}
}
<details closed>
<summary>map2_for_b2.ino</summary>
<pre>
/*
XIAO USB Keyboard.example.
http://yuichitamiya.fabcloud.io/fab16/How_to/program/
void loop() {
Key0 = digitalRead(pins[0]);
Key1 = digitalRead(pins[1]);
Key2 = digitalRead(pins[2]);
Key3 = digitalRead(pins[3]);
Key4 = digitalRead(pins[4]);
Key5 = digitalRead(pins[5]);
Key6 = digitalRead(pins[6]);
Key7 = digitalRead(pins[7]);
Key8 = digitalRead(pins[8]);
Key10 = digitalRead(pins[9]);//pin10 sensor_in
// XIAOでは、LOW = On = key pressed
if (Key0 == LOW ) {
Key0_act();
}
if (Key1 == LOW ) {
Key1_act();
}
if (Key2 == LOW ) {
Key2_act();
}
if (Key3 == LOW ) {
Key3_act();
}
if (Key4 == LOW ) {
Key4_act();
}
if (Key5 == LOW ) {
Key5_act();
}
if (Key6 == LOW ) {
Key6_act();
}
if (Key7 == LOW ) {
Key7_act();
}
if (Key8 == LOW ) {
Key8_act();
}
if (Key10 == LOW ) {//pin10 sensor_in
Key3_act();
}
}
Google map help
https://support.google.com/maps/answer/6396990?co=GENIE.Platform%3DDesktop&hl=ja
Ctrl+/ to show help menu
*/
// https://github.com/cyborg5/TinyUSB_Mouse_and_Keyboard
#include <TinyUSB_Mouse_and_Keyboard.h>
void Key0_act() {
// <-
Keyboard.press(KEY_RIGHT_ARROW);
delay(400);
Keyboard.releaseAll();
//#include &lt;TinyUSB_Mouse_and_Keyboard.h&gt;
//HID KEYCODE
//https://www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardmodifiers/
//uint8_t pins[] = { A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 }; //A9:no-use,A10:JACK_L
uint8_t pins[] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 10}; //9:no-use, 10:JACK_L
uint8_t pincount = sizeof(pins)/sizeof(pins[0]);
/*
Board 2
|8|4|3|
|6|<|>|
|5|0|1|
|7|x|2|
*/
uint8_t Key0;
uint8_t Key1;
uint8_t Key2;
uint8_t Key3;
uint8_t Key4;
uint8_t Key5;
uint8_t Key6;
uint8_t Key7;
uint8_t Key8;
uint8_t Key10;
void setup() {
Keyboard.begin();
// led pin
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
// Set up pin as input
for (uint8_t i=0; i<pincount; i++)
{
pinMode(pins[i], INPUT_PULLUP);// pinMode(0, INPUT_PULLUP); 0 to 8
digitalWrite(LED_BUILTIN, LOW);// XIAOでは、LOW = On
KeyRelease();
}
}
void loop() {
void Key1_act() {
// ->
Keyboard.press(KEY_LEFT_ARROW);
delay(400);
Keyboard.releaseAll();
Key0 = digitalRead(pins[0]);
Key1 = digitalRead(pins[1]);
Key2 = digitalRead(pins[2]);
Key3 = digitalRead(pins[3]);
Key4 = digitalRead(pins[4]);
Key5 = digitalRead(pins[5]);
Key6 = digitalRead(pins[6]);
Key7 = digitalRead(pins[7]);
Key8 = digitalRead(pins[8]);
Key10 = digitalRead(pins[9]);//pin10 sensor_in
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
void Key2_act() {
// down arrow
Keyboard.press(KEY_DOWN_ARROW);
Keyboard.releaseAll();
// XIAOでは、LOW = On = key pressed
if (Key0 == LOW ) {
Key0_act();
}
if (Key1 == LOW ) {
Key1_act();
}
if (Key2 == LOW ) {
Key2_act();
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
if (Key3 == LOW ) {
Key3_act();
void Key3_act() {
// up arrow
Keyboard.press(KEY_UP_ARROW);
Keyboard.releaseAll();
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
if (Key4 == LOW ) {
Key4_act();
void Key4_act() {
// move to right tab
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_RIGHT_ALT);
Keyboard.press(KEY_RIGHT_ARROW);
Keyboard.releaseAll();
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
if (Key5 == LOW ) {
Key5_act();
/*
Board 2
|8|4|3|
|6|<|>|
|5|0|1|
|7|x|2|
*/
void Key8_act() {
//select url
Keyboard.press(KEY_LEFT_GUI);
Keyboard.write('l');
Keyboard.releaseAll();
delay(100);
//copy
Keyboard.press(KEY_LEFT_GUI);
Keyboard.write('c');
Keyboard.releaseAll();
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
if (Key6 == LOW ) {
Key6_act();
void Key6_act() {
//move to left tab
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_RIGHT_ALT);
Keyboard.press(KEY_LEFT_ARROW);
// run spreadsheet script
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_RIGHT_ALT);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.write('1');
Keyboard.releaseAll();
delay(3000);
// paste
Keyboard.press(KEY_LEFT_GUI);
Keyboard.write('v');
Keyboard.releaseAll();
delay(100);
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
if (Key7 == LOW ) {
Key7_act();
void Key5_act() {
// move to right tab
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_RIGHT_ALT);
Keyboard.press(KEY_RIGHT_ARROW);
Keyboard.releaseAll();
// tab to forcus screen
Keyboard.press(KEY_TAB);
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
if (Key8 == LOW ) {
Key8_act();
void Key7_act() {
// tab to forcus screen
Keyboard.press(KEY_TAB);
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
if (Key10 == LOW ) {//pin10 sensor_in
Key3_act();
void KeyRelease() {
Keyboard.releaseAll();
delay(500);
digitalWrite(LED_BUILTIN, HIGH);// XIAOでは、HIGH = Off
}
}
void Key0_act() {
// <-
Keyboard.press(KEY_RIGHT_ARROW);
delay(400);
Keyboard.releaseAll();
digitalWrite(LED_BUILTIN, LOW);// XIAOでは、LOW = On
KeyRelease();
}
void Key1_act() {
// ->
Keyboard.press(KEY_LEFT_ARROW);
delay(400);
Keyboard.releaseAll();
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
void Key2_act() {
// down arrow
Keyboard.press(KEY_DOWN_ARROW);
Keyboard.releaseAll();
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
void Key3_act() {
// up arrow
Keyboard.press(KEY_UP_ARROW);
Keyboard.releaseAll();
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
void Key4_act() {
// move to right tab
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_RIGHT_ALT);
Keyboard.press(KEY_RIGHT_ARROW);
Keyboard.releaseAll();
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
/*
Board 2
|8|4|3|
|6|<|>|
|5|0|1|
|7|x|2|
*/
void Key8_act() {
//select url
Keyboard.press(KEY_LEFT_GUI);
Keyboard.write('l');
Keyboard.releaseAll();
delay(100);
//copy
Keyboard.press(KEY_LEFT_GUI);
Keyboard.write('c');
Keyboard.releaseAll();
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
void Key6_act() {
//move to left tab
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_RIGHT_ALT);
Keyboard.press(KEY_LEFT_ARROW);
// run spreadsheet script
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_RIGHT_ALT);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.write('1');
Keyboard.releaseAll();
delay(3000);
// paste
Keyboard.press(KEY_LEFT_GUI);
Keyboard.write('v');
Keyboard.releaseAll();
delay(100);
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
void Key5_act() {
// move to right tab
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_RIGHT_ALT);
Keyboard.press(KEY_RIGHT_ARROW);
Keyboard.releaseAll();
// tab to forcus screen
Keyboard.press(KEY_TAB);
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
void Key7_act() {
// tab to forcus screen
Keyboard.press(KEY_TAB);
digitalWrite(LED_BUILTIN, LOW);
KeyRelease();
}
void KeyRelease() {
Keyboard.releaseAll();
delay(500);
digitalWrite(LED_BUILTIN, HIGH);// XIAOでは、HIGH = Off
}
</pre>
</details>
```
---
## Case
......
# make_drone_controller
## DJI Flight Simulator
[DJI Flight Simulator](https://www.dji.com/simulator)
[Download Software](https://www.dji.com/downloads/products/simulator)
---
### Manual
[Download User Manual](https://dl.djicdn.com/downloads/simulator/20200612/DJI_Flight_Simulator_User_Manual_v1.4_EN.pdf)
![](../images/make/drone_controller.png){width=600}
![](../images/make/drone_keyboard.png){width=600}