GithubHelp home page GithubHelp logo

micropython-custom-modules's Introduction

Micropython Custom Modules

Custom modules created with MicroPython C API.

A Mandelbrot interface to use to draw on display.

mandelbrot((width: int, height: int), colour: str, (real_start: float, real_end: float, imaginary_start: float, imaginary_end: float) [, iterations: int]) -> bytearray

It allocates a buffer with width * height * 2 bytes (RGB565) of size and used to return calculated Madelbrot as bytearray. Colour options are "r" for red, "g" for green, and "b" for blue. Defauts to blue if passed wrong value. Iterations have default value of 10.

mandelbrot_into((width: int, height: int), colour: str, (real_start: float, real_end: float, imaginary_start: float, imaginary_end: float), buffer: bytearray [, iterations: int]) -> int

Same behaviour mandelbrot but uses buffer passed as args insted of memory allocations. Returns the size of the buffer. Buffer must be size of width * height * 2.

Usage

import mandlebrot
buff = mandlelbrot.mandlebrot((80, 160), "r", (-2, 1, -1, 1))

Using pre-allocated buffer

import mandlebrot
buff = bytearray(80 * 160 * 2)
mandlelbrot.mandlebrot_into((80, 160), "r", (-2, 1, -1, 1), buff)

How to Build

The Bouncing Balls example uses the custom draw circle functions of my fork of micropython. As is added as a submodule you can simply to get my fork.

git submodule update --init -- micropython

Build Micropython for desired port using USER_C_MODULES as the cmake file on the modules folder.

Example using Pico Board:

micropython$ git submodule update --init -- lib/pico-sdk lib/tinyusb
micropython$ make -C mpy-cross
micropython$ cd ports/rp2
micropython/ports/rp2$ make USER_C_MODULES=../../../modules/micropython.cmake 

Now just drag the .uf2 file to your board located on the build folder.

micropython-custom-modules's People

Contributors

lukeflima avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.