XIM Community

N52te and Orbweaver internals replaced by Teensy  (Read 17123 times)

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
N52te and Orbweaver internals replaced by Teensy
« on: 09:55 AM - 06/29/14 »
Pitfalls:
- D+ D- is very fragile on the Teensy if you connect the USB cable. If the USB cable is not high quality like it inst in the orbweaver solder 4 nice wires in-between.
- Orbweaver pcb is grounded row-wise
- analogue read 0 is not read on Teensy pin 0 but on analogue 0 which is pin 14
- If you glue the analogue stick there is a metal pin at the side, do not cover it with epoxy or you will not be able to move the stick and drilling the pin free can be ugly
- trace needs to be cut on thumb piece that would otherwise short. 
- ALWAYS after upload press reset button so upload is sure. Auto-update does not work 100% and always.
- if you connect the Teensy internal Orbweaver or N52 to the Xim and a single button is shown as pressed then you messed up the pins and stick buttons and foil assignments.
- check the pin where a foils is connected is really a touch capable pin. See Teensy pin-out.


This is just simple stuff put together from the past ideas, mostly W11cemeisters. Thanks for a "!" that made the code work. I was forced to do this as my USB hub made problems on the XIM4E.
The teensy handles a joystick, the keys and two touch buttons for the mouse. I did not wire the N52te scroll wheel as I don't use it.
Its time the Teensy leaves the gaming keypads from the shelf and gets his own.

get Teensyduino here
https://www.pjrc.com/teensy/td_download.html

W11ce pack to copy to arduino folders, flash code below with V2: (3/2015)
https://drive.google.com/file/d/0B_0MQrj9_eGteGlfLUhvQ1N1ZVE/view?usp=sharing

Code: [Select]
int axelX;
int axelY;

int overVal = 128;

void setup()
{
  Joystick.useManualSend(true);
  //pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);
  pinMode(9, INPUT_PULLUP);
  pinMode(10, INPUT_PULLUP);
  pinMode(11, INPUT_PULLUP);
  pinMode(12, INPUT_PULLUP);
  pinMode(13, INPUT_PULLUP);
  pinMode(16, INPUT_PULLUP);
  pinMode(17, INPUT_PULLUP);
  pinMode(18, INPUT_PULLUP);
  pinMode(19, INPUT_PULLUP);
  pinMode(20, INPUT_PULLUP);
  pinMode(21, INPUT_PULLUP);
  pinMode(22, INPUT_PULLUP);
  pinMode(23, INPUT_PULLUP);
  pinMode(24, INPUT_PULLUP);
  pinMode(25, INPUT_PULLUP);
  pinMode(26, INPUT_PULLUP);
  pinMode(27, INPUT_PULLUP);
  pinMode(28, INPUT_PULLUP);
}
void loop() {
 //Orbweaver Thumb-piece
    //Joystick.button(21, !digitalRead(0));
    Joystick.button(22, !digitalRead(1));
    Joystick.button(23, !digitalRead(2));
    Joystick.button(24, !digitalRead(3));
    Joystick.button(25, !digitalRead(4));
    Joystick.button(26, !digitalRead(5));

 // Keyboard
    Joystick.button(1, !digitalRead(6));
    Joystick.button(2, !digitalRead(7));
    Joystick.button(3, !digitalRead(8));
    Joystick.button(4, !digitalRead(9));
    Joystick.button(5, !digitalRead(10));
    Joystick.button(6, !digitalRead(11));
    Joystick.button(7, !digitalRead(12));
    Joystick.button(8, !digitalRead(16));
    Joystick.button(9, !digitalRead(17));
    Joystick.button(10, !digitalRead(18));
    Joystick.button(11, !digitalRead(19));
    Joystick.button(12, !digitalRead(20));
    Joystick.button(13, !digitalRead(21));
    Joystick.button(14, !digitalRead(22));
    Joystick.button(15, !digitalRead(23));
    Joystick.button(16, !digitalRead(24));
    Joystick.button(17, !digitalRead(25));
    Joystick.button(18, !digitalRead(26));
    Joystick.button(19, !digitalRead(27));
    Joystick.button(20, !digitalRead(28));


    //Joystick (pins 14 and 15)
    axelX = map(analogRead(0), 0, 1023, 1023+overVal, 0-overVal);
    axelX = constrain(axelX, 0, 1023);
    axelY = map(analogRead(1), 0, 1023, 1023+overVal, 0-overVal);
    axelY = constrain(axelY, 0, 1023);

    Joystick.X(axelX);
    Joystick.Y(axelY);

    //Touch buttons mouse
    if(touchRead(32) > 3000) Joystick.button(27, 1);
    else Joystick.button(27, 0);
    if(touchRead(33) > 3000) Joystick.button(28, 1);
    else Joystick.button(28, 0);
    //touch button Orbweaver
    if(touchRead(0) > 3000) Joystick.button(21, 1);
    else Joystick.button(21, 0);
    Joystick.send_now();
  //  delay (50);
}











« Last Edit: 10:37 AM - 03/12/15 by roads »
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.

Offline W11cE

  • MVP
  • *
  • Posts: 1523
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #1 on: 03:53 PM - 06/29/14 »
Nice :)
Have you tested if it works on XIM4E?

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #2 on: 04:12 PM - 06/29/14 »
not yet will tomorrow.
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #3 on: 11:00 PM - 06/29/14 »
What I am not sure about is, if its NKRO6 the way the code is? I did not get that in the Teensy manual. I know it can do it, but there are several ways to use the Teensy as a keyboard and I am not sure this one can type several characters at once. W11ce?
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #4 on: 05:04 AM - 06/30/14 »
Keys work fine, touch works fine, joystick does not. Rechecked soldering, must be code?
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.

Offline mist4fun

  • Global Moderator
  • MVP
  • *
  • Posts: 51815
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #5 on: 10:36 AM - 06/30/14 »
I like this. What is the primary reason for this though? Mouse touchpad/hub? Added benefit or macros? . Nice job.
Have a problem with your XIM APEX? Find a solution in the XIM APEX Support FAQ
XIM APEX Quick Start Guide   |   XIM Instructional Videos

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #6 on: 10:47 AM - 06/30/14 »
Macros are secondary but yeah you can program whatever you want later if there is a mouse sensor on the Teensy even that to any extent you want. Main reason is, we did not get another USB port. With this and mouse I don't need to connect a hub. Also any housing is possible so the teensy can leave the N52te or whatever device.
Strangely the Joystick is not working yet, need help from W11ce.
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.

Offline W11cE

  • MVP
  • *
  • Posts: 1523
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #7 on: 05:43 PM - 06/30/14 »
Here is for joystick buttons:
Code: [Select]
void setup()
{
Joystick.useManualSend(true);

pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(24, INPUT_PULLUP);
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
pinMode(27, INPUT_PULLUP);
pinMode(28, INPUT_PULLUP);
}
void loop() {

Joystick.button(1, !digitalRead(2));
Joystick.button(2, !digitalRead(3));
Joystick.button(3, !digitalRead(4));
Joystick.button(4, !digitalRead(5));
Joystick.button(5, !digitalRead(6));
Joystick.button(6, !digitalRead(7));
Joystick.button(7, !digitalRead(8));
Joystick.button(8, !digitalRead(9));
Joystick.button(9, !digitalRead(10));
Joystick.button(10, !digitalRead(11));
Joystick.button(11, !digitalRead(12));
Joystick.button(12, !digitalRead(24));
Joystick.button(13, !digitalRead(25));
Joystick.button(14, !digitalRead(26));
Joystick.button(15, !digitalRead(27));
Joystick.button(16, !digitalRead(28));

Joystick.X(analogRead(0));
Joystick.Y(analogRead(1));

if(touchRead(18) > 3000) Joystick.button(17, 1);
else Joystick.button(17, 0);
if(touchRead(19) > 3000) Joystick.button(18, 1);
else Joystick.button(18, 0);

Joystick.send_now();
}
Use with VER2 (G13) code.

I will need to check later if joystick, mouse and kb are possible at the same time with xim4e now that it supports composite devices.

About the NKRO6: Kb buttons have it, but joystick buttons does not have that limit.

btw: Knew it was the code, but was just hoping it still would work. Would have saved me from some coding and testing...

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #8 on: 11:12 PM - 06/30/14 »
OK so we go full joystick, will try later.
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #9 on: 03:23 AM - 07/01/14 »
replaced code in first post, still untested on XIM, Joy.cpl works fine.
*fingers crossed*
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.

Offline W11cE

  • MVP
  • *
  • Posts: 1523
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #10 on: 10:55 AM - 07/01/14 »
OK, looks like i never released VER2. I will need to do a new pack and some cleaning too. Any requests?

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #11 on: 11:01 AM - 07/01/14 »
LOL and I searched like crazy. Yes please add mouse support library and call it G13_M.
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #12 on: 01:39 PM - 07/01/14 »
1. post updated
VER2 is now in first post thanks W11ce. Teensyduino 1.19 needed.
Testing...
« Last Edit: 01:58 PM - 07/01/14 by roads »
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #13 on: 01:49 AM - 07/02/14 »
IT IS.....
WORKING!!!!!!!!!!!!!

thank you sir W11cemeister!
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.

Offline roads

  • MVP
  • *
  • Posts: 19700
    • View Profile
Re: N52te internals replaced by Teensy
« Reply #14 on: 01:58 AM - 07/02/14 »
So Joystick, touch and the keyboard work fine, no restrictions of buttons pressed simultanueously. Code is very simple, no calibration needed. Easy to tweak even for the XIM noob. This is a great success.

It is time the Teensy leaves the N52te and we get some cool housing.
Crusade atm: XIM Mouse that is stable 1000hz at 12000 or higher no delays by smoothing. XIM APEX is ridiculous without a XIM Mouse.