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
  • 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 moved onto the next column until the block is full.

Blocks are written top left to bottom left, then moved onto 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.3.tar.gz (7.0 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.3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: turtlebyte-0.1.3.tar.gz
  • Upload date:
  • Size: 7.0 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.3.tar.gz
Algorithm Hash digest
SHA256 3cf0f59a8ba5063108be645acfb2752d22afac58bb397cdbd41dc84aa222a031
MD5 ade4e8f3a3dec2091c79408e640219da
BLAKE2b-256 afe36a66dea2b3200a9181df238bdf3bc0eaef7849eb34853f3021a920f10903

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: turtlebyte-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 765b8b3c57088e5ff8cdb168626123099b21b88e0762c48ca771221cd3819a38
MD5 fe0ed9186b02195a758ca452a3a5d943
BLAKE2b-256 88f50a80f21648b7a5a87c9236190444c2329e62d77ca0bd0b4fe7e491aa0086

See more details on using hashes here.

Provenance

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