Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1078 Posts in 245 Topics- by 866 Members - Latest Member: Wjamnunsub

May 20, 2013, 12:58:27 PM
The Stribe Project - ForumGeneral CategoryinfofirmwareTopic: new firmware 0.4v implements fader handle instead of cursor mode
Pages: [1] |   Go Down
Print
Author Topic: new firmware 0.4v implements fader handle instead of cursor mode  (Read 2786 times)
0 Members and 1 Guest are viewing this topic.
ultrajosh
Administrator
Master Striber
*****
Posts: 396



View Profile WWW
« on: April 07, 2008, 11:08:19 AM »

You might be looking for this: http://soundwidgets.com/smf/index.php?topic=167.msg624#msg624

older:


I implemented a minor change to the firmware to provide similar functionality to that of _stribe_faders.mxb, but it works a bit better.  Now, in cursor mode, you still get a cursor with trails but now it leaves an indicator at the last place touched when you let go.  It works great with _stribe_cc.mxb.  I replaced default cursor mode with this since it is much more useful.  The mode is ON by default but can be toggled off in _stribe_io.mxb by turning off "firmware cursor".

http://www.soundwidgets.com/stribe/code/stribe_04v.pde

Note that adjacent LEDs on the same grid will flicker when on.  There is still no smart-updating of the display going on.

Logged

"Well you touch it and it makes sounds."
bantri
Intrigued
*
Posts: 39


View Profile
« Reply #1 on: April 08, 2008, 07:42:13 AM »

Sorry for my ignorance but...

In this scheme... using usbmod and an arduino stamp...

Can you send firmware directly over USB in your circuit? (without any programming knowledge or extra equipment, just by using some program specialized to do that)
Logged
ultrajosh
Administrator
Master Striber
*****
Posts: 396



View Profile WWW
« Reply #2 on: April 08, 2008, 07:58:00 AM »

Yes!

How to Work on the firmware

Read the above for details, but the short version is you install the Arduino IDE onto your machine, download SimpleMessageSystem library and compile it, then you can load up the latest "sketch" (firmware code) from /stribe/code/*.pde, compile it, and upload it to the Arduino stamp via the USB.  The MINI and the USB stamps are wired together with a reset switch on the stribe, so you just hit the reset switch and then click the "upload" button in the IDE and watch the status leds flash and voila, new firmware.

Logged

"Well you touch it and it makes sounds."
bantri
Intrigued
*
Posts: 39


View Profile
« Reply #3 on: April 08, 2008, 12:26:36 PM »

ok, thanks a lot
Logged
ultrajosh
Administrator
Master Striber
*****
Posts: 396



View Profile WWW
« Reply #4 on: April 09, 2008, 08:25:29 AM »

The new fader mode was really a hack that sort of started working before I expected it to.  So one thing I'm noticing is after awhile it stops clearing the display, esp if you let it sit with no activity for awhile.  Then sometimes it spontaneously clears when you touch it and it goes back to it's old behavior.  Just curious if anyone else is seeing this.
Logged

"Well you touch it and it makes sounds."
tk
Intrigued
*
Posts: 8


View Profile
« Reply #5 on: April 09, 2008, 02:44:55 PM »

I'm not able to test your firmware, but I've some debugging skills Wink
Assumed, that loop() is called each mS, and assumed that the signed integer range of your C compiler is -32768 to +32767, the clearAll counter will get negative after ca. 33 seconds so long at least one sensor is touched. Once the overrun took place, there will be a timeframe of ca. 33 seconds where touch states will be ignored (because clearAll <= trails) and the LEDs won't be cleared, followed by a 33 second timeframe where it will work again.

It makes sense to saturate the counter at 32767 (for ca. 33 seconds) - and maybe also to use unsigned instead of signed variables to double the max delay to ca. 66 seconds

In general, I see a lot of signed variables in your firmware at many places where the negative values are not really required. Signed operations can seriously slow down the code execution, and therefore should be ommited

Best Regards, Thorsten.

P.S.: I'm confused about the comment "only clear if touch[]=0", because the LEDs will only be cleared if at least one member of touch[] is != 0"... so parts of my assumptions above could be wrong. But I think that you got the point...
Logged
ultrajosh
Administrator
Master Striber
*****
Posts: 396



View Profile WWW
« Reply #6 on: April 09, 2008, 05:12:33 PM »

I just been reading-up on signed vs unsigned ints; and you're right there's also a logic error I need to correct.

Thanks! 
Logged

"Well you touch it and it makes sounds."
tk
Intrigued
*
Posts: 8


View Profile
« Reply #7 on: April 09, 2008, 05:54:04 PM »

I would propose to store the touch state of the 8 sensors into a single byte (-> "unsigned char"). This saves some RAM (int touch[8] consumes 16 bytes), and improves the performance on logical checks.

To set a flag, use:
   touched |= (1 << stribe);
To clear a flag, use:
   touched &= ~(1 << stribe);

Check if any sensor is touched:
   if( touched ) { ...

Check if no sensor is touched:
  if( !touched ) { ...

Check if an individual sensor is touched:
  if( touched & (1 << stribe) ) { ...
or
  if( touched & and_mask[stribe] ) { ...

where and_mask is globally defined as: "const unsigned char and_mask[8] = { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f };"


touched could also be declared as an aggregate (union):
Code:
typedef union {
  struct {
    unsigned ALL:8;
  };
  struct {
    unsigned SENSOR1:1;
    unsigned SENSOR2:1;
    unsigned SENSOR3:1;
    unsigned SENSOR4:1;
    unsigned SENSOR5:1;
    unsigned SENSOR6:1;
    unsigned SENSOR7:1;
    unsigned SENSOR8:1;
  };
} touched_t;

touched_t touched;

...which not only improves the readability:
  if( touched.ALL ) { ...
  if( !touched.ALL ) { ...
  if( touched.SENSOR1 ) { ...
  if( !touched.SENSOR2 ) { ...

but also the performance (again... single flag checks result into a single assembler instruction)

Best Regards, Thorsten.

Logged
ultrajosh
Administrator
Master Striber
*****
Posts: 396



View Profile WWW
« Reply #8 on: April 09, 2008, 06:52:44 PM »

Wow, that is some good stuff!   Grin   Much food for thought.

BTW: here is a slightly updated firmware with the climbing value fixed and most ints converted to unsigned:

http://soundwidgets.com/stribe/code/stribe_04w.pde
Logged

"Well you touch it and it makes sounds."
ultrajosh
Administrator
Master Striber
*****
Posts: 396



View Profile WWW
« Reply #9 on: April 09, 2008, 07:16:31 PM »

I rolled-in kid sputnik's changes (marked 'DB')

http://soundwidgets.com/stribe/code/stribe_04x.pde

There is also an .exe for watching the messages go by but i couldn't get it to run on my XP box.  Maybe someone else can: http://soundwidgets.com/stribe/code/kidsputnik/

Logged

"Well you touch it and it makes sounds."
Pages: [1] |   Go Up
Print
The Stribe Project - ForumGeneral CategoryinfofirmwareTopic: new firmware 0.4v implements fader handle instead of cursor mode
Jump to:  

Theme orange-lt created by panic