Coder Social home page Coder Social logo

micropython-scrollbit's Introduction

MicroPython scroll:bit library for the BBC micro:bit

Installing

Copy the scrollbit.py file from library/scrollbit.py into your "mu_code" folder, this might be in:

  • C:\Users\YourUserName\mu_code on Windows
  • /Users/YourUserName/mu_code on macOS

Create a new blank file in Mu for your project, leave it blank and Flash it to your micro:bit with the Flash button. You can close this for now.

Create another new file, save this one as "main.py" and keep it open.

Now open the "Files" dialog (you might have to close the "Repl" first) and drag and drop main.py and scrollbit.py from the right pane, to the left pane.

When you reset your micro:bit, it will load main.py- so you can "import scrollbit" and start writing your code here!

Function Reference

Scroll text across your scroll:bit

scroll(text, brightness=255, delay=10, icons=True)

The text will always start off the right edge of the screen, and scroll across until it disappears off the left edge. You can optionally set the brightness and delay, and turn off icon support if you dont need it (slightly faster).

EG:

scroll("Hello {HEART} World")

Icon names should be in ALL CAPS and surrounded by {CURLY BRACES}. Available icons are:

HEART, HEART_SMALL, HAPPY, SMILE, SAD, CONFUSED, ANGRY, ASLEEP, SURPRISED, SILLY, FABULOUS, MEH, YES, NO, CLOCK12, CLOCK1, CLOCK2, CLOCK3, CLOCK4, CLOCK5, CLOCK6, CLOCK7, CLOCK8, CLOCK9, CLOCK10, CLOCK11, ARROW_N, ARROW_NE, ARROW_E, ARROW_SE, ARROW_S, ARROW_SW, ARROW_W, ARROW_NW, TRIANGLE, TRIANGLE_LEFT, CHESSBOARD, DIAMOND, DIAMOND_SMALL, SQUARE, SQUARE_SMALL, RABBIT, COW, MUSIC_CROTCHET, MUSIC_QUAVER, MUSIC_QUAVERS, PITCHFORK, XMAS, PACMAN, TARGET, ALL_CLOCKS, ALL_ARROWS, TSHIRT, ROLLERSKATE, DUCK, HOUSE, TORTOISE, BUTTERFLY, STICKFIGURE, GHOST, SWORD, GIRAFFE, SKULL, UMBRELLA and SNAKE

Write a string of text to scroll:bit

write(text, offset_col=0, offset_row=0, brightness=255)

This wont appear immediately, you'll have to call show() to display it, but it's useful for positioning short phrases on scroll:bit.

Show an icon on scroll:bit

draw_icon(col, row, icon, brightness=255)

You'll need to use an icon from microbit.Image like microbit.Image.HAPPY, consult the list above or try dir(microbit.Image) in the Repl.

Set a single pixel

set_pixel(col, row, brightness)

The columns and rows you can use are labelled on your scroll:bit, and the brightness can be from 0 to 255.

Show your changes

show()

Call this to display your changes on scroll:bit.

micropython-scrollbit's People

Contributors

gadgetoid avatar loopspace avatar magiccow avatar

Watchers

 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.