Shop OBEX P1 Docs P2 Docs Learn Events
FLiP Holiday Kit Test/Demo Code — Parallax Forums

FLiP Holiday Kit Test/Demo Code

JonnyMacJonnyMac Posts: 9,159
edited 2024-12-23 21:15 in PASM/Spin (P1)

As creatives, we all have our own way, so this is my way about the Holiday Kit. The wiring is the same as with the Parallax demo.

Once I started my test code I found that the pixels don't need the Red/Green swap that is required by the WS2812b pixels, so I switched the driver to an updated WS2811 driver. All of the interface methods are the same, there's just a small difference in the PASM driver.

My tones and music generation doesn't use an external object; it's built into the main project (I call this an embedded object). I have programmed many laser tag and escape room props that needed simple beeps, boops, and monotonic music, so the code attached is based on what I've been doing for the last eight years. The up-shot is that being internal allows you to stop the music any time. The background cog that runs the music runs every millisecond which provides a convenient timing mechanism. And over the years I found that you can get a lot of work done in 1ms running Spin1 and 80MHz. That is to say that you can add features to the background if desired (e.g., button debouncing).

Even though I call this a tester, it has several lighting animations and some music, including "Oh, Christmas Tree" and "The Dreidel Song."

I wrote and tested this in Propeller Tool (because it's like an old, comfortable pair of jeans), and also tested in Spin Tools IDE. If using the latter, you can turn off the line input for the PST terminal emulation so that it behaves like PST. If you have line input enabled, you need to press Enter.

Have fun, and let me know if you run into any snags.

Comments

  • VonSzarvasVonSzarvas Posts: 3,486
    edited 2024-12-23 10:50

    Cool, thanks Jon.

    Anyone wanting to add this to the existing "Run" menu in the Holiday Kit WiFi module's built-in menu system (reset 3-press), just upload the attached binary file using the WiFi module web-gui "Files" tab.

    Tips:

    • Usually you'd get to the web-gui by typing the IP address of your WiFi module into a web browser on a computer connected to the same network as the WiFi module.
    • The WiFi IP address is shown on the OLED screen of the holiday kit, once the WiFi is connected to your network.

    Alternatively, if Jon's code is loaded direct to FLiP EEPROM (F11 from Propeller Tool or Spin Tools), then you can still get into the WiFi run menu by pressing the reset button 3 times.

    BTW @JonnyMac ... who's the Cafe Babe ? :)

  • iseriesiseries Posts: 1,496

    I think the kit should have included the 74HC165 to show how to interface the 5 position switch to it and be able to use SPI to read it.

    Mike

  • Neat idea.
    Do you have a wiring diagram and code to share? We could feature it somehow.

  • JonnyMacJonnyMac Posts: 9,159
    edited 2024-12-23 15:54

    BTW @JonnyMac ... who's the Cafe Babe ? :)

    $DEAD_BEEF is not in the holiday spirit! :D (unless it's roast, and served with mashed potatoes).

    Do you have a wiring diagram and code to share? We could feature it somehow.

    Here's a connection diagram for a '165 from a P1 product I designed sometime back.

    You don't need the 4.7K if powering the '165 with 3.3v.

    In your setup code, configure the IOs used by the '165

      io.high(LD_165)                                               ' setup x165 io pins
      io.low(SCK_165)
      io.input(SDI_165)
    

    You can read 8 bits from the device like this:

    pub read_165 : result
    
    '' Read 8 bits from 74x165
    
      outa[LD_165] := 0                                             ' load new inputs
      outa[LD_165] := 1
    
      repeat 8
        result := (result << 1) | ina[SDI_165]                      ' read bit (MSBFIRST) 
        outa[SCK_165] := 1                                          ' clock next bit
        outa[SCK_165] := 0
    

    In my particular case I have two 165s that are daisy-chained and the 9th bit from a DMX switch (17 bits total). The read code look this. It is unrolled for best speed because this runs in one of those 1ms background loops I mentioned in my first post.

    pri scan_ttl_ins : tempin
    
    '' Scan TTL and DMX address inputs
    
      outa[LD_165] := 0                                             ' blip Shift/Load line
      outa[LD_165] := 1
    
      ' unrolled for best speed
    
      tempin := ina[DMX_A8]                                         ' bit16
    
      tempin := (tempin << 1) | ina[SDI_165]                        ' bit15
      outa[SCK_165] := 1                                            ' blip clock
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
    
      tempin := (tempin << 1) | ina[SDI_165]                        ' bit7
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]
      outa[SCK_165] := 1
      outa[SCK_165] := 0
      tempin := (tempin << 1) | ina[SDI_165]                        ' bit0
    
      ttlpins := tempin.byte[0]                                     ' update global vars
      dmxaddr := tempin >> 8
    
Sign In or Register to comment.