Monday, March 21, 2011

Broadcasting your screen to XO laptops

The Activity Turtle Art can be used to broadcast an OLPC XO laptop's screen to other laptops.

In a shared session, images are reproduced on all laptops from TurtleArt V106. Enter the following code in Pippy and save:


Run the following code on the sending XO laptop in Turtle Art, click the Python block to load the Python code:

The Media block points to the screenshot image

["journal", "/home/olpc/Activities/TurtleArt.activity/screenshot.png"]

Either use this TurtleArt file , hand edit the Media block in a word processor or first run Turtle Art in Gnome (which has a file chooser instead of a journal object chooser) to set the Media block to the screenshot image.

All other laptops in the shared session will receive a screenshot every 5 seconds of the sending laptop's screen, whatever it is showing (but not the mouse cursor). Below the received image of the sending laptop's home view.


The image size and the sending interval are adjustable on the sending laptop with draggable blocks, experiment for the best results on your network.

Programming challenges:
  • Add a mouse cursor
  • break the image up into tiles and only transmit changed tiles

Labels: , , , , ,

Thursday, March 03, 2011

Singing turtle

For TurtleArt on the Sugar OS



Load the Python block with the following code




The inbuilt sample code speak.py will incorporate this functionality from V107

Labels: , , , , ,

Monday, September 13, 2010

Pippy sliderule

Sliderule for Pippy on Sugar
Use arrow keys to move upper scale

Challenges:
Create more markings at useful intervals
Create alternate scales, CI, A, K, S, T, LL, Ln
Add a cursor
Mouse input
Circular sliderule
Replicate all the features at http://wiki.sugarlabs.org/go/Activities/Sliderule

source
Note blog messes up indenting

# sliderule

import pippy, pygame, sys
from pygame.locals import *
import math

# always need to init first thing
pygame.init()

# create the window and keep track of the surface
# for drawing into
screen = pygame.display.set_mode()

# turn off the cursor
pygame.mouse.set_visible(False)

color = (0, 0, 0)
bgcolor = (250,250,250)
rdisp = 0

def drawnum(posx, posy, num):
fsize = 25
msg = str(num)
font = pygame.font.Font(None, fsize)
text = font.render(msg, True, color)
textRect = text.get_rect()
textRect.centerx = posx
textRect.centery = posy
screen.blit(text, textRect)

def drawbox(rightdisp,downdisp,markdisp):
pygame.draw.line(screen, color, (rightdisp+100, downdisp), (rightdisp+800, downdisp))
pygame.draw.line(screen, color, (rightdisp+800, downdisp), (rightdisp+800, downdisp+100))
pygame.draw.line(screen, color, (rightdisp+800, downdisp+100), (rightdisp+100, downdisp+100))
pygame.draw.line(screen, color, (rightdisp+100, downdisp+100), (rightdisp+100, downdisp))
for i in range (1,10):
pygame.draw.line(screen, color, (rightdisp+700*math.log10(i)+100, downdisp+markdisp), (rightdisp+700*math.log10(i)+100, downdisp+markdisp+20))
drawnum(rightdisp+700*math.log10(i)+100,downdisp+50,i)
pygame.display.flip()

def draw2box():
screen.fill(bgcolor)
drawbox(rdisp,100,80)
drawbox(0,200,0)

draw2box()

# events
while pippy.pygame.next_frame():
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()

if event.type == KEYDOWN:
if event.key == K_ESCAPE:
sys.exit()
elif event.key == 275:
rdisp += 10
draw2box()
elif event.key == 276:
rdisp -= 10
draw2box()

Labels: , , ,