Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- What is it?
- -----------
- Controller for Youtube video playback: Pause/Play (k), Backward (j)/Forward (l), Volume Up (up)/Down (down).
- The Latest Version
- ------------------
- Versioning is not applicable for this repo.
- Documentation
- -------------
- You can read in header of files and, maybe, README for each folder will be created.
- Requirements
- ------------
- Gyver EncButton library https://github.com/GyverLibs/EncButton
- Installation
- ------------
- Arduino IDE => Tools => Board => "Arduino Leonardo"
- Licensing
- ---------
- Please see the file called LICENSE.
- Contacts
- --------
- If you have a concrete bug report please contact me via email.
- Connections
- ----------
- Arduino Leonardo or same
- S1 - D3
- S2 - D2
- Key - D4
- Miscellaneous
- ----------
- Keyboard shortcut Function
- Spacebar Play/Pause when the seek bar is selected. Activate a button if a button has focus.
- k Pause/Play in player.
- m Mute/unmute the video.
- Left/Right Seek backward/forward 5 seconds.
- j Seek backward 10 seconds in player.
- l Seek forward 10 seconds in player.
- . While the video is paused, skip to the next frame.
- , While the video is paused, go back to the previous frame.
- > Speed up the video playback rate.
- < Slow down the video playback rate.
- Up/Down Increase/Decrease volume 5%.
- Numbers 1 to 9 Seek to the 10% to 90% of the video.
- Number 0 Seek to the beginning of the video.
- / Go to search box.
- f Activate full screen.
- c Activate closed captions and subtitles if available.
- Shift+N Move to the next video
- Shift+P Move to the previous video.
- i Open the Miniplayer.
- Controller for Youtube video playback:
- Pause/Play (k),
- Backward (j)/Forward (l),
- Volume Up (up)/Down (down).
- */
- #include <Arduino.h>
- #include <Keyboard.h>
- #include <EncButton.h>
- const int ENCA = 2;
- const int ENCB = 3;
- const int BTN = 4;
- EncButton enc(ENCA, ENCB, BTN);
- volatile int value = 0;
- volatile int step = 3; //1 шаг за каждые step сигналов энкодера, чтобы снизить чувствительность (так удобнее)
- void setup() {
- Serial.begin(115200);
- enc.setEncType(EB_STEP4_LOW);
- // показаны значения по умолчанию
- enc.setBtnLevel(LOW);
- enc.setClickTimeout(500);
- enc.setDebTimeout(50);
- enc.setHoldTimeout(600);
- enc.setStepTimeout(200);
- enc.setEncReverse(0);
- enc.setFastTimeout(30);
- }
- void loop() {
- enc.tick(); // опрос происходит здесь
- if (enc.right())
- {
- value = value + step; //поворот вправо
- }
- if (enc.left())
- {
- value = value - step; //поворот влево
- }
- if (enc.leftH()) {
- Keyboard.press(KEY_UP_ARROW);
- delay(10);
- Keyboard.releaseAll();
- }
- if (enc.rightH()) {
- Keyboard.press(KEY_DOWN_ARROW);
- delay(10);
- Keyboard.releaseAll();
- }
- if (enc.click()) {
- Keyboard.press('K');
- delay(10);
- Keyboard.releaseAll();
- }
- if (value > 9) {
- Keyboard.press('J'); // каждые value поворотов вправо нажимаем J
- delay(10);
- Keyboard.releaseAll();
- value = 0;
- }
- if (value < -9) {
- Keyboard.press('L'); // каждые value поворотов влево нажимаем
- delay(10);
- Keyboard.releaseAll();
- value = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement