Browse Source

We don't have led, change pins for teensy 2.0

mouse-trak
squeaky otter 2 years ago
parent
commit
77d25aebdc
Signed by: dashie GPG Key ID: C2D57B325840B755
  1. 42
      Firmware/Firmware.ino
  2. 48
      Firmware/globals.h
  3. 20
      README.md

42
Firmware/Firmware.ino

@ -15,11 +15,6 @@ void do_click(byte i){
reset_event();
click_states[i] = 0;
}
// do outside so it's not reliant on state change
if(!in_pattern){
set_led(i, btns[i].isPressed());
}
}
bool scroll_mode = false;
@ -27,13 +22,9 @@ void do_scroll(){
static byte i = _SCROLL;
if(btns[i].isPressed()){
reset_event();
if(in_pattern) return;
set_led(i, true);
scroll_mode = true;
}
else if(btns[i].isReleased()){
if(in_pattern) return;
set_led(i, false);
scroll_mode = false;
}
}
@ -43,34 +34,8 @@ void do_dpi(){
static byte i = _DPI;
if(btns[i].wasPressed()){
reset_event();
if(in_pattern) return;
dpi_state = !dpi_state;
}
if(in_pattern) return;
set_led(i, dpi_state);
}
int8_t pattern_step = -1;
unsigned long last_pattern = 0;
void do_pattern() {
if(TimeElapsed(last_pattern, 1000)){
Serial.println(pattern_step);
last_pattern = millis();
for(byte i=0; i<BTNS; i++){
set_led(pattern_order[i], pattern_step == i);
}
pattern_step += pattern_dir;
if(pattern_step >= BTNS){
pattern_step = BTNS-2;
pattern_dir = -1;
}
else if(pattern_step < 0){
pattern_step = 1;
pattern_dir = 1;
}
}
}
void setup()
@ -79,7 +44,6 @@ void setup()
Mouse.begin();
setup_btns();
setup_leds();
}
void loop()
@ -87,12 +51,6 @@ void loop()
static long h, v;
static byte mult = MOUSE_MULT_HIGH;
if(TimeElapsed(last_event, LAST_EVENT_TIMEOUT)){
in_pattern = true;
do_pattern();
}
else { in_pattern = false; }
read_btns();
do_dpi();

48
Firmware/globals.h

@ -3,10 +3,13 @@
#define MOUSE_MULT_HIGH 4
#define MOUSE_MULT_LOW 2
#define V_A 2 // Yellow
#define V_B 3 // Green
#define H_A 4 // Blue
#define H_B 5 // Purple
// Only four pins with interrupts available on the 2.0
// https://www.pjrc.com/teensy/td_libs_Encoder.html
// AVOID PIN 11
#define V_A 5 // OC2 pin 6
#define V_B 6 // OC2 pin 8
#define H_A 7 // OC1 pin 6
#define H_B 8 // OC1 pin 8
#define BTNS 5 // Button Count
@ -19,20 +22,13 @@
byte pattern_order[] = {_SCROLL, _DPI, _LEFT, _MID, _RIGHT};
// Avoid PIN 11 on 2.0
byte btn_pins[] = {
6, // L
7, // R
8, // M
10, // Scroll
9 // DPI
};
byte led_pins[] = {
14, // L
15, // R
16, // M
18, // Scroll
17 // DPI
21, // L
20, // R
19, // M
NULL, // Scroll (unused)
18 // DPI (or unuse this one and swap NULL/17)
};
volatile unsigned long last_int[] = {
@ -69,24 +65,6 @@ void read_btns(){
}
}
void setup_leds(){
pinMode(led_pins[_LEFT], OUTPUT);
pinMode(led_pins[_MID], OUTPUT);
pinMode(led_pins[_RIGHT], OUTPUT);
pinMode(led_pins[_DPI], OUTPUT);
pinMode(led_pins[_SCROLL], OUTPUT);
digitalWrite(led_pins[_LEFT], LOW);
digitalWrite(led_pins[_MID], LOW);
digitalWrite(led_pins[_RIGHT], LOW);
digitalWrite(led_pins[_DPI], LOW);
digitalWrite(led_pins[_SCROLL], LOW);
}
void set_led(byte i, bool state){
digitalWrite(led_pins[i], state);
}
#define LAST_EVENT_TIMEOUT 60000
unsigned long last_event = 0;
bool in_pattern = false;

20
README.md

@ -1,18 +1,14 @@
# Arcade Trackball Mouse
# Mouse-Trak Teensy conversion
A completely unnecessary, but fun computer mouse using arcade components and a billiard ball.
Got an old 1998 MOUSE-TRAK but the Z86 MCU seems fried.
# Design Files
I decided to just replace it with a teensy.
All printed parts were designed in Fusion 360 and can be viewed and downloaded here: https://a360.co/2Rxvm0l
Or find the STL files in the `Fab` folder.
# How
Later.
# Bill of Materials
- [Happ/Atari Trackball](http://www.arcadeshop.com/i/19/2-trackball-unit-white-ball-atari-happ.htm)
- [24mm Buttons](https://www.adafruit.com/product/3432)
- [Quick Connect Button Wires](https://www.adafruit.com/product/1152)
- [#10-24 2-1/4" bolt](https://www.amazon.com/gp/product/B07B7JNY5K/)
- [#10-24 Nut](https://www.amazon.com/gp/product/B078SM2C7N/)
- [Teensy 3.2](https://www.pjrc.com/store/teensy32.html)
- [PCB @ OSHPark](https://oshpark.com/shared_projects/eHG1B3Ws) (Or see PCB folder and KiCAD files)
- [Vintage Mouse Track](http://www.itacsystems.com/industrial-desktops.html)
- [Teensy 2.0](https://www.pjrc.com/store/teensy.html)
Loading…
Cancel
Save