PYCONFR 2015
Marre de faire du C++ avec Arduino?
Marre de faire du C++ avec Arduino?
FAITES DU MICROPYTHON SUR UNE PYBOARD!
QUI SUIS-JE ?Arthur Lutz
Plutôt software que hardwareApprenti en éléctronique
@arthurlutzLogilab
QU'EST-CE MICROPYTHON ?Réécriture en C de python 3.4 pour (ousystèmes contraints)sous-ensemble de la librairie standard (sys, time,struct)le reste de la libraire standard est implémenté sous formede modules indépendants ( )
microcontrôlleur
micropython-lib
QU'EST-CE QUE LA PYBOARD?Carte de référence avec micropython qui tournedirectement sur le microcontrôlleurOpen Hardware
MOTIVATIONLanguage haut niveau avec accès materiel bas niveauBasse consommationMatériel entre l'arduino et la raspberry pi
HISTORIQUE PROJETnovembre 2013 kickstarter par Damien GeorgeObjectif : 15'000 £Atteint : 100'000 £Début 2014: production de 3'000 cartesFin 2014 : production d'une nouvelle serie de 3'000 cartes
SPECSSTM32F405RG: 192k RAM, 1M ROM, 168MHz, CortexM4FUSB micro connecteurLecteur Micro carte SDAccéléromètre 3-axes (MMA7660)Horloge temps réel, 4 LEDs, 2 interrupteurs30 GPIOFilesystème interne ”/flash” et ”/sd”
UTILISATIONshell python - (screen /dev/ttyACM0)système de fichier sur la flash (115k !!)carte SD avec boot.py pour "distribuer" son programmeplusieurs modes possible (port serie + disque, port serie +souris)
REPL
PYTHON ?toute la syntaxe python 3.4 (y compris classes, exceptions,"with", "yield from", etc.)optimisations inspirées de PyPymodule pyb pour acceder au matérielinline assembler
EXEMPLES DE CODEf r o m p y b i m p o r t L E Dl e d = L E D ( 1 ) # r e d l e dl e d . t o g g l e ( )l e d . o n ( )l e d . o f f ( )
DÉMO
TOURNE AUSSI SUR ...unix !ESP8266teensy 3.1etc
EXEMPLE DE CODE> > i m p o r t e s p> > # C o n n e c t t o a W i F i n e t w o r k .> > e s p . c o n n e c t ( ' Y O U R W I F I S S I D N A M E ' , ' Y O U R W I F I S S I D P A S S W O R D ' )> > # D e f i n e f u n c t i o n t o p r i n t d a t a r e c e i v e d f r o m s o c k e t .> > d e f s o c k e t _ p r i n t e r ( s o c k e t , d a t a ) :. . p r i n t ( d a t a )> > # C r e a t e a s o c k e t a n d s e t u p t h e p r i n t f u n c t i o n .> > s o c = e s p . s o c k e t ( )> > s o c . o n r e c v ( s o c k e t _ p r i n t e r )> > s o c . c o n n e c t ( ( ' 1 9 2 . 1 6 8 . 0 . 1 2 ' , 8 0 ) )> > s o c . s e n d ( ' G E T / t e s t w i f i / i n d e x . h t m l H T T P / 1 . 0 \ r \ n \ r \ n ' )b ' H T T P / 1 . 1 2 0 0 O K \ r \ n . . . '
MONDE RÉELcommunauté bien plus petite que Arduino"drivers" pour quelques periphériquesprojets de robotsprojets pédagogiquesvoir aussi les projets de javascript sur microcontroller( )espruino
WIPYmicropython + wifi : wipy