Shop OBEX P1 Docs P2 Docs Learn Events
Interactively test WS2812 NeoPixel LEDs with Tachyon and serial terminal +Matrix demo - Page 2 — Parallax Forums

Interactively test WS2812 NeoPixel LEDs with Tachyon and serial terminal +Matrix demo

2»

Comments

  • MJBMJB Posts: 1,235
    edited 2014-10-26 03:18
    [QUOTE=
    %1001_1100 .BYTE 9C ok
    force binary
    [/QUOTE]
    binary is corrupted above
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-10-26 04:02
    MJB wrote: »
    binary is corrupted above

    Yes, this forum code makes it hard to keep things formatted sometimes, hence the reason for the blog page
  • David BetzDavid Betz Posts: 14,516
    edited 2014-10-26 05:19
    The # prefix forces a number to decimal and I allow symbols to be mixed with digits so you could say 13 or #13 or #P13 or even #PORT13 as it all resolves the same way but #P13 is much more recognizable as a port number rather than just some constant.
    Here are a few commented examples:
    $13120520 .LONG 1312.0520 ok
    force hex
    $13.12.05.20 .LONG 1312.0520 ok
    force hex with separators
    $13:12:05:20 .LONG 1312.0520 ok
    force hex
    #13:12:05:20 .LONG 0D0C.0514 ok
    force decimal with BCD clock style notation
    $1312_0520 .LONG 1312.0520 ok
    force hex with separators
    #13120520 .LONG 00C8.3408 ok
    force decimal
    #1312_0520 .LONG 00C8.3408 ok
    force decimal with separators
    #80,000,000 .LONG 04C4.B400 ok
    force decimal with commas etc
    01_1100 .BYTE 9C ok
    force binary
    &192.168.16.1 .LONG C0A8.1001 ok
    specify an IP address
    #P26 .BYTE 1A ok
    specify a port number
    #P26:25:19:18 .LONG 1A19.1312 ok
    packing pin numbers into a long (used to set device pinouts)

    BTW, I looked at getting the 8x8 matrix but figured that 8 of the 8 way strips were better value and more flexible, although they only had 5 left in stock. If I am going to do a matrix I am better off with rows of the LED ropes.

    EDIT: Just created a blog entry in regards to numeric notation
    Thanks for the explanation of the # syntax. I figured it was something like that but wanted to make sure there wasn't something subtle that I was missing. Is the link at the bottom of your post "Introduction to TACHYON Forth" still the best way to learn the language? Is it up to date?

    I like the 8x8 matrix because it is compact and the spacing is perfect. Of course, I haven't bought one yet so I guess I don't like them *that* much! :-)
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-10-26 10:24
    David Betz wrote: »
    Thanks for the explanation of the # syntax. I figured it was something like that but wanted to make sure there wasn't something subtle that I was missing. Is the link at the bottom of your post "Introduction to TACHYON Forth" still the best way to learn the language? Is it up to date?

    I like the 8x8 matrix because it is compact and the spacing is perfect. Of course, I haven't bought one yet so I guess I don't like them *that* much! :-)

    I've did a little bit to the intro page and it seems to be up-to-date mostly but it probably needs a little help in the way of feedback so I know what to fix up, what to include, what to elaborate on etc. But certainly the intro page is a real hands-on get into it type intro where you can pick up all the basics.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-10-26 10:38
    I've did a little bit to the intro page and it seems to be up-to-date mostly but it probably needs a little help in the way of feedback so I know what to fix up, what to include, what to elaborate on etc. But certainly the intro page is a real hands-on get into it type intro where you can pick up all the basics.
    Mostly, I was wondering about the PUB and PRI words. I don't recall seeing them described in the tutorial I read a while back. Also, stuff like ==. I can probably guess what they mean mostly but I was looking for a more authoritative source. :-)
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-10-26 11:01
    David Betz wrote: »
    Mostly, I was wondering about the PUB and PRI words. I don't recall seeing them described in the tutorial I read a while back. Also, stuff like ==. I can probably guess what they mean mostly but I was looking for a more authoritative source. :-)

    Well, just a quick note on that before I turn in for the morning :)

    pub and pri can be substituted for the colon which begins a definition and the only real difference is that pri sets a bit in the attributes flag for that definition marking it as <private> but still visible. Later on if you run RECLAIM it will eliminate all those private headers and compact the dictionary thus freeing up space. The use of pub also makes it a bit easier to see that this is a definition or function much like we create one in Spin.

    Likewise there are alias words that I'd rather use as some typical and traditional Forth words seem to clutter the readability as far as I'm concerned. So as well as CONSTANT there is the alias == so that the name and value stand out much more than the big CONSTANT name itself, like this:
    #1,000 == FREQ
    vs
    1000 CONSTANT FREQ

    Another area that I avoid traditional Forth names is when I build tables as the word C, will compile a literal byte but it clutters the reading:
    TABLE lookup
    12 C, 34 C, 56 C, 78 C,
    vs a much cleaner look:
    TABLE lookup
    12 | 34 | 56 | 78 |

    There's also PRINT and PRINT" as I find the dot symbol can be hard to see plus everybody understands PRINT. There are also many different ways of commenting too as once again I find that the old back slash gets lost and looks too much like a math operator anyway. So there are // and --- and multi-line braces { } and quite a few others.

    You can also create your own alias words which inherit the attributes of the parent so that you could even do this:
    ALIAS : void
    void myfunction etc

    But please, if you can, get all these questions together and I will look at improving the intro page.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-10-26 12:21
    Well, just a quick note on that before I turn in for the morning :)

    pub and pri can be substituted for the colon which begins a definition and the only real difference is that pri sets a bit in the attributes flag for that definition marking it as <private> but still visible. Later on if you run RECLAIM it will eliminate all those private headers and compact the dictionary thus freeing up space. The use of pub also makes it a bit easier to see that this is a definition or function much like we create one in Spin.

    Likewise there are alias words that I'd rather use as some typical and traditional Forth words seem to clutter the readability as far as I'm concerned. So as well as CONSTANT there is the alias == so that the name and value stand out much more than the big CONSTANT name itself, like this:
    #1,000 == FREQ
    vs
    1000 CONSTANT FREQ

    Another area that I avoid traditional Forth names is when I build tables as the word C, will compile a literal byte but it clutters the reading:
    TABLE lookup
    12 C, 34 C, 56 C, 78 C,
    vs a much cleaner look:
    TABLE lookup
    12 | 34 | 56 | 78 |

    There's also PRINT and PRINT" as I find the dot symbol can be hard to see plus everybody understands PRINT. There are also many different ways of commenting too as once again I find that the old back slash gets lost and looks too much like a math operator anyway. So there are // and --- and multi-line braces { } and quite a few others.

    You can also create your own alias words which inherit the attributes of the parent so that you could even do this:
    ALIAS : void
    void myfunction etc

    But please, if you can, get all these questions together and I will look at improving the intro page.
    Thanks for the explanations.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-03-28 04:10
    Now finally I have some LEDs so I have connected them into a 5x8 matrix because that's all I've got and they work great, and man, are they bright!.
    Decided to get it to draw a 5x7 font on the display and then divert Tachyon console output to the display.

    If you can bear it here's a quick video.

  • TubularTubular Posts: 4,702
    edited 2014-10-28 01:04
    Very nice Peter!

    I have a 1200 led array i would love to test this on.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-10-28 01:51
    Tubular wrote: »
    Very nice Peter!

    I have a 1200 led array i would love to test this on.

    Finally got back into it and implemented a smooth scroll-in for each character and set it up for a better video with the matrix sitting over the terminal screen and the camera fixed. I will post this a little later.

    So I will improve the matrix output stream driver to handle control characters which would also include brightness and colors etc.

    There's also a patch (rev X#24) to the kernel as the WS2812 module was sending the lsb first which was picked up as the msb, no wonder the brightness wasn't working correctly!

    Let me know your 1200 led configuration and I see if I can set up the code to work correctly so hopefully you should be able to paste in the source and it should work. You can even turn the Prop into a serial slave and talk to it over Bluetooth or even Telnet.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-10-28 01:55
    Now finally I have some LEDs so I have connected them into a 5x8 matrix because that's all I've got and they work great, and man, are they bright!.
    Decided to get it to draw a 5x7 font on the display and then divert Tachyon console output to the display.
    Awesome! Shows the power of an interactive interface.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-03-28 04:09
    As promised earlier I have done a simple video showing how easy it is to direct text output from Tachyon onto the display but with smooth scrolling. After I tidy up the code I will add the link to it on this post.

    This link here also includes links to the YouTube video and the Propeller binary which includes the 5x7 font. You can patch in a new transmit pin or simply copy and paste modified code.

    LINK to Tachyon WS2812 MATRIX.fth document

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-10-28 19:37
    As promised earlier I have done a simple video showing how easy it is to direct text output from Tachyon onto the display but with smooth scrolling. After I tidy up the code I will add the link to it on this post.

    This link here also includes links to the YouTube video and the Propeller binary which includes the 5x7 font. You can patch in a new transmit pin or simply copy and paste modified code.

    LINK to Tachyon WS2812 MATRIX.fth document

    [video=youtube_share;5J0IOyCRAbM]

    The demo source has now been updated and I have included links to the binary etc.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-10-29 17:40
    If you check out the WS2812 MATRIX source code page it has been updated and the code refined a lot but I haven't been happy about how colors are specified and used so I made a few changes.

    First off, the color words can set foreground and background with the INK and PAPER words which are both concise and easily understood.

    Secondly all the color definitions are used with a weight or descriptor to specify how much so you would always say WEAK RED INK if you didn't want it burn out your eyeballs.

    Thirdly, rather than just using fixed constants for colors they can be specified as percentages of RGB and they still have a weight that can be used to adjust them.

    Examples of weights or shades are:
    WEAK
    STRONG
    BOLD
    MEDIUM
    etc or you can just specify the absolute value from 0-255 with 18 RED INK for instance.

    At the moment I'm taking values from an RGB color chart and tuning some of them when I check them, but maybe if you have some LEDs you can check them too. Don't forget to diffuse these a little to blend the RGB colors together a bit better.

    So for now I can type:
    WEAK AQUA PAPER MEDIUM ORANGE INK DEMO
    and it is so!

    BTW, the MATRIX demo also includes handling of control characters so you can change the colors etc using control characters in the stream, so the string itself is all that is normally needed to control the matrix display. If you slave the Prop to a serial port or similar then you can treat the Prop as a smart serial message display. But I have to hook-up more LEDs now to try all this out.

    Happy interacting.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-10-29 19:07
    If you check out the WS2812 MATRIX source code page it has been updated and the code refined a lot but I haven't been happy about how colors are specified and used so I made a few changes.

    First off, the color words can set foreground and background with the INK and PAPER words which are both concise and easily understood.

    Secondly all the color definitions are used with a weight or descriptor to specify how much so you would always say WEAK RED INK if you didn't want it burn out your eyeballs.

    Thirdly, rather than just using fixed constants for colors they can be specified as percentages of RGB and they still have a weight that can be used to adjust them.

    Examples of weights or shades are:
    WEAK
    STRONG
    BOLD
    MEDIUM
    etc or you can just specify the absolute value from 0-255 with 18 RED INK for instance.

    At the moment I'm taking values from an RGB color chart and tuning some of them when I check them, but maybe if you have some LEDs you can check them too. Don't forget to diffuse these a little to blend the RGB colors together a bit better.

    So for now I can type:
    WEAK AQUA PAPER MEDIUM ORANGE INK DEMO
    and it is so!

    BTW, the MATRIX demo also includes handling of control characters so you can change the colors etc using control characters in the stream, so the string itself is all that is normally needed to control the matrix display. If you slave the Prop to a serial port or similar then you can treat the Prop as a smart serial message display. But I have to hook-up more LEDs now to try all this out.

    Happy interacting.
    Sounds nice. I am lazy and ordered the 8x8 LED matrix from AdaFruit. It should come tomorrow so I'll be able to play over the weekend. I think your idea of buying a bunch of long strips of LEDs and making a multi-character display is probably the best way of doing this though. The individual 8x8 displays are too expensive.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-10-30 02:29
    David Betz wrote: »
    Sounds nice. I am lazy and ordered the 8x8 LED matrix from AdaFruit. It should come tomorrow so I'll be able to play over the weekend. I think your idea of buying a bunch of long strips of LEDs and making a multi-character display is probably the best way of doing this though. The individual 8x8 displays are too expensive.

    Well, the strips certainly seemed a lot more flexible in how I could configure them anyway and as you can see it wasn't a problem to turn them into a matrix, and just enough for one character! But I don't really see the need to maintain full 24-bit color for these things unless I did a really big video screen. So I am compressing each pixel down to 8-bit color and a CLUT and this will also simplify the graphics drivers too. As I read a byte I translate that into 24-bits in the CLUT which can be tuned to suit the LEDs.

    Even with eight 5M strips with 300 LEDs per strip that's "only" 2400 LEDs and it would take 72ms to update the whole lot over a single pin which would still allow for smooth scrolling anyway so there is no need to have more than one pin drive these things I guess. A 5M strip would give me up to 50 characters wide, so maybe a 2M strip would still be fine for 20 characters and a 35 fps update rate. There's a lot of 5M strip lights that can be cut to size and rejoined via their PCB edge fingers so the 10M (2x5M) strips work out a lot cheaper than trying to use those expensive 8x8 matrix pcbs, that's for sure.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-10-31 06:29
    Well, the strips certainly seemed a lot more flexible in how I could configure them anyway and as you can see it wasn't a problem to turn them into a matrix, and just enough for one character! But I don't really see the need to maintain full 24-bit color for these things unless I did a really big video screen. So I am compressing each pixel down to 8-bit color and a CLUT and this will also simplify the graphics drivers too. As I read a byte I translate that into 24-bits in the CLUT which can be tuned to suit the LEDs.

    Even with eight 5M strips with 300 LEDs per strip that's "only" 2400 LEDs and it would take 72ms to update the whole lot over a single pin which would still allow for smooth scrolling anyway so there is no need to have more than one pin drive these things I guess. A 5M strip would give me up to 50 characters wide, so maybe a 2M strip would still be fine for 20 characters and a 35 fps update rate. There's a lot of 5M strip lights that can be cut to size and rejoined via their PCB edge fingers so the 10M (2x5M) strips work out a lot cheaper than trying to use those expensive 8x8 matrix pcbs, that's for sure.
    I'm not really interested in making scrolling signs but a big 32x32 or larger matrix would be fun for playing with cellular automata.
Sign In or Register to comment.