Postby vputz » February 01 2009, 14:49 PM
Okay, busyish weekend in OrbDuino-land! (heh).
1) Okay, I think bindings are basically done; maybe some tweakings. I have tweaked things so that bindings take place in PROGMEM (flash memory) so we've got plenty of SRAM, or so it seems. To do bindings, you just create some structures, and set them. Here's a basic Orbduino sketch:
[code]
#include "orb_device.h"
#include "orb_translator.h"
#include "hid_keys.h"
Logical_orb orb_buffer( SpaceBall4000 );
Orb_translator translator;
byte b;
boolean has_initialized_orb=false;
PROGMEM Axis_key_binding axis_key_bindings[] =
{
{ 0, 0, 255, 0, KEY_O },
{ 0, 768, 1023, 0, KEY_U},
{ 1, 0, 255, 0, KEY_PERIOD},
{ 1, 768, 1023, 0, KEY_E},
{ 5, 0, 255, 0, KEY_COMMA },
{ 5, 768, 1023, 0, KEY_P }
};
PROGMEM Button_key_binding button_key_bindings[] =
{
{ 0x01 << 1, MOD_SHIFT_LEFT, 0 },
{ 0x01 << 2, 0, KEY_H },
{ 0x01 << 3, 0, KEY_E },
{ 0x01 << 4, 0, KEY_L },
{ 0x01 << 5, 0, KEY_O }
};
PROGMEM Axis_mouse_binding axis_mouse_bindings[] =
{
{ 0, MOUSE_AXIS_X, 3 },
{ 1, MOUSE_AXIS_Y, 3 }
};
PROGMEM Button_mouse_binding button_mouse_bindings[] =
{
{ 0x01, 0x01 },
{ 0x01 << 1, 0x01 << 1 },
{ 0x01 << 2, 0x01 << 2 }
};
void setup()
{
Serial.begin( 9600 );
translator.set_chording( false );
translator.set_axis_map( Axis_map_spaceball_4k );
translator.set_polarity( Polarity_spaceball_4k );
//translator.set_axis_key_bindings( axis_key_bindings, 6 );
//translator.set_button_key_bindings( button_key_bindings, 5 );
translator.set_axis_mouse_bindings( axis_mouse_bindings, 2 );
translator.set_button_mouse_bindings( button_mouse_bindings, 3 );
}
void loop()
{
orb_device.refresh();
if ( Serial.available() )
{
b = Serial.read();
orb_buffer.add_byte( b );
if ( orb_buffer.has_changed() )
{
if ( (!has_initialized_orb) && (orb_buffer.physical_buttons & 1) )
{
orb_device.safe_send_serial_P(spaceball_setup_string);
has_initialized_orb = true;
}
else if ( has_initialized_orb )
{
}
//orb_device.refresh();
//translator.translate_orb( orb_buffer, orb_device );
//orb_buffer.log_change();
translator.update(orb_buffer, orb_device);
}
}
}
[/code]
(some of that will make better sense with a bit of documentation).
At any rate, the orb can now produce joystick, keyboard, and mouse events, which is well exciting (what with typing using the orb buttons, or dragging windows around and such). Good stuff! I think I may need to change the Vendor ID and Product ID to match the one provided in the library (for the original project, we sorta just got away with IDs we had no right to, but I'd like to be a bit more legal this time).
2) Latest beta files are available on the Orbduino website ([url]http://orbduino.sourceforge.net[/url]), although the website looks absolutely terrible. I'll update that later.
3) Well, I tried... there's a great little device called the "Teensy" which claims to work with the Arduino environment but has a tiny little bit of closed-source proprietary code. It would have been a great thing for us, because it uses that AT90USB chip, and would have GREATLY simplified things (we could just have the Teensy, a Max233, and a DB9 serial plug, and that's it, no Arduino board at all). Unfortunately the fellow who designed it doesn't seem to "get" the idea of open-source, and when I tried to persuade him to open the bootloader (even offering to buy one on the spot if he did) things escalated rather nastily (see page two of [url=http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1228496328]this thread[/url]). A real pity; it's a great board. I still may play with the AVROpendous to see if there's progress to be made there, but it's not nearly as tidy a solution, and as mentioned the Arduino+shield seems to be doing just fine. Of course, if someone wants to try and run it on a teensy and accept the proprietary bootloader, that's OK, but I shall be snooty about it (heh).
Tired, but progress still going. With luck the boards will be here in a week or so and we can see if they work.