On 21.04.2012, at 13:25, David Graham wrote:

> On 4/21/12 2:16 PM, Bert Freudenberg wrote:
>> On 20.04.2012, at 22:14, David Graham wrote:
>> 
>>> It took me almost 20 years, but I finally thought of something interesting 
>>> to put on the Internet. ;)
>>> 
>>> I've been experimenting with a BeagleBone (embedded ARM V7 platform) and 
>>> was able to get Squeak 4.2 running without a problem.  I put together a 
>>> simple demo with a blog post and video, and thought the Squeak list may be 
>>> interested (also, please let me know if I have any technical errors in my 
>>> smalltalk code explanation).
>>> 
>>> http://blog.unthinkable.org/
>>> 
>>> -David
>> Very nice!
>> 
>> There is one flaw in your code. You should never run Morphic code outside 
>> the UI process. But your "appendValue:" message does that. The correct way 
>> would be to write
>> 
>>      WorldState addDeferredUIMessage: [graph1 appendValue: lightValue]
>> 
>> That will cause the block to be evaluated at the next display cycle.
>> 
>> Of course, the proper way to make an updating Morph is to write a new Morph 
>> class. Then you could use Morphic's stepping mechanism to read the data and 
>> display it.
> 
> Thanks Bert!  I just started playing with Morphic and didn't know this. ( 
> also, I just started learning smalltalk last year and mostly working with 
> Zinc on Pharo).  I was targeting my post at non-smalltalk arduino / 
> BeagleBone devs and wanted to keep the syntax as simple as possible, but 
> should I update the post?

Well, people learn from examples, and it's better if the examples do not teach 
bad style.

Here is a way to use Morphic's stepping properly from a workspace. This uses 
the Etoys mechanism of adding methods to an object directly (without having to 
make a new class in the browser):

graph1 := GraphMorph new.
graph1 assureUniClass.
graph1 class compile: 'step
        self appendValue: 50 atRandom.
        super step'.
graph1 class compile: 'stepTime
        ^50'.
graph1 openInWorld.
graph1 extent: 700@500.
graph1 clear.

This avoids having to create a background process, but I'm not sure if that 
makes it more clear to your audience.

- Bert -

>> But for a 10 line hack your code is not bad :)
> I hear this a lot. ;)
> 
> _______________________________________________
> Beginners mailing list
> Beginners@lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to