Shop OBEX P1 Docs P2 Docs Learn Events
Let's make a P2 hardware cookbook — Parallax Forums

Let's make a P2 hardware cookbook

Andrey DemenevAndrey Demenev Posts: 428
edited 2026-06-06 13:21 in Propeller 2

I started putting together a simple web site that will serve as a community maintained Propeller 2 hardware cookbook.

The idea is this: a git repository with a bunch of markdown files, each file being a recipe. Recipe can belong to one or more topics and a difficulty level. There is some code that converts the file into a site where visitors can browse the recipes by topic and/or difficulty. Contributors can fork the repository, add recipe(s) and submit a pull request

I am just getting started, the site is not available online, I just want to validate the idea. Please let me know if you think this can be useful, and more importantly if you would contribute.

Comments

  • JonnyMacJonnyMac Posts: 9,850
    edited 2026-06-06 15:02

    I like your idea. I'm constantly reminding my new/inexperienced programming friends to just "play" with small experiments and small bits of hardware -- it all adds up in the end.

    BTW, with the pin functions in the P2, you don't have to set the dir bit -- it's handled by the function.

    Also, newcomers might be confused by the schematic having two boxes marked LED. May I suggest:

        Px ----[220R]----[+ LED -]---- GND
    

    Ada created a neat website for P2 assembly instructions that allows one to type and find -- it's very convenient. That kind of site with small examples for instructions would be excellent for new Spin2 programmers.

    -- https://p2docs.github.io/

  • JonnyMacJonnyMac Posts: 9,850
    edited 2026-06-06 17:38

    I wonder... can you have multiple code sections so that you can move from verbose to refined?

    If I may, I'd like to see a little more whitespace in listings. It costs nothing and aids readability.

    Very small contribution attached. This shows three iterations of the same button input program. I don't know the rules of the mark-up language you're using so I just tried to mimic what you did in your example.

  • @JonnyMac Thanks

    I am not ready to add actual recipes yet, I want to make the app first. Actually, that single recipe I have was ai generated, I just needed something that looks realistic, not necessarily correct or polished

    @JonnyMac said:
    I wonder... can you have multiple code sections so that you can move from verbose to refined?

    Yes, absolutely. As many code sections as needed.

  • RaymanRayman Posts: 16,460

    Maybe a web version of something like this:
    https://forums.parallax.com/discussion/175417/

  • There are already so many places where some information might be hidden for P2. Isn't it possible to use obex or the forum? Perhaps a new category has to be implemented?

  • @"Christof Eb." said:
    There are already so many places where some information might be hidden for P2. Isn't it possible to use obex or the forum? Perhaps a new category has to be implemented?

    I am not sure if any of these are good for the goal. OBEX requires downloading and unzipping. Forums are not convenient in terms of search, navigation and categorization.

  • ErNaErNa Posts: 1,862

    Long time ago, I started using CMapTools to build a path through the jungle of information, starting here: https://cmapspublic3.ihmc.us/rid=1181572927203_421963583_5511/PropellerRoot.cmap Meanwhile, there exists a web based cloud app, I didn't use up to now. Maybe now is the time to give this a kick.

  • I have put the server online at https://p2cookbook.fivedotmark.com/

  • JonnyMacJonnyMac Posts: 9,850

    In the example code you have dirh(LED_PIN) -- that is not a valid Spin2 keyword. The pin functions set the direction bit for the pin(s) automatically.

    If you test your code in Spin Tools it will point out errors without having to manually compile.

    Also suggest that -- since this is intended for beginners -- that you stick with verbose names (pinhigh() versus pinh()). Regardless of which version you use, I think it's important for style to be consistent (not that it's not in the above example).

    The smart pin example doesn't work. The inner workings of that mode are more complicated than the example suggests, and for beginners the smart pins should probably be avoided (in manual examples, anyway).

    This is from the P2 docs

    %00110 = NCO frequency
    
    This mode overrides OUT to control the pin output state.
    
    X.[15..0] establishes a base period in clock cycles which forms the empirical high-time and low-time units.
    
    Upon WXPIN, X.[31..16] is written to Z.[31..16] to allow phase setting, even during reset.
    
    Y.[31..0] will be added into Z.[31..0] at each base period.
    
    The pin output will reflect Z.[31].
    
    IN will be raised whenever Z overflows.
    
    During reset (DIR=0), IN is low, the output is low, and Z[15:0] is set to zero.
    
    

    I couldn't remember using P_NCO_FREQ but when looking through my own code base found its use in IR LED modulation.

    pub start(pin, freq)
    
    '' Configure pin for modulated output
    '' -- signal is active-high
    '' -- freq is modulation frequency in Hz (e.g., 40_000)
    
      stop()
    
      lp := pin                                                     ' save pin (control)
      pinstart(lp, P_NCO_FREQ | P_OE, 1, freq frac clkfreq)         ' configure for NCO output
      pinfloat(lp)                                                  ' disable modulation
    
      frametix := clkfreq / 1000 * 45                               ' ticks in 45ms
      setup := true
    

    Here's a (tested) fix if you really want to include the smart pin variation:

      wrpin(LED_56, P_NCO_FREQ | P_OE)                      ' use NCO frequency mode
      wxpin(LED_56, 1)                                      ' set period multiplier (1x)
      wypin(LED_56, 2 frac clkfreq)                         ' base is 2Hz
      pinlow(LED_56)                                        ' enable smart pin output
    

    ...which can be more cleanly encapsulated in pinstart():

      pinstart(LED_56, P_NCO_FREQ | P_OE, 1, 2 frac clkfreq)    
    
  • Andrey DemenevAndrey Demenev Posts: 428
    edited 2026-06-12 22:26

    @JonnyMac thanks for your input

    That example is just AI generated, I did not even check for correctness. For now I am more concerned with site functions like search, filtering and formatting, not the actual examples.

  • JonnyMacJonnyMac Posts: 9,850

    For now I am more concerned with site functions like search

    Okay, I'll stop bothering you. I don't think it's okay to post UNTESTED code that is targeted for beginners.

  • @JonnyMac You are right, I should had tested it before publishing. I have simplified that example keeping only direct pin control and removing all smart stuff, and also made other changes that you suggested. Thank you for your feedback!

  • I am planning to have these topics initially, a recipe can belong to more than one topic:

    • GPIO
    • Clock
    • FIFO
    • Streamer
    • Interfaces {SPI, UART etc}
    • Video
    • CORDIC

    And also it will be possible to create links between recipes ("Related recipes")

Sign In or Register to comment.