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: 2
    • This is the automatic border that comes with the tkinter canvas. On my device it's 2 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
    • 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.1.4.tar.gz (7.1 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.1.4-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for turtlebyte-0.1.4.tar.gz
Algorithm Hash digest
SHA256 f71357fe95ecaa5789e80525b106818f3eb5c62826bfd9ee0286577c4e23d775
MD5 63f34dfb4d14642f24dbc88c0ee2fbf6
BLAKE2b-256 f6503df8435a6cd483a80b78bf268c5c110feba916ecddeb9353b17c62374061

See more details on using hashes here.

Provenance

The following attestation bundles were made for turtlebyte-0.1.4.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.1.4-py3-none-any.whl.

File metadata

  • Download URL: turtlebyte-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.8 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.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c6565f3947b4d60a24b29b61dadb47e578046b5b7dfc70c7d6d890acd29a9a02
MD5 1be28d295ea68d666a51a7184868468d
BLAKE2b-256 a6caec0d209f2c370cb4380247d282ffa1e3c36d91c3f4b2d12ed7ed1a2aae6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for turtlebyte-0.1.4-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