Raspberry Pi + Python

19

Transcript of Raspberry Pi + Python

Page 1: Raspberry Pi + Python

Raspberry Pi + Python

Daker Fernandes Pinheiro (dakerfp)

Novembro/2012, Python Brasil [8] - Rio de Janeiro / RJ

Page 2: Raspberry Pi + Python

$ whois dakerfp

� Daker Fernandes Pinheiro

� Ciência de Computação pela UFPE - Recife/Brasil

� 2010 - Instituto Nokia de Tecnologia

� Qt, KDE, ...

Page 3: Raspberry Pi + Python
Page 4: Raspberry Pi + Python

O que é?

The Raspberry Pi is a credit-card sized computer thatplugs into your TV and a keyboard. It's a capable littlePC which can be used for many of the things that yourdesktop PC does, like spreadsheets, word-processing andgames. It also plays high-de�nition video. We want tosee it being used by kids all over the world to learnprogramming.

� Barato!

� http://raspberrypi.org/

Page 5: Raspberry Pi + Python

O que posso fazer?

Page 6: Raspberry Pi + Python
Page 7: Raspberry Pi + Python

Raspberry Pi vs Arduino

Arduino� Sentir e Controlar o mundo físico� + Sinais Digitais� + Conversor ADC onboard� + Shields

Page 8: Raspberry Pi + Python

Raspberry Pi + Arduino

� Bridge� Arduino to RPi shields� Gertboard

Page 9: Raspberry Pi + Python

Como obter?

� Modelo A (256MB) - US$25

� Modelo B (512MB) - US$30

� Farnell: http://www.farnell.com/

� RS Components: http://uk.rs-

online.com/web/generalDisplay.html?id=raspberrypi

� + Fonte Micro USB

� + Cartão SD

Page 10: Raspberry Pi + Python

Valeu Brasil!

� >R$150,00

� Câmbio

� Frete Internacional

� Imposto Alfendegário

� ICMS

� INFRAERO

� Taxas Administrativas

� ...

Page 11: Raspberry Pi + Python

Setup

� Download de imagemhttp://www.raspberrypi.org/downloads

� Raspbian� ArchLinux� RISC OS

� $ dd if=imagem.img of=/dev/cartao-sd ||Win32DiskImager

� Encaixe o cartão SD na RPi

� Encaixe a fonte mini USB na força || 4 pilhas

� Redimensione o espaço utilizado

� Have fun!

Page 12: Raspberry Pi + Python

Util

� user: pi password: raspberry

� startx

� shutdown -h 0

� dhclient

Page 13: Raspberry Pi + Python

Python on the Pi

Por quê?

� Didático

� Fácil

� Compilação

� Cross Compilação (arm)

� Divertido

Raspbian

� IDE inclusa

� Exemplos

� Divertido

Page 14: Raspberry Pi + Python

Bibliotecas Grá�cas

� PySide

� PyQt

� PyGTK

� PyGame

� Kivy

� pycairo

� pye�

� PySDL

� ...

Page 15: Raspberry Pi + Python

Aceleração grá�ca

� OpenGL vs OpenGL ES

� OpenGL ES 2: pogles

� OpenMAX: gst-openmax

� Conheça sua API grá�ca

� X.org free: RPi_Vid_Core:https://bitbucket.org/bryancole/rpi_vid_core/wiki/Home

� WIP: Wayland

Page 16: Raspberry Pi + Python

IO

� Seu framework favorito :-)� X.org free:

� evdev: pyglet� GPIO: RPi.GPIO

Page 17: Raspberry Pi + Python

IO

� High: 3.3V Low: 0V� Não é 5V tolerant� Não há proteção contra super-voltagem

Page 18: Raspberry Pi + Python

Dicas

� Evite threads, event loops resolvem

� Python é bom para prototipar, mas não temperformance con�ável em embarcados

� Use o X.org apenas se necessário

� Pense OpenGL ES 2

� Minimize uso de CPU

� Delegue mais funções para APIs implementadas emC

� Faça pro�le antes de otimizar

� Otimize algoritmos antes de escovar bits

Page 19: Raspberry Pi + Python

Duvidas?

http://codecereal.blogspot.comhttp://raspberrypi.org

http://www.elinux.org/R-Pi_Hub@dakerfp

freenode dakerfp

Daker Fernandes Pinheiro (dakerfp)[email protected]://www.anselmolsm.org