Page 1 of 9

RaspberryPi Stacks

Posted: Thu Feb 20, 2014 1:02 am
by [-hh]
RaspberryPi Stacks collection #0 = thread-preface

A 'RaspberryPi stack' is, that is the criterion for this collection, any LC stack that is fast enough to run 'smoothly' on a RaspberryPi B and later.

There are a few stacks only, that require RaspberryPi hardware or special additional software. There are/will be a few, that are using GPIO or peripherals (webcam, mini display, camera).

So nearly all of the following stacks will also run (much faster) on all platforms supported by LC.

LC-IDEs for the RaspberryPi are available HERE.
(Thanks to Fraser Gordon from LC-staff.)
  • LC 6.5.1 (fast; scroll download-page to bottom for the link)
  • LC 7.0.4 (slower, but fully implemented Unicode-stuff; linked as 'RPI' in 7.0.4)
For installing and handling some problems see the 'FAQs' of this sub-forum.

The LC 7.0.4 IDE (only) allows (also on Mac/Win/Linux) to build standalones for RaspberryPi.

I've learned a lot in trying to improve scripts for gaining speed on such slow CPU's. What gives some milliseconds only on a 3 GHz Linux box can win a full second on RaspberryPi B (800 MHz).

Have as much fun with the stacks on Raspi as I have!

[Here was dusty snow from last years in this post, I removed it.]

Nov 25, 2014. Some of you asked me for the "gone" stacks of this thread, I hadn't all. Now we are rather complete, thanks for the 'collectors' for sending them back to me.


I lost oversight, a table of content may be also comfortable for you, I'll insert one every 69 stacks :-)

Table of contents (as of Sep 11, 2019)

Re: RaspberryPi Stacks

Posted: Mon Mar 10, 2014 1:57 am
by [-hh]
Raspberry Pi stacks collection #1 = backdropPi.livecode

LC on Raspi has, incl. version 7.0.0, (as earlier linux versions) a nasty "backdrop-bug": If you choose to have a backdrop then, as soon as you click in the backdrop, it hides everything and ctrl-Q (quit) doesn't work. Also it is some work to get rid of this option again.

So, better don't use it on Raspi. Here is a stack that enables you to use a "virtual backdrop" (substack) and has also some other tiny features.

Whenever something disappears (is possible if several stacks are open), then simply click into the backdrop. This brings all other LC windows to front, especially if the backdropPi window hides behind it's substack.
  • MB = show/hide MenuBar
  • TT = show/hide ToolbarText
  • TI = show/hide ToolbarIcons
  • T = show/hide Tools
  • B = show/hide (virtual) backdrop
    Choose below "B" pattern or color for the (virtual) backdrop
    Use scrollWheel over backdrop to adjust its transparency (not yet on Raspi).
backdropPi.jpg (13.75 KiB) Viewed 28487 times
Run info. The stack is fast enough for Raspberry Pi running LC 6.5.1 and later; also runs on all other platforms.

Re: RaspberryPi Stacks

Posted: Mon Mar 10, 2014 9:29 pm
by [-hh]
Raspberry Pi stacks collection #2 = regularPolygons3.livecode

A stack that shall visually explain how regular polygons are constructed. Look at the script, you can see there how the points on the circle are computed.
A triangle (N=3) , we go from N=2 (a line) up,
N=24 is visually already close to a circle.
With newer LC you can also "get" such points for using them. I scripted in detail how such points are created. One single formula (for angle 0) is the central line for understanding it also 'theoretically', a second line -- slightly advanced -- shows how a 'rotation angle' can be involved in the computation.

I added, just for fun, or "learning by doing" for beginners, a simple animation of an oval graphic object along the points of such polygons.

Look at the script and try to change some parts, it may be also fun to simply "play" with the stack and its scripts.

=== EDIT:
The stack below needs a correction:
In line 66 of the card script insert a semicolon after "origin". It should read:

Code: Select all

 case "origin"; put "angle" into X; break

Re: RaspberryPi Stacks

Posted: Tue Mar 11, 2014 9:50 pm
by [-hh]
Raspberry Pi stacks collection #3 = snapToGridInBrowseMode.livecode

This is a self-contained group that handles SnapToGrid In Browse Mode (use with browse tool).
By checking "H" and/or "V" the group makes a horizontal grid and/or vertical grid with the chosen spacing. Here 2-256 are absolute pixel values, 1/2-1/64 divide the height and/or width into equal parts (1/2 gives 2 parts, ..., 1/64 gives 64 parts). The grid is drawn optionally on bottom or on top or hidden.

The group (as background-group) now uses the following handlers PAST the card script, before the stack script. If you wish to use these handlers of the group you have to pass them!

= mouseDown (for dragging/grab)
= mouseUp (for snapToGrid)
= resizeStack (for redrawing the grid)

That is, it will react on every mouseDown that reaches it with dragging (grab) the object that's targeted by mouseDown.

It will react on every mouseUp that reaches it with snapping to the drawn grid, IF button "Snap" is checked OR the ctrlKey is down while mouse goes up. The five small buttons let you select how the snap is done: by aligning the topleft or topright or bottomLeft or bottomRight or the loc of the dragged object with the grid.

It will react on every resizeStack that reaches it with redrawing the grid.

At left are color selectors for the two grids and the card background. Check "Hide" hides the two grids. Snapping is independent of the visibility of the grids.

Now just try with the attached demo stack, choose a horizontal and/or vertical grid and drag the objects around, let them snap to the grid -- in browse mode.

Re: RaspberryPi Stacks

Posted: Thu Mar 13, 2014 12:30 am
by [-hh]
Raspberry Pi stacks collection #4 and #5 = garage1Door.livecode and garage4Doors.livecode

These two stacks play with a moving objects technique, imitating the well known 'garage door effect' of web menus (by jQuery and/or CSS 3).

The simple starter/beginner stack 'garage1Door' is nearly completely developed on raspi and shows the main technique with one door. The scripts are short, commented and rather elementary. It builds a group and one can copy this group 'readymade' to other stacks. Thus you can create your own garage door stack by 4 copy/paste actions. (And the groups can arranged as you like it! Or each one may be hidden and reappear.)
Upper part = the (beginner's) construction-how-to
Lower part = the four 'garage doors'.
The more advanced stack 'garage4Doors' uses the classic set of four doors and shows moreover many variations of this technique. It works not with groups but with 'hiders', because slider variations are simpler derived this way. Each of these visual variations has its own 'movement beauty', clearly depending also on the resources used for the graphic objects. I added the images that shall serve to compare directly to the CSS/jQuery version. You have to add other resources yourself. The scripts require some experiences with message handling and organising possible states. A teeny will probably need some assistance for scripting this or adapting the scripts to other situations.

Options for ...
  • what is moving, 'door' (shutter) or 'garage' (content)
  • where it is moving (in front or back)
  • the direction of movement (up or down)
  • the modus of moving (garage or sliders)
  • the kind of moving (single or synchron)
... sum up to 40 choosable animation types, and these may be each triggered by either mouseEnter, mouseDown or spacebar.

I was really surprised, how good this runs on raspi, even a synchronised moving (it is, needless to say, not perfect).

Re: RaspberryPi Stacks

Posted: Fri Mar 14, 2014 11:27 pm
by [-hh]
Raspberry Pi stacks collection #6= hhRuler.livecode

This stack holds a self-contained ruler-button, you can just copy and paste it to cards on other stacks.(You will find the following info and much more comments in it's script.)

INFO on CRB (= the create/remove ruler button)

Click CRB to create on the current card
  • One On/Off button at topleft for the ruler trigger script.
  • Two fields that show mouseH and mouseV.
  • Two ruler graphics with a tick every 5 pixels, fitting width/height of the card.
  • Two single-line graphics indicating mouseH/mouseV within the rulers.
  • Two multi-line graphics indicating a grid of parts of the width/height of the card.
OptionClick/AltClick CRB to create also a 'full' grid of long lines.
Default grid is quarters of the width and thirds of the height of this card.
(AltClick on Raspi means: Hold first mouseDown and then press altKey while the mouse is still down.)

CmdClick/CtrlClick CRB for a clean remove of al created ruler objects.

If the ruler is ON then
  • hold shiftKey down to show the mouseLoc near the mouseLoc (and indicators).
  • hold cmdKey/ctrlKey down to temporarily disable the mouseMove trigger.
  • rightClick with shiftKey down to record the clickLocs, one after the other, in message box (appending).
After a card's size change simply click (or option-/altClick) CRB again. This will at first remove and then recreate all ruler objects. (Or use the exemplary resizeStack handler of the stack.)
To change the appearance of the ruler you can change the local variables of the script or change the separated 'properties-handler' of CRB to your wishes, for example set an origin different from (0,0). Here is the stack.

Re: RaspberryPi Stacks

Posted: Fri Mar 21, 2014 5:13 pm
by [-hh]
Raspberry Pi stacks collection #7 = imageZoomAndFit.livecode
Raspberry Pi stacks collection #8 = quadratIcon2a.livecode

Image sizing/grouping.

Re: RaspberryPi Stacks

Posted: Mon Mar 31, 2014 12:32 am
by [-hh]
Raspberry Pi stacks collection #9 = drawTime2c.livecode (uses transparency, not for Raspi)
Raspberry Pi stacks collection #10 = drawTimeRaspi2c.livecode (for Raspi and others)
Raspberry Pi stacks collection #11 = calendarColumns.livecode (contains Font installation by script)

Several time displays.

Re: RaspberryPi Stacks

Posted: Tue Apr 01, 2014 3:42 pm
by [-hh]
Raspberry Pi stacks collection #12 = asianRods2c.livecode
Raspberry Pi stacks collection #13 = MACadressTime.livecode (HEX display of time)
Raspberry Pi stacks collection #14 = timeFlows2.livecode (contains using speech on Mac+Win+Raspi)

More (unusual) displays of time.

Re: RaspberryPi Stacks

Posted: Wed Apr 02, 2014 12:45 am
by [-hh]
Raspberry Pi stacks collection #15 = hhTimer.livecode
Raspberry Pi stacks collection #16 = iDate.livecode
Raspberry Pi stacks collection #17 = multipleCountDown.livecode

  • hhTimer: Yet anothe countUp-countDown-time-date display timer.
  • iDate: A one-line-field format and output field to exercise date format.
  • multipleCountDown: counts down several alarms, one after the other (was an answer by me in the forum).

Re: RaspberryPi Stacks

Posted: Thu Apr 03, 2014 4:41 pm
by [-hh]
Raspberry Pi stacks collection #18 = cursorsAndImages1.livecode
Raspberry Pi stacks collection #19 = cursorsAndImages2.livecode
Raspberry Pi stacks collection #20 = cursorsAndImages3.livecode

Fully documented.

Re: RaspberryPi Stacks

Posted: Sun Apr 13, 2014 11:55 pm
by [-hh]
Raspberry Pi stacks collection #21 = TextUtilities2b.livecode

These are four text utilities.
  • Shuffle (= random sort)
    Sorting lines (or other chunks) of a string by "sort str by random(2^15)" is well known to yield biased results by preferring a certain kind of permutations. Here the unbiased shuffle of Durstenfeld/ Fisher/ Knuth/ Yates is used where every permutation has the same probability of being chosen.
  • How Many
    Counts and gives a frequency distribution of chunks of a string. Also determines the frequency of occurence of any substring. Search can be chosen case-insensitive.
  • Text Marks
    Uses a certain (choosable) fixed pattern to build a menu of marks ('tags') in your string and jumps to there. The marks may be switched visible/hidden. Especially useful for scripts if the marking pattern starts with comment chars.
  • Line Numbers
    Lines ('paragraphs') are numbered, soft-wrapping doesn't count.
    Method 1: Shows line numbers (and "." for a softwrapped line) in a separate, attached field. Fast updating with every 'textChanged'.
    Method 2: Shows line numbers 'inline', put as "num :: " before each line. Very fast numbering and 'unnumbering' (if say less than 5000 lines), uses arrays.
TextUtilities2b.jpg (25.72 KiB) Viewed 28260 times
The stack has also two kinds of path menus where you can go to parts of the stack path or file path (as in Mac Finder or TextEdit windows by cmdClick in title).

There are eight 'location' buttons along the stacks boundary for moving the stack to the corresponding locs on the screen.

Re: RaspberryPi Stacks

Posted: Mon Apr 14, 2014 11:02 pm
by Nakia
Any chance you could put together an example stack of LiveCode controlling / reading the IO on the Pi?

I think this is something a lof of people may like to start with...

Re: RaspberryPi Stacks

Posted: Fri Apr 18, 2014 3:31 am
by [-hh]
This is already perfectly solved by Python packages. There is another topic in this subforum about GPIO uses, contains a livecode stack that does it via shell and a link to a python library for that.

Attached you'll find also a stack that shows, how to use python from LC, can be very comfortable for features that LC currently doesn't has, for example 'bigNum'-handling.

Raspberry Pi stacks collection #22 = hhPython2.livecode

This stack is a Python Helper.
Python is the main scripting language of a RaspberryPi and there are a lot of tested scripts, ready for use. To use these with LC we need an interface. This stack is such a (simple) interface. It demonstrates how to use Python from LC via it's "shell" function.

Scripts are commented, every action button has help. There are a few examples added (Text, Big numbers, list building). You can play with these to get basic knowledge of python.

The techniques used here are (after small changes) also applicable to other scripting languages as perl, PHP, Powershell or applescript.

This Python Helper
  • demonstrates how to use scripts of LC objects with other scripting languages.
  • demonstrates how to write and use a temporary file as shell input.
  • demonstrates how to use a saved file (may be currently open in an external editor) as shell input.
  • contains a generally usable 'help mechanism' (done by display in a substack).

Re: RaspberryPi Stacks

Posted: Sun Apr 20, 2014 1:42 pm
by [-hh]
Raspberry Pi stacks collection #23 = setOfPoints.livecode
Raspberry Pi stacks collection #24 = countedSingleSet.livecode
Raspberry Pi stacks collection #25 = countedSets.livecode

A Venn diagram (or set diagram) shows all possible logical relations between a finite number of sets. Venn diagrams are used to teach elementary set theory or to illustrate simple set relationships of rather complicated situations.
Here we give
# an interactive venn diagram where you can generate all possible situations (intersecting or not) between up to three sets,
# a set of radio buttons to generate all possible unions of segments ('atoms') of these sets.

More general than a mathematical set, which is an unordered collection of *distinct* objects (for example a collection of distinct lines of chars) a COUNTED SET is an unordered collection of *indistinct* objects (for example a collection of lines of chars that may have duplicates in this collection). A counted set is also known as a bag.

Here we give a very fast script for creating the frequency display of a counted set, that is the distinct/ unique objects, each prefixed with its frequency of occurence.

Such 'frequency distributions' will be used in part 2 for doing set operations ( OR, AND, SETMINUS, XOR ) between counted sets and creating the frequency display of the resulting counted set, that is the distinct/ unique objects, prefixed with their frequencies of occurence in each of the two sets.

That is, you see from the result too, where the distinct objects come from, what may be an important information.