Last commit was wrong... now all versions aof Passkey are here... :)
This commit is contained in:
parent
9282cba259
commit
92d0aef82b
10 changed files with 407 additions and 0 deletions
30
Blinker/LICENSE.md
Normal file
30
Blinker/LICENSE.md
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
Copyright (c) 2015, Majenko Technologies
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of Majenko Technologies nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
9
Blinker/README.md
Normal file
9
Blinker/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
Blinker Library
|
||||||
|
===============
|
||||||
|
|
||||||
|
This very simple little library will cause an output
|
||||||
|
to "blink" - that is repeatedly go HIGH then LOW with a
|
||||||
|
requested delay.
|
||||||
|
|
||||||
|
The operation is completely non-blocking, so you can
|
||||||
|
blink an output while doing other things.
|
||||||
54
Blinker/examples/BlinkTest/BlinkTest.ino
Normal file
54
Blinker/examples/BlinkTest/BlinkTest.ino
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Majenko Technologies
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* * Neither the name of Majenko Technologies nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Blinker.h>
|
||||||
|
|
||||||
|
// Most boards have an LED on pin 13. Let's blink it.
|
||||||
|
Blinker blinker(13);
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
// The blinker defaults to 500ms delay, which is a 1 second period blinking.
|
||||||
|
// Let's make it faster - say 250ms delay.
|
||||||
|
blinker.setDelay(250);
|
||||||
|
|
||||||
|
// There is also an asymetric blink delay version which takes two delay values,
|
||||||
|
// one for the ON time and one for the OFF time:
|
||||||
|
// blinker.setDelay(50, 950);
|
||||||
|
|
||||||
|
// Start the blinker blinking. There's also a blinker.stop() function.
|
||||||
|
blinker.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// As long as you keep calling this method the output will toggle
|
||||||
|
// with the requested delay. It's non-blocking so you can do othe
|
||||||
|
// things while blinking.
|
||||||
|
blinker.blink();
|
||||||
|
}
|
||||||
13
Blinker/library.json
Normal file
13
Blinker/library.json
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"name": "Blinker",
|
||||||
|
"keywords": "led, blink",
|
||||||
|
"description": "Non-blocking LED blinking class",
|
||||||
|
"repository":
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/MajenkoLibraries/Blinker"
|
||||||
|
},
|
||||||
|
"version": "1.0.3",
|
||||||
|
"frameworks": "arduino",
|
||||||
|
"platforms": "*"
|
||||||
|
}
|
||||||
10
Blinker/library.properties
Normal file
10
Blinker/library.properties
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
name=Blinker
|
||||||
|
version=1.0.4
|
||||||
|
author=Matt Jenkins
|
||||||
|
maintainer=Matt Jenkins <matt@majenko.co.uk>
|
||||||
|
sentence=Blink an output in different patterns
|
||||||
|
paragraph=Blinker Library\n===============\n\nThis very simple little library will cause an output\nto "blink" - that is repeatedly go HIGH then LOW with a \nrequested delay.\n\nThe operation is completely non-blocking, so you can\nblink an output while doing other things.\n
|
||||||
|
url=https://github.com/MajenkoLibraries/Blinker
|
||||||
|
category=Signal Input/Output
|
||||||
|
architectures=*
|
||||||
|
includes=Blinker.h
|
||||||
44
Blinker/src/Blinker.cpp
Normal file
44
Blinker/src/Blinker.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
#include <Blinker.h>
|
||||||
|
|
||||||
|
Blinker::Blinker(int pin) {
|
||||||
|
_blinkPin = pin;
|
||||||
|
_highDelay = 500;
|
||||||
|
_lowDelay = 500;
|
||||||
|
_lastBlink = 0;
|
||||||
|
_blinkState = false;
|
||||||
|
_running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Blinker::setDelay(uint32_t d) {
|
||||||
|
_highDelay = d;
|
||||||
|
_lowDelay = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Blinker::setDelay(uint32_t h, uint32_t l) {
|
||||||
|
_highDelay = h;
|
||||||
|
_lowDelay = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Blinker::blink() {
|
||||||
|
uint32_t diff = millis() - _lastBlink;
|
||||||
|
uint32_t blinkDelay = _blinkState ? _highDelay : _lowDelay;
|
||||||
|
if (diff >= blinkDelay) {
|
||||||
|
_lastBlink = millis() - (diff - blinkDelay); // Account for any delay in calling blink
|
||||||
|
_blinkState = !_blinkState;
|
||||||
|
if (_running) {
|
||||||
|
digitalWrite(_blinkPin, _blinkState ? HIGH : LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Blinker::start() {
|
||||||
|
pinMode(_blinkPin, OUTPUT);
|
||||||
|
_running = true;
|
||||||
|
_lastBlink = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Blinker::stop(bool idleState) {
|
||||||
|
_running = false;
|
||||||
|
_blinkState = idleState;
|
||||||
|
digitalWrite(_blinkPin, _blinkState);
|
||||||
|
}
|
||||||
28
Blinker/src/Blinker.h
Normal file
28
Blinker/src/Blinker.h
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef _BLINKER_H
|
||||||
|
#define _BLINKER_H
|
||||||
|
|
||||||
|
#if (ARDUINO >= 100)
|
||||||
|
# include <Arduino.h>
|
||||||
|
#else
|
||||||
|
# include <WProgram.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class Blinker {
|
||||||
|
private:
|
||||||
|
int _blinkPin;
|
||||||
|
uint32_t _highDelay;
|
||||||
|
uint32_t _lowDelay;
|
||||||
|
uint32_t _lastBlink;
|
||||||
|
boolean _blinkState;
|
||||||
|
boolean _running;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Blinker(int pin);
|
||||||
|
void setDelay(uint32_t d);
|
||||||
|
void setDelay(uint32_t h, uint32_t l);
|
||||||
|
void blink();
|
||||||
|
void start();
|
||||||
|
void stop(bool idleState = LOW);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
1
Blinker/uecide.json
Normal file
1
Blinker/uecide.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"name":"Blinker","provides":"Blinker.h","license":"LICENSE.md","readme":"README.md","description":"Blink an output in different patterns","category":"IO","subcategory":"Digital","maintainer":"Matt Jenkins <matt@majenko.co.uk>","version":"1.0.4","family":"all","core":"all","install":{"examples":"\/","library.properties":"\/","src":"\/"}}
|
||||||
109
Digispark_Passkey.ino
Normal file
109
Digispark_Passkey.ino
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
// Passkey for Arduino using the Digispark Rev.3 board.
|
||||||
|
// Copyright 2022 by Johannes Findeisen <you@hanez.org>
|
||||||
|
// Licensed under the terms of the MIT license.
|
||||||
|
|
||||||
|
// For using the Blinker library you have to install it from:
|
||||||
|
// https://github.com/MajenkoLibraries/Blinker
|
||||||
|
// Since the code is included in Passkey you easily can just copy
|
||||||
|
// Blinker/src/Blinker.cpp and Blinker/src/Blinker.h to the root of
|
||||||
|
// Passkey.
|
||||||
|
#include "Blinker.h"
|
||||||
|
#include "DigiKeyboard.h"
|
||||||
|
|
||||||
|
// The button pin
|
||||||
|
#define BUTTON_PIN 0
|
||||||
|
// The LED pin
|
||||||
|
#define LED_PIN 1
|
||||||
|
// The pause after last button press before executing a command
|
||||||
|
#define PAUSE 2000
|
||||||
|
|
||||||
|
// Local variables
|
||||||
|
unsigned long last;
|
||||||
|
unsigned int count;
|
||||||
|
|
||||||
|
// Create blinker object
|
||||||
|
Blinker blinker(LED_PIN);
|
||||||
|
|
||||||
|
// The list of available passwords
|
||||||
|
// The number and overall lenght of passwords depends
|
||||||
|
// because the memory of the digispark is very limited...
|
||||||
|
// I recommend to use a prefix you easily can remember
|
||||||
|
// for the password/passwords to make the passwords
|
||||||
|
// on the passkey unusable for others in case you've lost
|
||||||
|
// your passkey. E.g.: WhatAWonderfulWorld -> then press the button.
|
||||||
|
const char *passwords[] = {
|
||||||
|
// passwords[0]
|
||||||
|
"n0Emb871NAQPSIqBoldh8R7UDaNhncF7Pt60Amdo6GWdTdAPwVBi2A3KU8x8DTCRo6GWdTdXNn2wLh3SUbxVWQvFDVPtatDg",
|
||||||
|
// passwords[1]
|
||||||
|
"oaxt6e3lSgflOuJ3C6Q6sUb5gvmvI5IEPFku5fqcbxJljBOUblHIT121wCu",
|
||||||
|
// passwords[2]
|
||||||
|
"jUgKGBtiJ0iNN1Ok9vejrXNn2wLh3SUbxVWQvFDVPtat0OxJlKU8x8DTCRo6GWdTdAPwVBi2A3KUrTKQwjUgK",
|
||||||
|
// passwords[3]
|
||||||
|
"G57dFnXsPUnRq1eC1CjrGxpCjuiJFlDti54W6wBS9Ro6GWdTdAPwVBi2A3KU8x8KGBtiJ0iNN1Ok9vejrXNn2wLhH"
|
||||||
|
};
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
// Set button pin to high.
|
||||||
|
pinMode(BUTTON_PIN, INPUT);
|
||||||
|
// Set BUTTON_PIN pin to high because the button is connected
|
||||||
|
// to GND when pressed and will go LOW
|
||||||
|
digitalWrite(BUTTON_PIN, HIGH);
|
||||||
|
|
||||||
|
// Set blink effect (ON, OFF) in milliseconds
|
||||||
|
blinker.setDelay(25, 9075);
|
||||||
|
blinker.start();
|
||||||
|
|
||||||
|
// Initialize HID
|
||||||
|
DigiKeyboard.delay(0);
|
||||||
|
DigiKeyboard.sendKeyStroke(0);
|
||||||
|
|
||||||
|
// Light up the LED for a second to show that passkey is ready
|
||||||
|
pinMode(LED_PIN, OUTPUT);
|
||||||
|
digitalWrite(LED_PIN, HIGH);
|
||||||
|
delay(1000);
|
||||||
|
digitalWrite(LED_PIN, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// Start LED blink effect
|
||||||
|
blinker.blink();
|
||||||
|
|
||||||
|
// Read button state
|
||||||
|
if (digitalRead(BUTTON_PIN) == LOW) {
|
||||||
|
// Button is pressed
|
||||||
|
count++;
|
||||||
|
digitalWrite(LED_PIN, HIGH);
|
||||||
|
// Wait until button is released
|
||||||
|
while (digitalRead(BUTTON_PIN) == LOW) {
|
||||||
|
delay(1);
|
||||||
|
}
|
||||||
|
// Set the last press timestamp
|
||||||
|
last = millis();
|
||||||
|
digitalWrite(LED_PIN, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait PAUSE time before executing a command
|
||||||
|
if (count > 0 && (millis() - last) >= PAUSE) {
|
||||||
|
// The switch case is the number of button presses
|
||||||
|
switch (count) {
|
||||||
|
case 1:
|
||||||
|
DigiKeyboard.println(passwords[0]);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
DigiKeyboard.println(passwords[1]);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
DigiKeyboard.println(passwords[2]);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
// You can use print instead of println if you don't want
|
||||||
|
// to hit enter automatically after inserting the password
|
||||||
|
DigiKeyboard.print(passwords[3]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Reset the counter
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
109
Digispark_Passkey3.ino
Normal file
109
Digispark_Passkey3.ino
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
// Passkey for Arduino using the Digispark Rev.3 board.
|
||||||
|
// Copyright 2022 by Johannes Findeisen <you@hanez.org>
|
||||||
|
// Licensed under the terms of the MIT license.
|
||||||
|
|
||||||
|
// For using the Blinker library you have to install it from:
|
||||||
|
// https://github.com/MajenkoLibraries/Blinker
|
||||||
|
// Since the code is included in Passkey you easily can just copy
|
||||||
|
// Blinker/src/Blinker.cpp and Blinker/src/Blinker.h to the root of
|
||||||
|
// Passkey.
|
||||||
|
#include "Blinker.h"
|
||||||
|
#include "DigiKeyboard.h"
|
||||||
|
|
||||||
|
// The button pin
|
||||||
|
#define BUTTON_PIN 0
|
||||||
|
// The LED pin
|
||||||
|
#define LED_PIN 1
|
||||||
|
// The pause after last button press before executing a command
|
||||||
|
#define PAUSE 2000
|
||||||
|
|
||||||
|
// Local variables
|
||||||
|
unsigned long last;
|
||||||
|
unsigned int count;
|
||||||
|
|
||||||
|
// Create blinker object
|
||||||
|
Blinker blinker(LED_PIN);
|
||||||
|
|
||||||
|
// The list of available passwords
|
||||||
|
// The number and overall lenght of passwords depends
|
||||||
|
// because the memory of the digispark is very limited...
|
||||||
|
// I recommend to use a prefix you easily can remember
|
||||||
|
// for the password/passwords to make the passwords
|
||||||
|
// on the passkey unusable for others in case you've lost
|
||||||
|
// your passkey. E.g.: WhatAWonderfulWorld -> then press the button.
|
||||||
|
const char *passwords[] = {
|
||||||
|
// passwords[0]
|
||||||
|
"n0Emb871NAQPSIqBoldh8R7UDaNhncF7Pt60Amdo6GWdTdAPwVBi2A3KU8x8DTCRo6GWdTdXNn2wLh3SUbxVWQvFDVPtatDg",
|
||||||
|
// passwords[1]
|
||||||
|
"oaxt6e3lSgflOuJ3C6Q6sUb5gvmvI5IEPFku5fqcbxJljBOUblHIT121wCu",
|
||||||
|
// passwords[2]
|
||||||
|
"jUgKGBtiJ0iNN1Ok9vejrXNn2wLh3SUbxVWQvFDVPtat0OxJlKU8x8DTCRo6GWdTdAPwVBi2A3KUrTKQwjUgK",
|
||||||
|
// passwords[3]
|
||||||
|
"G57dFnXsPUnRq1eC1CjrGxpCjuiJFlDti54W6wBS9Ro6GWdTdAPwVBi2A3KU8x8KGBtiJ0iNN1Ok9vejrXNn2wLhH"
|
||||||
|
};
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
// Set button pin to be INPUT.
|
||||||
|
pinMode(BUTTON_PIN, INPUT);
|
||||||
|
// Set BUTTON_PIN pin to HIGH because the button is connected
|
||||||
|
// to GND when pressed and will go LOW
|
||||||
|
digitalWrite(BUTTON_PIN, HIGH);
|
||||||
|
|
||||||
|
// Set blink effect (ON, OFF) in milliseconds
|
||||||
|
blinker.setDelay(25, 9075);
|
||||||
|
blinker.start();
|
||||||
|
|
||||||
|
// Initialize HID
|
||||||
|
DigiKeyboard.delay(0);
|
||||||
|
DigiKeyboard.sendKeyStroke(0);
|
||||||
|
|
||||||
|
// Light up the LED for a second to show that passkey is ready
|
||||||
|
pinMode(LED_PIN, OUTPUT);
|
||||||
|
digitalWrite(LED_PIN, HIGH);
|
||||||
|
delay(1000);
|
||||||
|
digitalWrite(LED_PIN, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// Start LED blink effect
|
||||||
|
blinker.blink();
|
||||||
|
|
||||||
|
// Read button state
|
||||||
|
if (digitalRead(BUTTON_PIN) == LOW) {
|
||||||
|
// Button is pressed
|
||||||
|
count++;
|
||||||
|
digitalWrite(LED_PIN, HIGH);
|
||||||
|
// Wait until button is released
|
||||||
|
while (digitalRead(BUTTON_PIN) == LOW) {
|
||||||
|
delay(1);
|
||||||
|
}
|
||||||
|
// Set the last press timestamp
|
||||||
|
last = millis();
|
||||||
|
digitalWrite(LED_PIN, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait PAUSE time before executing a command
|
||||||
|
if (count > 0 && (millis() - last) >= PAUSE) {
|
||||||
|
// The switch case is the number of button presses
|
||||||
|
switch (count) {
|
||||||
|
case 1:
|
||||||
|
DigiKeyboard.println(passwords[0]);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
DigiKeyboard.println(passwords[1]);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
DigiKeyboard.println(passwords[2]);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
// You can use print instead of println if you don't want
|
||||||
|
// to hit enter automatically after inserting the password
|
||||||
|
DigiKeyboard.print(passwords[3]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Reset the counter
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue