Added digispark
This commit is contained in:
16
README.md
16
README.md
@@ -2,14 +2,22 @@
|
||||
Worship switcher is a simple device for switching chord-sheet pages on the fly.
|
||||
|
||||
## Hardware
|
||||
WorshipSwitcher is designed arround the Arduino Pro Micro. All you need to build your own is:
|
||||
* Arduino Pro Micro (Make sure it is a Pro Micro and not a Pro Mini)
|
||||
WorshipSwitcher is designed arround the Arduino Pro Micro and the Digispark. All you need to build your own is:
|
||||
* Arduino Pro Micro (Make sure it is a Pro Micro and not a Pro Mini) or Digispark
|
||||
* Two push buttons
|
||||
|
||||
The Push-Buttons connect to Pin 8 and 9. Pins 8 and 9 are configured as active-low with internal oush.up resistors. Therefore the switches need to be connected against ground.
|
||||
### Wiring for the Arduino Pro Micro
|
||||
The Push-Buttons connect to Pin 8 and 9. Pins 8 and 9 are configured as active-low with internal pushup resistors. Therefore the switches need to be connected against ground.
|
||||
|
||||
### Wiring for the Digispark
|
||||
The Push-Buttons connect to P0 and P2. Pins P0 and P2 are configured as active-low with internal pushup resistors. Therefore the switches need to be connected against ground.
|
||||
Pin P1 is connected to the internal LED. It blinks when the USb Keybioard is initialized and it is ready to be used.
|
||||
|
||||
## Software
|
||||
The firmware is designed for Acrobat Reader for iOS in Single Page mode.
|
||||
The firmware is designed for Acrobat Reader for iOS in Single Page mode. It also works with OnSong.
|
||||
|
||||
The mapped keycodes are PAGE_UP and PAGE_DOWN.
|
||||
In onsong, this mimics the behaviour of the AirTurn Pedals and can be mapped to various functions.
|
||||
|
||||
## Usage
|
||||
### Button 1 - Back / Top
|
||||
|
||||
88
firmware_digispark/firmware_digispark.ino
Normal file
88
firmware_digispark/firmware_digispark.ino
Normal file
@@ -0,0 +1,88 @@
|
||||
#include "DigiKeyboard.h"
|
||||
|
||||
#define SW_1_PIN 0
|
||||
#define SW_2_PIN 2
|
||||
#define debounceTimeConst 200 //debounce time in ms
|
||||
|
||||
unsigned long sw1_debounce = 0; //debounce var (last time button was pressed)
|
||||
unsigned long sw2_debounce = 0; //debounce var (last time button was pressed)
|
||||
void setup() {
|
||||
// don't need to set anything up to use DigiKeyboard
|
||||
pinMode(SW_1_PIN, INPUT_PULLUP);
|
||||
pinMode(SW_2_PIN, INPUT_PULLUP);
|
||||
DigiKeyboard.sendKeyStroke(0);
|
||||
DigiKeyboard.delay(100);
|
||||
}
|
||||
|
||||
int ledState = LOW; // ledState used to set the LED
|
||||
unsigned long previousMillis = 0; // will store last time LED was updated
|
||||
|
||||
|
||||
void loop() {
|
||||
unsigned long now = millis(); //timestamp of start of loop
|
||||
// debounce button 1
|
||||
if(digitalRead(SW_1_PIN) == false){
|
||||
if(sw1_debounce + debounceTimeConst < now){
|
||||
unsigned long pressed = millis(); //store time when button is pressed
|
||||
delay(150); //initial delay to compensate bounce
|
||||
while( digitalRead(SW_1_PIN) == false ){
|
||||
// wait for button release
|
||||
}
|
||||
if (pressed + 1000 > millis() ) {
|
||||
// pressed shorter than 1s
|
||||
pdf_up();
|
||||
}else{
|
||||
// pressed longer than 1s
|
||||
pdf_top();
|
||||
}
|
||||
}
|
||||
sw1_debounce = now;
|
||||
}
|
||||
|
||||
// debounce button 2
|
||||
if(digitalRead(SW_2_PIN) == false){
|
||||
if(sw2_debounce + debounceTimeConst < now){ pdf_down(); }
|
||||
sw2_debounce = now;
|
||||
}
|
||||
//Serial.println(sw1_debounce);
|
||||
|
||||
unsigned long currentMillis = millis();
|
||||
if (currentMillis - previousMillis >= 500) {
|
||||
previousMillis = currentMillis;
|
||||
if (ledState == LOW) {
|
||||
ledState = HIGH;
|
||||
} else {
|
||||
ledState = LOW;
|
||||
}
|
||||
digitalWrite(1, ledState);
|
||||
}
|
||||
}
|
||||
|
||||
#define KEY_RIGHT_ARROW 0x4F // Keyboard RightArrow -> Alternative arrow keys names
|
||||
#define KEY_LEFT_ARROW 0x50 // Keyboard LeftArrow
|
||||
#define KEY_DOWN_ARROW 0x51 // Keyboard DownArrow
|
||||
#define KEY_UP_ARROW 0x52 // Keyboard UpArrow
|
||||
#define KEY_PAGE_UP 0x4B // Keyboard PageUp
|
||||
#define KEY_DELETE 0x4C // Keyboard Delete Forward
|
||||
#define KEY_END 0x4D // Keyboard End
|
||||
#define KEY_PAGE_DOWN 0x4E // Keyboard PageDown
|
||||
#define KEY_HOME 0x4A // Keyboard Home
|
||||
//Keyborad Event definitions
|
||||
|
||||
void pdf_up() {
|
||||
DigiKeyboard.sendKeyStroke(KEY_PAGE_UP);
|
||||
//Keyboard.press(KEY_LEFT_ARROW);
|
||||
DigiKeyboard.delay(100);
|
||||
}
|
||||
|
||||
void pdf_down() {
|
||||
DigiKeyboard.sendKeyStroke(KEY_PAGE_DOWN);
|
||||
//Keyboard.press(KEY_RIGHT_ARROW);
|
||||
DigiKeyboard.delay(100);
|
||||
}
|
||||
|
||||
void pdf_top() {
|
||||
DigiKeyboard.sendKeyStroke(KEY_HOME);
|
||||
//Keyboard.press(KEY_RIGHT_ARROW);
|
||||
DigiKeyboard.delay(100);
|
||||
}
|
||||
Reference in New Issue
Block a user