Circuit Python for Gamebuino

Créations

Aurélien Rodot

il y a 4 ans

Learn Circuit Python

Get started here.

How to install Circuit Python

Download the zip file, extract it, and copy/past the "CircuitPython" folder to the root of your micro SD card.

Circuit Python Reference

All the generic functions (input / output, if / else, etc.) can be found on Adafruit's Circuit Python Essentials

Find below all the Gamebuino specific supported functions.

(usage is the same as the c++ equivalents)

Things in brackets [] are optional parameters

Base

  • void gb.begin() unneeded!
  • void gb.loader() loads loader, was very useful for testing & re-flashing
  • bool gb.update()
  • void gb.waitForUpdate() waits until next screen update
  • void gb.updateDisplay()
  • void gb.setFrameRate(int framerate)
  • int gb.getCpuLoad()
  • int gb.getFreeRam()
  • string gb.getDefaultName() Pretty useless as SD functionality isn't implemented currently

Display

  • void gb.display.clear([int color])
  • void gb.display.fill([int color])
  • void gb.display.print([int x, int y,] string|int text)
  • void gb.display.println([int x, int y,] string|int text)
  • void gb.display.drawLine(int x1, int y1, int x2, int y2)
  • void gb.display.drawRect(int x, int y, int width, int height)
  • void gb.display.fillRext(int x, int y, int width, int height)
  • void gb.display.drawPixel(int x, int y [, int color])
  • void gb.display.drawCircle(int x, int y, int radius)
  • void gb.display.fillCircle(int x, int y, int radius)
  • void gb.display.drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3)
  • void gb.display.fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3)
  • void gb.display.drawRoundRect(int x, int y, int width, int height, int radius)
  • void gb.display.fillRoundRect(int x, int y, int width, int height, int radius)
  • void gb.display.setColor(int color)
  • void gb.display.drawBitmap(int x, int y, bytes buffer [, int scale])
  • void gb.display.drawImage(int x, int y, buffer image)

Lights

  • void gb.lights.clear([int color])
  • void gb.lights.fill([int color])
  • void gb.lights.fillRect(int x, int y, int width, int height)
  • void gb.lights.drawPixel(int x, int y [, int color])
  • void gb.lights.setColor(int color)

Buttons

Constants :

  • int gb.buttons.DOWN
  • int gb.buttons.LEFT
  • int gb.buttons.RIGHT
  • int gb.buttons.UP
  • int gb.buttons.A
  • int gb.buttons.B
  • int gb.buttons.MENU
  • int gb.buttons.HOME

Methods:

  • bool gb.buttons.pressed(int button)
  • bool gb.buttons.released(int button)
  • bool gb.buttons.held(int button, int duration)
  • bool gb.buttons.repeat(int button, int duration)
  • int gb.buttons.timeHeld(int button)

Collide

  • bool gb.collide.rectRect(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
  • bool gb.collide.pointRect(int pointX, int pointY, int rectX, int rectY, int rectW, int rectH)
  • bool gb.collide.circleCircle(int centerX1, int centerY1, int r1, int centerX2, int centerY2, int r2)
  • bool gb.collide.pointCircle(int pointX, int pointY, int centerX, int centerY, int r)

Color

  • int gb.color.WHITE
  • int gb.color.GRAY
  • int gb.color.DARKGRAY
  • int gb.color.BLACK
  • int gb.color.PURPLE
  • int gb.color.PINK
  • int gb.color.RED
  • int gb.color.ORANGE
  • int gb.color.BROWN
  • int gb.color.BEIGE
  • int gb.color.YELLOW
  • int gb.color.LIGHTGREEN
  • int gb.color.GREEN
  • int gb.color.DARKBLUE
  • int gb.color.BLUE
  • int gb.color.LIGHTBLUE

GUI

  • string gb.gui.keyboard(string titleText [, string defaultText])
  • int gb.gui.menu(string titleText, [, array[string] entries])
  • void gb.gui.popup(string text, int duration)

Voir la création

gregvsmj

NEW il y a 4 ans

Au top, j'attendais de voir un exemple de ce qu'allait donner le python sur la Meta ^^ Merci Aurélien!

JPBONNAFOUS

NEW il y a 4 ans

J'arrive pas à "monter" le volume circuit python sur mon linux mint 18.10 !
Message d'erreur:

Error 2 hard Fault
Appuyez sur A pour continuer

ça marche sur mon WIN7 du taf par contre... mais c'est ma machine du taf :-(

te3game

NEW il y a 4 ans

C'est génial!
À propos, si j'essaie d'utiliser la bibliothèque CircuitPython avec Gamebuino META, quelle procédure dois-je suivre?
Je pense à utiliser le stockage dans sdcard.mpy etc.

Sorunome

NEW il y a 4 ans

0.0.4 Update

  • Fixed the gamebuino object being cleared by the garbage collector
  • Made calling to gb.begin() unneeded
  • Updated to upstream version 4.0.0-rc1

JPBONNAFOUS

NEW il y a 4 ans

Yeah!!!
Je viens d'installer la 0.0.4 et maintenant j'arrive à monter le volume circuit python sur mon Linux.

Sorunome

NEW il y a 4 ans

0.0.5 Update

This includes all the gb.collide methods

Thierry

NEW il y a 4 ans

That's a good pace of evolution, thanks Sorunome.


te3game

NEW il y a 4 ans

Je ne connais pas la raison.
On a l'impression qu'il n'y a pas eu de problème à 0.0.4.

Le mode coller REPL ne fonctionne pas correctement.
La même chose s'est produite dans le passé, même avec Adafruit Feather.

paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== print("Hello world")
===
Traceback (most recent call last):
  File "<stdin>", line 1
SyntaxError: invalid syntax
>>>

Le problème est résolu.
Le problème est le shell Linux, pas CircuitPython.
Lorsque la commande "reset" est entrée
Le mode coller de CircuitPython fonctionnait correctement.