Skip to main content

A virtual memory device drawn by python's turtle

Project description

Upload Python Package

turtlebyte.py

Turtlebyte is a thing I did for fun. It uses Python's turtle module to store memory by drawing it on your screen. I plan to use it for some silly things in the future.

Installation

pip install turtlebyte --upgrade

Usage

First, instantiate a Turtlebyte object:

from turtlebyte import Turtlebyte
tb = Turtlebyte()

There are two main operations you'll use in turtlebyte:

write_bytes(address: bytes, data: bytes) -> bool

  • Writes the bytes of data at the given address

  • Args:

    • address (bytes): The address to write at
    • data (bytes): The data to write
  • Returns:

    • bool: True if write operation is successful

read_bytes(address: bytes, num_bytes: int) -> bytes

  • Reads the data at given address

  • Args:

    • address(bytes): The address to start reading from
    • num_bytes(int): The number of bytes to read
  • Returns:

    • bytes: The bytes found at the address

Configuration

All configuration is passed to the initial Turtlebyte object. Optional settings (which you will most likely have to experiment with) and their defaults are:

  • turtle_pen_size: 10
  • turtle_speed: 1000 (turtle has a maximum speed)
  • turtle_screensize_x: 600
  • turtle_screensize_y: 600
  • turtle_window_buffer: 6
    • This is the automatic border that comes with the tkinter canvas. On my device it's 6 pixels
  • show_animation: False
    • If this is enabled, the turtle will move across your screen as it writes or reads. It's slow, so I prefer to leave this off and just set a low refresh interval
  • refresh_interval: 10
    • This is the number of bytes between screen updates in write_bytes and read_bytes
  • grid_width: 2
    • The number of columns in the grid of data blocks
  • grid_height: 2
    • The number of rows in the grid of data blocks

Example Usage

from turtlebyte import Turtlebyte

tb = Turtlebyte(
    show_animation = True,
    turtle_pen_size = 15,
    turtle_speed = 20,
    grid_width = 2,
    grid_height = 2
)

msg = b'Hello world!'

tb.write_bytes(b'\x00', msg)

print(tb.read_bytes(b'\x00', len(msg)))

input()

Note that the program does not stay open automatically after it has reached the end of its lifespan, thus the input() call.

Random Notes, for Those Interested

The default block size is 32 by 16 bytes for 512 bytes. I have yet to experiment with other block sizes. You are welcome to, but no promises.

The blocks do not affect the way data is processed, it's entirely for effect.

Each cell is one byte. If you don't feel like slowing down the animation to see what's going on, the byte is 4 bits wide and 2 bits tall. The 8 bits are written top left to top right, down, then bottom right to bottom left.

Cells are written top left to bottom left in the block, then top to bottom on the next column until the block is full.

Blocks are written top left to bottom left, then top to bottom on the next column until the grid is full.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

turtlebyte-0.2.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

turtlebyte-0.2.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file turtlebyte-0.2.0.tar.gz.

File metadata

  • Download URL: turtlebyte-0.2.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for turtlebyte-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a0edd56af1d21e46d2d47ffebf389314a032b07ac208f8f8845fcd2bd8f77037
MD5 ccc15cc41b7881bdb602b8fdf0cd894f
BLAKE2b-256 6ce47883b605a82da0e798f97a59337a0137a2c6cb058e3f480da681a2d820cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for turtlebyte-0.2.0.tar.gz:

Publisher: python-publish.yml on isaac1000000/turtlebyte

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file turtlebyte-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: turtlebyte-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for turtlebyte-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 191f866da0c6d1b885c7836f004c041d8f8cd9cdc74fcbd6515d00c03f635a98
MD5 ff227f6931e43594fc152d41d92c6123
BLAKE2b-256 4b4471a62820c369ae8eba4f2401aef8ce875888309a1f004bd4a5a64b43369e

See more details on using hashes here.

Provenance

The following attestation bundles were made for turtlebyte-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on isaac1000000/turtlebyte

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page