7 Commits

Author SHA1 Message Date
Erik Tylek Kettenburg
158d655dfa fix digimouse 2014-12-20 13:07:59 -08:00
Erik Tylek Kettenburg
de2937f691 fix path to avrdude 2014-12-20 12:34:24 -08:00
Erik Tylek Kettenburg
2f74dc9204 Update pins_arduino.h 2014-12-20 12:31:22 -08:00
Erik Tylek Kettenburg
4dd9d246e8 Update pins_arduino.h 2014-12-20 12:31:06 -08:00
Erik Tylek Kettenburg
260c1e1da0 Update pins_arduino.h 2014-12-20 12:30:44 -08:00
Erik Tylek Kettenburg
556095de2d Fix pin 3 and 6 being flipped 2014-12-19 16:32:39 -08:00
Erik Tylek Kettenburg
f1f8616ba4 Update README.md 2014-12-19 12:12:21 -08:00
6 changed files with 80 additions and 40 deletions

View File

@@ -4,7 +4,7 @@ DigistumpArduino
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:

View File

@@ -31,6 +31,10 @@ static uchar rt_usbHidReportDescriptorSize = 0;
static const uchar *rt_usbDeviceDescriptor = NULL;
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.
//#include <WConstants.h>
//#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;
char usb_hasCommed = 0;
const PROGMEM unsigned char mouse_usbHidReportDescriptor[] = { /* USB report descriptor */
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
@@ -89,7 +94,7 @@ const PROGMEM unsigned char mouse_usbHidReportDescriptor[] = { /* USB report des
#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 */
USBDESCR_DEVICE, /* descriptor type */
0x01, 0x01, /* USB version supported */
@@ -145,16 +150,18 @@ void clearMove() {
class DigiMouseDevice {
public:
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 */
//TIMSK &= !(1<TOIE0);//interrupt off
}
char isConnected()
{
return usb_hasCommed;
}
void begin(){
cli();
PORTB &= ~(_BV(USB_CFG_DMINUS_BIT) | _BV(USB_CFG_DPLUS_BIT));
usbDeviceDisconnect();
_delay_ms(250);
usbDeviceConnect();
@@ -170,6 +177,16 @@ class DigiMouseDevice {
sei();
last_report_time = millis();
}
void refresh() {
update();
}
void poll() {
update();
}
void update() {
usbPoll();
@@ -231,6 +248,28 @@ class DigiMouseDevice {
last_built_report[2] = *(reinterpret_cast<unsigned char *>(&deltaY));
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) {
last_built_report[0] = buttons;
@@ -254,6 +293,7 @@ extern "C"{
// USB_PUBLIC uchar usbFunctionSetup
uchar usbFunctionSetup(uchar data[8]) {
usb_hasCommed = 1;
usbRequest_t *rq = (usbRequest_t *)data;
usbMsgPtr = reportBuffer;

View File

@@ -65,8 +65,8 @@ recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
# AVR Uploader/Programmers tools
# ------------------------------
tools.micronucleus.cmd.path={sketchbook.path}/hardware/digistump/avr/tools/avrdude
tools.micronucleus.cmd.path.linux={sketchbook.path}/hardware/digistump/avr/tools/avrdude
tools.micronucleus.cmd.path={runtime.ide.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.quiet=-q
@@ -77,4 +77,4 @@ tools.micronucleus.upload.pattern="{cmd.path}" -cdigispark --timeout 60 -Uflash:
# Default blank usb manufacturer will be filled it at compile time
# - from numeric vendor ID, set to Unknown otherwise
build.usb_manufacturer=
build.usb_flags=
build.usb_flags=

View File

@@ -33,7 +33,7 @@
#define NUM_DIGITAL_PINS 14
#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)
@@ -46,7 +46,7 @@ static const uint8_t SDA = 0;
static const uint8_t SCL = 2;
//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 A6 = NUM_DIGITAL_PINS+0;
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 digitalPinToPCICRbit(p) (((p) >= 3 && (p) <= 10) ? 4 : 5)
#define digitalPinToPCMSK(p) (((p) >= 3 && (p) <= 10) ? (&PCMSK0) : (((p) >= 0 && (p) <= 2) ? (&PCMSK1) : ((uint8_t *)NULL)))
#define digitalPinToPCMSKbit(p) (((p) >= 3 && (p) <= 10) ? (10 - (p)) : (p))
#define digitalPinToPCICRbit(p) (((p) >= 6 && (p) <= 13) ? PCIE0 : PCIE1)
#define digitalPinToPCMSK(p) (((p) >= 6 && (p) <= 13) ? (&PCMSK0) : (&PCMSK1))
#define digitalPinToPCMSKbit(p) (((p) >= 6 && (p) <= 13) ? ((p) - 6) : (((p) >= 0 && (p) <= 3) ? (p) : ((p) + 2)))
#ifdef ARDUINO_MAIN
@@ -174,7 +174,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] =
PA, /* 10 */
PA,
PA,
PB, /* 15 */
PB, /* RESET */
};
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(1),
_BV(2), /* 2 */
_BV(3), /* 3 */
_BV(6), /* 4 */
_BV(6), /* 3 */
_BV(3), /* 4 */
_BV(7),
_BV(0),
_BV(1),
@@ -230,4 +230,4 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
#define SOFTWARE_SERIAL_PORT PORTB
#define SOFTWARE_SERIAL_TX 0
#define SOFTWARE_SERIAL_PIN PINB
#define SOFTWARE_SERIAL_RX 1*/
#define SOFTWARE_SERIAL_RX 1*/

View File

@@ -33,7 +33,7 @@
#define NUM_DIGITAL_PINS 14
#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)
@@ -46,7 +46,7 @@ static const uint8_t SDA = 0;
static const uint8_t SCL = 2;
//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 A6 = NUM_DIGITAL_PINS+0;
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 digitalPinToPCICRbit(p) (((p) >= 3 && (p) <= 10) ? 4 : 5)
#define digitalPinToPCMSK(p) (((p) >= 3 && (p) <= 10) ? (&PCMSK0) : (((p) >= 0 && (p) <= 2) ? (&PCMSK1) : ((uint8_t *)NULL)))
#define digitalPinToPCMSKbit(p) (((p) >= 3 && (p) <= 10) ? (10 - (p)) : (p))
#define digitalPinToPCICRbit(p) (((p) >= 6 && (p) <= 13) ? PCIE0 : PCIE1)
#define digitalPinToPCMSK(p) (((p) >= 6 && (p) <= 13) ? (&PCMSK0) : (&PCMSK1))
#define digitalPinToPCMSKbit(p) (((p) >= 6 && (p) <= 13) ? ((p) - 6) : (((p) >= 0 && (p) <= 3) ? (p) : ((p) + 2)))
#ifdef ARDUINO_MAIN
@@ -174,7 +174,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] =
PA, /* 10 */
PA,
PA,
PB, /* 15 */
PB, /* RESET */
};
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(1),
_BV(2), /* 2 */
_BV(3), /* 3 */
_BV(6), /* 4 */
_BV(6), /* 3 */
_BV(3), /* 4 */
_BV(7),
_BV(0),
_BV(1),
@@ -230,4 +230,4 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
#define SOFTWARE_SERIAL_PORT PORTB
#define SOFTWARE_SERIAL_TX 0
#define SOFTWARE_SERIAL_PIN PINB
#define SOFTWARE_SERIAL_RX 1*/
#define SOFTWARE_SERIAL_RX 1*/

View File

@@ -33,7 +33,7 @@
#define NUM_DIGITAL_PINS 14
#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)
@@ -46,7 +46,7 @@ static const uint8_t SDA = 0;
static const uint8_t SCL = 2;
//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 A6 = NUM_DIGITAL_PINS+0;
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 digitalPinToPCICRbit(p) (((p) >= 3 && (p) <= 10) ? 4 : 5)
#define digitalPinToPCMSK(p) (((p) >= 3 && (p) <= 10) ? (&PCMSK0) : (((p) >= 0 && (p) <= 2) ? (&PCMSK1) : ((uint8_t *)NULL)))
#define digitalPinToPCMSKbit(p) (((p) >= 3 && (p) <= 10) ? (10 - (p)) : (p))
#define digitalPinToPCICRbit(p) (((p) >= 6 && (p) <= 13) ? PCIE0 : PCIE1)
#define digitalPinToPCMSK(p) (((p) >= 6 && (p) <= 13) ? (&PCMSK0) : (&PCMSK1))
#define digitalPinToPCMSKbit(p) (((p) >= 6 && (p) <= 13) ? ((p) - 6) : (((p) >= 0 && (p) <= 3) ? (p) : ((p) + 2)))
#ifdef ARDUINO_MAIN
@@ -174,7 +174,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] =
PA, /* 10 */
PA,
PA,
PB, /* 15 */
PB, /* RESET */
};
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(1),
_BV(2), /* 2 */
_BV(3), /* 3 */
_BV(6), /* 4 */
_BV(6), /* 3 */
_BV(3), /* 4 */
_BV(7),
_BV(0),
_BV(1),
@@ -230,4 +230,4 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
#define SOFTWARE_SERIAL_PORT PORTB
#define SOFTWARE_SERIAL_TX 0
#define SOFTWARE_SERIAL_PIN PINB
#define SOFTWARE_SERIAL_RX 1*/
#define SOFTWARE_SERIAL_RX 1*/