mirror of
https://github.com/digistump/DigistumpArduino.git
synced 2025-09-18 09:52:23 -07:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
158d655dfa | ||
![]() |
de2937f691 | ||
![]() |
2f74dc9204 | ||
![]() |
4dd9d246e8 | ||
![]() |
260c1e1da0 | ||
![]() |
556095de2d | ||
![]() |
f1f8616ba4 |
@@ -4,7 +4,7 @@ DigistumpArduino
|
|||||||
Files to add Digistump support (Digispark, Pro, DigiX) to Arduino 1.5.X (1.5.7+)
|
Files to add Digistump support (Digispark, Pro, DigiX) to Arduino 1.5.X (1.5.7+)
|
||||||
|
|
||||||
|
|
||||||
**Binary downloads of the bundled IDE can be found here:**
|
**Binary downloads of the bundled IDE can be found here:** https://github.com/digistump/DigistumpArduino/releases/tag/v1.5.8A
|
||||||
|
|
||||||
To manually install:
|
To manually install:
|
||||||
|
|
||||||
|
@@ -31,6 +31,10 @@ static uchar rt_usbHidReportDescriptorSize = 0;
|
|||||||
static const uchar *rt_usbDeviceDescriptor = NULL;
|
static const uchar *rt_usbDeviceDescriptor = NULL;
|
||||||
static uchar rt_usbDeviceDescriptorSize = 0;
|
static uchar rt_usbDeviceDescriptorSize = 0;
|
||||||
|
|
||||||
|
#define MOUSEBTN_LEFT_MASK 0x01
|
||||||
|
#define MOUSEBTN_RIGHT_MASK 0x02
|
||||||
|
#define MOUSEBTN_MIDDLE_MASK 0x04
|
||||||
|
|
||||||
// TODO: Work around Arduino 12 issues better.
|
// TODO: Work around Arduino 12 issues better.
|
||||||
//#include <WConstants.h>
|
//#include <WConstants.h>
|
||||||
//#undef int()
|
//#undef int()
|
||||||
@@ -53,6 +57,7 @@ static unsigned char idle_rate = DIGIMOUSE_DEFAULT_REPORT_INTERVAL / 4; // in un
|
|||||||
static unsigned long last_report_time = 0;
|
static unsigned long last_report_time = 0;
|
||||||
|
|
||||||
|
|
||||||
|
char usb_hasCommed = 0;
|
||||||
|
|
||||||
const PROGMEM unsigned char mouse_usbHidReportDescriptor[] = { /* USB report descriptor */
|
const PROGMEM unsigned char mouse_usbHidReportDescriptor[] = { /* USB report descriptor */
|
||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||||
@@ -89,7 +94,7 @@ const PROGMEM unsigned char mouse_usbHidReportDescriptor[] = { /* USB report des
|
|||||||
|
|
||||||
#define USBDESCR_DEVICE 1
|
#define USBDESCR_DEVICE 1
|
||||||
|
|
||||||
unsigned const char usbDescrDevice[] PROGMEM = { /* USB device descriptor */
|
const unsigned char usbDescrDevice[] PROGMEM = { /* USB device descriptor */
|
||||||
18, /* sizeof(usbDescrDevice): length of descriptor in bytes */
|
18, /* sizeof(usbDescrDevice): length of descriptor in bytes */
|
||||||
USBDESCR_DEVICE, /* descriptor type */
|
USBDESCR_DEVICE, /* descriptor type */
|
||||||
0x01, 0x01, /* USB version supported */
|
0x01, 0x01, /* USB version supported */
|
||||||
@@ -145,16 +150,18 @@ void clearMove() {
|
|||||||
class DigiMouseDevice {
|
class DigiMouseDevice {
|
||||||
public:
|
public:
|
||||||
DigiMouseDevice () {
|
DigiMouseDevice () {
|
||||||
// this timer stuff doesn't even make sense - it seems like someone got some code for Timer1
|
|
||||||
// and haphazardly changed the 1's in the register names to 0's, but the two timers don't work
|
|
||||||
// the same way, so this code doesn't do what it says at all. Is it even useful to have?
|
|
||||||
/* configure timer 0 for a rate of 16M5/(1024 * 256) = 62.94 Hz (~16ms) */
|
|
||||||
//TCCR0A = 5; /* timer 0 prescaler: 1024 */
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
char isConnected()
|
||||||
|
{
|
||||||
|
return usb_hasCommed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void begin(){
|
||||||
|
|
||||||
//TIMSK &= !(1<TOIE0);//interrupt off
|
|
||||||
cli();
|
cli();
|
||||||
|
PORTB &= ~(_BV(USB_CFG_DMINUS_BIT) | _BV(USB_CFG_DPLUS_BIT));
|
||||||
usbDeviceDisconnect();
|
usbDeviceDisconnect();
|
||||||
_delay_ms(250);
|
_delay_ms(250);
|
||||||
usbDeviceConnect();
|
usbDeviceConnect();
|
||||||
@@ -171,6 +178,16 @@ class DigiMouseDevice {
|
|||||||
last_report_time = millis();
|
last_report_time = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void refresh() {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void poll() {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
usbPoll();
|
usbPoll();
|
||||||
|
|
||||||
@@ -232,6 +249,28 @@ class DigiMouseDevice {
|
|||||||
last_built_report[3] = *(reinterpret_cast<unsigned char *>(&deltaS));
|
last_built_report[3] = *(reinterpret_cast<unsigned char *>(&deltaS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void move(char deltaX, char deltaY, char deltaS, char buttons) {
|
||||||
|
if (deltaX == -128) deltaX = -127;
|
||||||
|
if (deltaY == -128) deltaY = -127;
|
||||||
|
if (deltaS == -128) deltaS = -127;
|
||||||
|
last_built_report[0] = buttons;
|
||||||
|
last_built_report[1] = *(reinterpret_cast<unsigned char *>(&deltaX));
|
||||||
|
last_built_report[2] = *(reinterpret_cast<unsigned char *>(&deltaY));
|
||||||
|
last_built_report[3] = *(reinterpret_cast<unsigned char *>(&deltaS));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rightClick(){
|
||||||
|
last_built_report[0] = MOUSEBTN_RIGHT_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void leftClick(){
|
||||||
|
last_built_report[0] = MOUSEBTN_RIGHT_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void middleClick(){
|
||||||
|
last_built_report[0] = MOUSEBTN_RIGHT_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
void setButtons(unsigned char buttons) {
|
void setButtons(unsigned char buttons) {
|
||||||
last_built_report[0] = buttons;
|
last_built_report[0] = buttons;
|
||||||
}
|
}
|
||||||
@@ -254,6 +293,7 @@ extern "C"{
|
|||||||
// USB_PUBLIC uchar usbFunctionSetup
|
// USB_PUBLIC uchar usbFunctionSetup
|
||||||
|
|
||||||
uchar usbFunctionSetup(uchar data[8]) {
|
uchar usbFunctionSetup(uchar data[8]) {
|
||||||
|
usb_hasCommed = 1;
|
||||||
usbRequest_t *rq = (usbRequest_t *)data;
|
usbRequest_t *rq = (usbRequest_t *)data;
|
||||||
|
|
||||||
usbMsgPtr = reportBuffer;
|
usbMsgPtr = reportBuffer;
|
||||||
|
@@ -65,8 +65,8 @@ recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
|
|||||||
# AVR Uploader/Programmers tools
|
# AVR Uploader/Programmers tools
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
|
|
||||||
tools.micronucleus.cmd.path={sketchbook.path}/hardware/digistump/avr/tools/avrdude
|
tools.micronucleus.cmd.path={runtime.ide.path}/hardware/digistump/avr/tools/avrdude
|
||||||
tools.micronucleus.cmd.path.linux={sketchbook.path}/hardware/digistump/avr/tools/avrdude
|
tools.micronucleus.cmd.path.linux={runtime.ide.path}/hardware/digistump/avr/tools/avrdude
|
||||||
|
|
||||||
tools.micronucleus.upload.params.verbose=-v
|
tools.micronucleus.upload.params.verbose=-v
|
||||||
tools.micronucleus.upload.params.quiet=-q
|
tools.micronucleus.upload.params.quiet=-q
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#define NUM_DIGITAL_PINS 14
|
#define NUM_DIGITAL_PINS 14
|
||||||
#define NUM_ANALOG_INPUTS 10
|
#define NUM_ANALOG_INPUTS 10
|
||||||
#define analogInputToDigitalPin(p) ((p < 7) ? p+6 : (p ==7) ? 5 : (p==9) ? 4 : (p==10) ? 13 : -1)
|
#define analogInputToDigitalPin(p) ((p == 3) ? 23 : (p == 5) ? 21 : (p < 13 && p > 5) ? p+14 : (p ==13) ? 24 : -1)
|
||||||
|
|
||||||
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1)
|
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1)
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ static const uint8_t SDA = 0;
|
|||||||
static const uint8_t SCL = 2;
|
static const uint8_t SCL = 2;
|
||||||
|
|
||||||
//Ax constants cannot be used for digitalRead/digitalWrite/analogWrite functions, only analogRead().
|
//Ax constants cannot be used for digitalRead/digitalWrite/analogWrite functions, only analogRead().
|
||||||
static const uint8_t A4 = NUM_DIGITAL_PINS+9;
|
static const uint8_t A3 = NUM_DIGITAL_PINS+9;
|
||||||
static const uint8_t A5 = NUM_DIGITAL_PINS+7;
|
static const uint8_t A5 = NUM_DIGITAL_PINS+7;
|
||||||
static const uint8_t A6 = NUM_DIGITAL_PINS+0;
|
static const uint8_t A6 = NUM_DIGITAL_PINS+0;
|
||||||
static const uint8_t A7 = NUM_DIGITAL_PINS+1;
|
static const uint8_t A7 = NUM_DIGITAL_PINS+1;
|
||||||
@@ -108,9 +108,9 @@ static const uint8_t A13 = NUM_DIGITAL_PINS+10;
|
|||||||
|
|
||||||
|
|
||||||
#define digitalPinToPCICR(p) (&PCIFR)
|
#define digitalPinToPCICR(p) (&PCIFR)
|
||||||
#define digitalPinToPCICRbit(p) (((p) >= 3 && (p) <= 10) ? 4 : 5)
|
#define digitalPinToPCICRbit(p) (((p) >= 6 && (p) <= 13) ? PCIE0 : PCIE1)
|
||||||
#define digitalPinToPCMSK(p) (((p) >= 3 && (p) <= 10) ? (&PCMSK0) : (((p) >= 0 && (p) <= 2) ? (&PCMSK1) : ((uint8_t *)NULL)))
|
#define digitalPinToPCMSK(p) (((p) >= 6 && (p) <= 13) ? (&PCMSK0) : (&PCMSK1))
|
||||||
#define digitalPinToPCMSKbit(p) (((p) >= 3 && (p) <= 10) ? (10 - (p)) : (p))
|
#define digitalPinToPCMSKbit(p) (((p) >= 6 && (p) <= 13) ? ((p) - 6) : (((p) >= 0 && (p) <= 3) ? (p) : ((p) + 2)))
|
||||||
|
|
||||||
#ifdef ARDUINO_MAIN
|
#ifdef ARDUINO_MAIN
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] =
|
|||||||
PA, /* 10 */
|
PA, /* 10 */
|
||||||
PA,
|
PA,
|
||||||
PA,
|
PA,
|
||||||
PB, /* 15 */
|
PB, /* RESET */
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
||||||
@@ -182,8 +182,8 @@ const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
|||||||
_BV(0), /* 0 */
|
_BV(0), /* 0 */
|
||||||
_BV(1),
|
_BV(1),
|
||||||
_BV(2), /* 2 */
|
_BV(2), /* 2 */
|
||||||
_BV(3), /* 3 */
|
_BV(6), /* 3 */
|
||||||
_BV(6), /* 4 */
|
_BV(3), /* 4 */
|
||||||
_BV(7),
|
_BV(7),
|
||||||
_BV(0),
|
_BV(0),
|
||||||
_BV(1),
|
_BV(1),
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#define NUM_DIGITAL_PINS 14
|
#define NUM_DIGITAL_PINS 14
|
||||||
#define NUM_ANALOG_INPUTS 10
|
#define NUM_ANALOG_INPUTS 10
|
||||||
#define analogInputToDigitalPin(p) ((p < 7) ? p+6 : (p ==7) ? 5 : (p==9) ? 4 : (p==10) ? 13 : -1)
|
#define analogInputToDigitalPin(p) ((p == 3) ? 23 : (p == 5) ? 21 : (p < 13 && p > 5) ? p+14 : (p ==13) ? 24 : -1)
|
||||||
|
|
||||||
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1)
|
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1)
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ static const uint8_t SDA = 0;
|
|||||||
static const uint8_t SCL = 2;
|
static const uint8_t SCL = 2;
|
||||||
|
|
||||||
//Ax constants cannot be used for digitalRead/digitalWrite/analogWrite functions, only analogRead().
|
//Ax constants cannot be used for digitalRead/digitalWrite/analogWrite functions, only analogRead().
|
||||||
static const uint8_t A4 = NUM_DIGITAL_PINS+9;
|
static const uint8_t A3 = NUM_DIGITAL_PINS+9;
|
||||||
static const uint8_t A5 = NUM_DIGITAL_PINS+7;
|
static const uint8_t A5 = NUM_DIGITAL_PINS+7;
|
||||||
static const uint8_t A6 = NUM_DIGITAL_PINS+0;
|
static const uint8_t A6 = NUM_DIGITAL_PINS+0;
|
||||||
static const uint8_t A7 = NUM_DIGITAL_PINS+1;
|
static const uint8_t A7 = NUM_DIGITAL_PINS+1;
|
||||||
@@ -108,9 +108,9 @@ static const uint8_t A13 = NUM_DIGITAL_PINS+10;
|
|||||||
|
|
||||||
|
|
||||||
#define digitalPinToPCICR(p) (&PCIFR)
|
#define digitalPinToPCICR(p) (&PCIFR)
|
||||||
#define digitalPinToPCICRbit(p) (((p) >= 3 && (p) <= 10) ? 4 : 5)
|
#define digitalPinToPCICRbit(p) (((p) >= 6 && (p) <= 13) ? PCIE0 : PCIE1)
|
||||||
#define digitalPinToPCMSK(p) (((p) >= 3 && (p) <= 10) ? (&PCMSK0) : (((p) >= 0 && (p) <= 2) ? (&PCMSK1) : ((uint8_t *)NULL)))
|
#define digitalPinToPCMSK(p) (((p) >= 6 && (p) <= 13) ? (&PCMSK0) : (&PCMSK1))
|
||||||
#define digitalPinToPCMSKbit(p) (((p) >= 3 && (p) <= 10) ? (10 - (p)) : (p))
|
#define digitalPinToPCMSKbit(p) (((p) >= 6 && (p) <= 13) ? ((p) - 6) : (((p) >= 0 && (p) <= 3) ? (p) : ((p) + 2)))
|
||||||
|
|
||||||
#ifdef ARDUINO_MAIN
|
#ifdef ARDUINO_MAIN
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] =
|
|||||||
PA, /* 10 */
|
PA, /* 10 */
|
||||||
PA,
|
PA,
|
||||||
PA,
|
PA,
|
||||||
PB, /* 15 */
|
PB, /* RESET */
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
||||||
@@ -182,8 +182,8 @@ const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
|||||||
_BV(0), /* 0 */
|
_BV(0), /* 0 */
|
||||||
_BV(1),
|
_BV(1),
|
||||||
_BV(2), /* 2 */
|
_BV(2), /* 2 */
|
||||||
_BV(3), /* 3 */
|
_BV(6), /* 3 */
|
||||||
_BV(6), /* 4 */
|
_BV(3), /* 4 */
|
||||||
_BV(7),
|
_BV(7),
|
||||||
_BV(0),
|
_BV(0),
|
||||||
_BV(1),
|
_BV(1),
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#define NUM_DIGITAL_PINS 14
|
#define NUM_DIGITAL_PINS 14
|
||||||
#define NUM_ANALOG_INPUTS 10
|
#define NUM_ANALOG_INPUTS 10
|
||||||
#define analogInputToDigitalPin(p) ((p < 7) ? p+6 : (p ==7) ? 5 : (p==9) ? 4 : (p==10) ? 13 : -1)
|
#define analogInputToDigitalPin(p) ((p == 3) ? 23 : (p == 5) ? 21 : (p < 13 && p > 5) ? p+14 : (p ==13) ? 24 : -1)
|
||||||
|
|
||||||
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1)
|
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1)
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ static const uint8_t SDA = 0;
|
|||||||
static const uint8_t SCL = 2;
|
static const uint8_t SCL = 2;
|
||||||
|
|
||||||
//Ax constants cannot be used for digitalRead/digitalWrite/analogWrite functions, only analogRead().
|
//Ax constants cannot be used for digitalRead/digitalWrite/analogWrite functions, only analogRead().
|
||||||
static const uint8_t A4 = NUM_DIGITAL_PINS+9;
|
static const uint8_t A3 = NUM_DIGITAL_PINS+9;
|
||||||
static const uint8_t A5 = NUM_DIGITAL_PINS+7;
|
static const uint8_t A5 = NUM_DIGITAL_PINS+7;
|
||||||
static const uint8_t A6 = NUM_DIGITAL_PINS+0;
|
static const uint8_t A6 = NUM_DIGITAL_PINS+0;
|
||||||
static const uint8_t A7 = NUM_DIGITAL_PINS+1;
|
static const uint8_t A7 = NUM_DIGITAL_PINS+1;
|
||||||
@@ -108,9 +108,9 @@ static const uint8_t A13 = NUM_DIGITAL_PINS+10;
|
|||||||
|
|
||||||
|
|
||||||
#define digitalPinToPCICR(p) (&PCIFR)
|
#define digitalPinToPCICR(p) (&PCIFR)
|
||||||
#define digitalPinToPCICRbit(p) (((p) >= 3 && (p) <= 10) ? 4 : 5)
|
#define digitalPinToPCICRbit(p) (((p) >= 6 && (p) <= 13) ? PCIE0 : PCIE1)
|
||||||
#define digitalPinToPCMSK(p) (((p) >= 3 && (p) <= 10) ? (&PCMSK0) : (((p) >= 0 && (p) <= 2) ? (&PCMSK1) : ((uint8_t *)NULL)))
|
#define digitalPinToPCMSK(p) (((p) >= 6 && (p) <= 13) ? (&PCMSK0) : (&PCMSK1))
|
||||||
#define digitalPinToPCMSKbit(p) (((p) >= 3 && (p) <= 10) ? (10 - (p)) : (p))
|
#define digitalPinToPCMSKbit(p) (((p) >= 6 && (p) <= 13) ? ((p) - 6) : (((p) >= 0 && (p) <= 3) ? (p) : ((p) + 2)))
|
||||||
|
|
||||||
#ifdef ARDUINO_MAIN
|
#ifdef ARDUINO_MAIN
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] =
|
|||||||
PA, /* 10 */
|
PA, /* 10 */
|
||||||
PA,
|
PA,
|
||||||
PA,
|
PA,
|
||||||
PB, /* 15 */
|
PB, /* RESET */
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
||||||
@@ -182,8 +182,8 @@ const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
|||||||
_BV(0), /* 0 */
|
_BV(0), /* 0 */
|
||||||
_BV(1),
|
_BV(1),
|
||||||
_BV(2), /* 2 */
|
_BV(2), /* 2 */
|
||||||
_BV(3), /* 3 */
|
_BV(6), /* 3 */
|
||||||
_BV(6), /* 4 */
|
_BV(3), /* 4 */
|
||||||
_BV(7),
|
_BV(7),
|
||||||
_BV(0),
|
_BV(0),
|
||||||
_BV(1),
|
_BV(1),
|
||||||
|
Reference in New Issue
Block a user