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,202
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,513
    edited 2024-12-27 22:45

    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 ? :)

    Edit 2024.12.27.: Binary file removed as not sanctioned by the author. Please compile from the source code provided in previous post.

  • 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,202
    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
    
  • Hi, I was stuck for a few minutes troubleshooting when I discovered the diagram doesn't show the correct WiFi module placement. See correction below.

    /Users/marcusgarfunkel/Pictures/Photos Library.photoslibrary/resources/derivatives/3/39C8D57A-BB58-46E0-AE28-76C65128E3D1_1_105_c.jpeg

    Thanks,
    Marcus

  • VonSzarvasVonSzarvas Posts: 3,513
    edited 2024-12-26 10:41

    Thanks Markus- will get that updated in the morning.

    Edit: Updated 2024.12.26. - Product guide and .png image files all updated. Thanks to Marcus for spotting that overzealous orange box.

  • Mag748Mag748 Posts: 269
    edited 2024-12-26 23:57

    @VonSzarvas

    Also, the buzzer isn't shown in the diagram :'(

    Thanks for the updates.

  • Ha! yeah, that part was missing on the breadboard making software. Here goes something!

  • Mag748Mag748 Posts: 269
    edited 2024-12-27 18:27

    @VonSzarvas said:
    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 ? :)

    Hi,

    I tested the JonnyMac bin file uploaded via the web page. It does run, although it's not very usable in my current configuration. The app requires a console (terminal) port to access the menu. When I try to run the PIXEL patterns when connected to my PC (MacBook Air), it crashes, I assume due to lack of power available on the USB port. When I run it from the supplied USB Power brick, there's no way to access the serial terminal.

    Thanks,
    Marcus

  • I found the same- jons demo relies on terminal by default. Can you use a powered hub to boost the power?

    Or adjust the code to use less “brightness” for each pixel? Jon has a colorx function in his library, as one way.

    Ideally someone might have time to extend jons code to use the oled for the menu.

    Relatedly… another option for more pixel power could be to add another 5v supply. In testing I used a Parallax powerpal as those are dirt cheap now, and breadboard friendly.

    Too many options of course!!

  • JonnyMacJonnyMac Posts: 9,202
    edited 2024-12-27 21:21

    I tested the JonnyMac bin file uploaded via the web page. It does run, although it's not very usable in my current configuration.

    I can't read minds to make code "usable" for every user's desires or configuration. What I can -- and do -- is provide baseline code that works from which you can take the pieces you need to build YOUR application. Note that I provided a source code archive, not a binary that you can't change.

    The reason I wrote that baseline code using a USB terminal is that it takes a variable out of the equation (WiFi connection, which has been iffy on my end even with my WiFi router sitting five feet from my desk) so that focus is on lighting patterns (something Ken asked me for), and I chose to demonstrate how my embedded music/beeps/boops player works.

  • Jon- if there’s anything to do on the module side to make things less ‘iffy’ please let me know and will do my best to improve it.

Sign In or Register to comment.