Shop OBEX P1 Docs P2 Docs Learn Events
Code snippet repository? — Parallax Forums

Code snippet repository?

Graham StablerGraham Stabler Posts: 2,510
edited 2011-01-21 18:01 in Propeller 1
The object exchange is pretty awesome but I was wondering if we could start a thread for short pieces of useful code that might be inserted into other programs rather than being objects themselves. I or example have a few functions I use often in my programs for basic data entry, I also have some assembly for some basic 64bit operations that became subroutines. Or even super simple functions like "putcursor(x,y)" which I made for putting the cursor in the correct place when using text rather than having two out commands.

Just a thought I'm not sure how it would work out, discuss.

Graham

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2008-08-19 09:45
    I second the idea smile.gif
  • simonlsimonl Posts: 866
    edited 2008-08-19 11:54
    Seems very sensible to me Graham - I'll third it smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,

    Simon
    www.norfolkhelicopterclub.co.uk
    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
    BTW: I type as I'm thinking, so please don't take any offense at my writing style smile.gif
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-08-19 12:44
    i LOVE the idea. I'm just learning how to work with not only Spin but also object-oriented language in general, not to mention assembly. Considering the stark lack of comments on most objects, it is hard to digest whole programs, so snippets, especially well-commented ones, would be a blessing.

    therefore let us bless one another,
    Mark

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    It might be the Information Age but the Eon of Ignorance has yet to end.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-08-19 13:06
    I've asked for this in the past..

    Parallax, how about a section in the obex?? Pretty please... [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • 4Alex4Alex Posts: 119
    edited 2008-08-19 13:30
    Hi all,

    I think it is a great proposal that Graham made: the absolute best would be to have some sort of classification (or subdivision) for the code snippets. It would avoid the anarchy found on some other sites and it would be MUCH easier to find something.

    Also, some sort of mechanism should be put in place so we can complement, correct or augment on a said snippet without having to follow a whole thread and try to piece everything back together. It would be less intimidating (read 'humble') for some of us that don't feel comfy at the idea of posting a whole spin... For example, I'd like to contribute routines on the several peculiar ICs I use in the course of my work but they're certainly not at such a high flying class of coding that they couldn't be improved. However, they do work!

    In any case, Graham's suggestion would add tremendous functionality to the Propeller (and perhaps reduce the number of repetitive threads about the same questions over and over - I'm the first guilty of it!).

    Cheers,

    Alex
  • AleksAleks Posts: 52
    edited 2008-08-19 13:43
    I also offer my support for this idea.

    4Alex has a good point too, in that classifying it in a similar way as the obex would help everyone find what they're looking for. I have a couple routines to submit myself if it ever becomes a reality

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ~Some men see things as they are and ask "why?"
    I dream of things that never were and ask "why not?"~
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-08-19 13:47
    While I'd rather this were officially sanctioned by Parallax. (Obex)
    We could use the Propeller Wiki propeller.wikispaces.com
    which would allow edits from multiple users.

    I have several routines which I use. I'm positive that there are
    better ways to accomplish the same tasks, coders better than I may
    have refinements. The wiki approach would permit this.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • Jay KickliterJay Kickliter Posts: 446
    edited 2008-08-19 16:14
    I really like the idea of using a wiki. Code could be tweaked and commented to be easily understood. I've been finding some of the Object Exchange code perplexing due to a lack of comments.
  • simonlsimonl Posts: 866
    edited 2008-08-20 09:35
    @OBC: Of course cool.gif The wiki would be perfect, so long as some structure's put in place. (Why didn't I think of that!)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,

    Simon
    www.norfolkhelicopterclub.co.uk
    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
    BTW: I type as I'm thinking, so please don't take any offense at my writing style smile.gif
  • Jeff MartinJeff Martin Posts: 760
    edited 2008-08-20 15:58
    Hi,

    Interesting idea. Ultimately, it seems some kind of obex-like site for posting these snippits would be handy, but we'd want some definite separation between the current obex objects and snippits. We'll have to consider this much more and see if there is something more practical we can do to help "house" it for the Propeller community.

    In the meantime, it seems that a wiki is probably the most practical place to share and collaborate on such things, so by all means, try that out. We will let you know if we come up with a better solution by posting to the Propeller forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Jeff Martin

    · Sr. Software Engineer
    · Parallax, Inc.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-08-20 16:07
    Unless one of you jumps in, I'll start working out a structure for this on wiki.
    (After I recover from the Expo.) [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • jazzedjazzed Posts: 11,803
    edited 2008-08-20 16:24
    In computer science terms, I believe what is being suggested here is a super-set of "Datastructures and Algorithms". If you don't mind loosening up the acronym and a little imagination, one might call this "DNA".

    Of course the "snippets" appear to be more application specific, but most will have "DNA" elements. The greater community would most likely be well served by having a "tool-kit" of generic Propeller DNA as at least a subsection of the "snippets". There are several bright software engineers here whom I'm sure would be happy to give and show off a little too.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve
  • hinvhinv Posts: 1,255
    edited 2011-01-19 07:30
    Maybe now that we have a new forum platform, they could make something that fits the bill here.
  • icepuckicepuck Posts: 466
    edited 2011-01-19 07:42
    Could there be a place for the stamps as well?
    -dan
  • RonPRonP Posts: 384
    edited 2011-01-19 09:18
    I am currently trying to learn some Python for my project and in my searching, I find a lot of code snippets. Great idea for the Prop and Stamp if possible. I have seen the other popular uController has tons of snippets and snippets don't weight much. :smile:

    Ron
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-19 11:33
    Certainly time to ask again. And there was another such thread recently.
  • atlstangatlstang Posts: 20
    edited 2011-01-19 11:52
    This would be helpful, i can see it especially for pasm type routines. Even for spin i constantly refer to the propeller education book just to see how they accomplished tasks in their simple programs. Especially if its just simple tasks, as most of the time things i code, im looking at and saying this could probably be better.

    Just recently i was viewing a i2c driver that was conveniently in spin, to drive a mcp23017 i/o expander. i was able to follow that to understand how i2c data is sent out. Though how to use the mcp23017 and i2c, i was really confused on, i searched all over til i found a forum post on someone doing something similar which pointed me in the right direction, after a while of some trial and error i finally figured it out. if it wasnt that little snippet the guy posted, i dunno if i would of figured it out or how long it would of taken. The data sheets really confuse me still, as im still a complete electronics newbie.
  • max72max72 Posts: 1,155
    edited 2011-01-19 12:19
    http://propeller.wikispaces.com/ already has some of them, as already stated by OBC.
    In my opinion is a good fit.
    Massimo
  • RonPRonP Posts: 384
    edited 2011-01-21 11:59
    Hello All,

    I feel somewhat out of place being new and all. But I would like to propose the following additions to the Propeller wikispaces to create a Propeller Snippet & DNA repository. All I need to do it is a few 'Green Lights', also suggestions ideas. Or just tell me to leave it alone and I am out of my league.:smile:

    Propeller Snippets & DNA (to be added under Software)

    Spin
    PASM
    C
    BASIC

    For each Language a new page with the categories below:

    Re-curing Questions Explained
    Snippets pertaining to all

    Data Storage
    Human Input
    Motor Control
    Speech & Sound
    Tool
    Protocol
    Sensor
    Fun
    Display
    Math
    Signal Generation & Processing


    Each category would link to a new page for users to list their
    their Snippet and create a link to it.

    Let me know what you think. I'll either get to work on it. Or mind my own business.:smile:

    Inspiration "If you build it they will come"

    EDIT: Never mind such a thing exist I just never saw it. It can be found under Released Projects/Object Reference. I guess it just doesn't get used often.:smile:

    -Ron
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-01-21 15:34
    It's a good idea to have a snippet respository. Since none exist, I've gone through posts and created a small local one on my computer which can be used offline for special apps.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-21 16:07
    The problems I see is that we already have a great forum and obex hosted by parallax. In our case, the wiki is an extension, but I never visit it, and to add to it just takes more time than it's worth to me. Hence, I wouldn't bother putting up code there. I even find the obex hard to find time to put my code there.

    So, here is a thought...
    Someone can start a thread "Code Snippets for the Parallax Propeller P8X32A Chip" - please use the full title because it will find it's way into google, etc, too.

    I suggets along the lines of my Prop Tools thread http://forums.parallax.com/showthread.php?106790-Prop-Tools-under-Development-or-Completed-(Index) but the code is within the post with a heading at the top of each post. Once this grows enough, perhaps we can get Parallax to make it a sticky or add it into one of the two stickies we have in the forum.

    This would be much easier for everyone to contribute to. I would start the thread with instructions for it's use if you like, or anyone could jump in.

    Your thoughts???
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2011-01-21 18:01
    Bruce,

    I don't think a direct copy of the OBEX would be good for snippets, some may be only a few lines long and so would be better displayed on a page (via some other script system no doubt). It probably would not need much modification however but it would need to format the code properly.

    Cluso99,

    I agree about the wiki, I feel bad about it but I don't visit it and have no desire to add anything to it, whatever is created should be more local and more Parallaxian. A thread would only work if carefully moderated so that chat could be trimmed as required, even then it would be messy and disorganized.

    Graham
Sign In or Register to comment.