Author Topic: Windows GUI for Arduino light show (eg pattern generator)  (Read 2514 times)

0 Members and 1 Guest are viewing this topic.

Offline deejay2k1Topic starter

  • Newbie
  • Posts: 7
  • Country: ro
Windows GUI for Arduino light show (eg pattern generator)
« on: November 30, 2016, 10:32:26 am »
Let me present to the community a small project of mine.

The main purpose was to simplify the array generation needed for the Christmas light show

But it somewhat evolved. So please review it, post tips for new features, use it or discard it  :popcorn:

Compiled and tested on Windows 7, 32bit

User manual: + and - sequence buttons adds or removes a sequence (last one). sequence is 8 bit, LSB first, hex notation (eg 0x01)

copy and paste buttons: copies into/from windows clipboard the array containing the patterns

.ino button: (beginner friendly)  copies into clipboard the entire Arduino sketch. Just paste it into Arduino IDE (please delete all from the sketch before paste). After that, you could paste only the array from the step above.

Please see attached image for the Knight Rider example
Link for the GUI: http://goo.gl/TA6MHC

Enjoy!
 
The following users thanked this post: ANTALIFE

Offline AlessandroAU

  • Regular Contributor
  • *
  • Posts: 168
  • Country: au
Re: Windows GUI for Arduino light show (eg pattern generator)
« Reply #1 on: December 01, 2016, 01:38:58 pm »
This is really cool thanks.
 
It will be very handy for creating custom fonts.
 

Offline deejay2k1Topic starter

  • Newbie
  • Posts: 7
  • Country: ro
Re: Windows GUI for Arduino light show (eg pattern generator)
« Reply #2 on: December 01, 2016, 02:11:37 pm »
Good idea. Bear in mind that it has (for the moment) a limit of 99 patterns. Shall be corrected in the next version.

I'm thinking to add Charlieplexing encoding also, if it gathers at least a couple votes.

Also I want to add a second matrix for built-in effects. As in specify the first pattern as single lit LED and tell it to shift or rotate, blink or whatever. The .ino code will be more compact then.

 

Offline deejay2k1Topic starter

  • Newbie
  • Posts: 7
  • Country: ro
Re: Windows GUI for Arduino light show (eg pattern generator)
« Reply #3 on: December 03, 2016, 12:10:34 am »
Update:
GUI version 1.1 with 512 sequences now available.

Finished working on Arduino side with the second array containing modifiers
It does shifting left and right, rotation left and right, blink and invert (in 8 steps).


Code: [Select]
//#define debug

#if defined(debug)
#define stepTime 250
#else
#define stepTime 50
#endif

int pinArray[] = {2, 3, 4, 5, 6, 7, 8, 9};

//copy or paste this into patOgen
//from here
const PROGMEM byte myArray[] =          {0xaa, 0x01, 0x80, 0x60, 0x06, 0x55, 0xff};

const PROGMEM byte myArrayModifiers[] = {0x05, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
//to here

#define noSteps sizeof(myArray)
int currentStep = 0;

void setup() {
  for (int i = 0; i < 8; i++) {
    pinMode(pinArray[i], OUTPUT);
#if defined(debug)
    Serial.begin(115200);
#endif
  }
}

void loop() {
  static long lightTime = millis();
  if (millis() - lightTime > stepTime) {
    static byte myLights = 0;
    static byte mode = 0;
    static byte subStep = 0;
    if (subStep == 0) {
      myLights =  pgm_read_byte_near(myArray + currentStep);
      mode = pgm_read_byte_near(myArrayModifiers + currentStep);
    }

    switch (mode) {
      case 1:
        //shl
        if (subStep > 0)
          myLights <<= 1;
        break;
      case 2:
        //shr
        if (subStep > 0)
          myLights >>= 1;
        break;
      case 3:
        //rol
        if (subStep > 0)
          myLights = ((myLights & 0x80) ? 0x01 : 0x00) | (myLights << 1);
        break;
      case 4:
        //ror
        if (subStep > 0)
          myLights = ((myLights & 0x01) ? 0x80 : 0x00) | (myLights >> 1);
        break;
      case 5:
        //invert
        if (subStep > 0)
          myLights = ~myLights;
        break;
      case 6:
        //blink
        if (subStep % 2 == 0)
          myLights =  pgm_read_byte_near(myArray + currentStep);
        else
          myLights = 0x00;
        break;
      default:
        subStep = 7;
        break;
    }

    subStep++;
    subStep %= 8;
#if defined(debug)
    Serial.println(subStep);
    Serial.println(myLights, BIN);
    Serial.println();
#endif
    for (int i = 0; i < 8; i++) {
      digitalWrite(pinArray[i], (bool)(0x01 & (myLights >> i)));
    }
    if (subStep == 0) currentStep++;
    currentStep %= noSteps;
    lightTime = millis();
  }
}
 

Offline deejay2k1Topic starter

  • Newbie
  • Posts: 7
  • Country: ro
Re: Windows GUI for Arduino light show (eg pattern generator)
« Reply #4 on: December 04, 2016, 11:25:26 am »
GUI version 1.2 released

Update ver 1.2: Added 8 modifiers for every sequence.
                    no modifier (----) just displays the sequence one (step) time
                    <---    move sequence to left in 8 steps
                    --->    move sequence to right in 8 steps
                    <--<    rotates sequence to left in 8 steps
                    >-->    rotates sequence to right in 8 steps
                    invert  inverts sequence in 8 steps
                    blink   blink/strobe sequence in 8 steps (4 on, 4 off)
                    <-fill  fills sequnce to the left with whatever value in bit b0 in 8 steps
                    fill->  fills sequnce to the right with whatever value in bit b7 in 8 steps
 

Offline deejay2k1Topic starter

  • Newbie
  • Posts: 7
  • Country: ro
Re: Windows GUI for Arduino light show (eg pattern generator)
« Reply #5 on: December 04, 2016, 05:33:03 pm »
Update ver 1.3: Added multiplier for every sequence (how many times it should repeat itself)

Update ver 1.4: Added new modifiers.
                    fill from middle (b4 and b3) outwards
                    fill from edges (b7 and b0) inwards
                    explode (shift from middle outwards)
                    implode (shift from edges inwards)
                    stack (sequence bits are not used, only the modifiers matters)
                    drip (same conditions as stack)

That's all folks!

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf