Intro #
The “2EAI-PEN-2324-Tiles” project is all about creating an exciting and interactive tile set. It consists of 36 tiles. This project blends technology and creativity to make gaming more fun and engaging.
Each tile consists of a pico, two pressure sensors, and rs485 communication. In the previous research project of this, the pico’s were programmed in rust, with rather pleasing results, with a few flaws. when this engineering project started, we decided, for best coarse of action to program them in python.
Code #
Here i will go over the code that runs on the pico’s as RS485 only specifies the the io and the differential signaling, the code for the project mainly consists of a protocol that has been especialy designed for the project.
it consists of a few lib files, that each contain classes.
RS485.py #
this contains two classes, one to store and use datapackets, the other to send and receive them
the datapacket class:
class datapacket:
channel: int
cmd: int
message: list[int]
def __init__(self, channel, cmd, message):
self.channel = channel
self.cmd = cmd
self.message = message
def to_bytes(self):
return bytes([self.channel, self.cmd]) + bytes(self.message)
def __str__(self):
return str("ch: " + str(self.channel) + " cmd: " + str(self.cmd) + " msg: " + str(self.message))
and the RS485 class, that uses uart_TX
and uart_RX
to send the data on the bus.
this only transmits datapacket
and receives them. it does not have any logic.
this class is used int tileclass to facilitate easier communication
Tile.py #
not really correctly named this one 🤦🏻♂️
This lib contains the way the protocol acts when receiving and transmitting datapacket
’s
it handles the addresses, it checks what type of command it is, and handles the commands
This clas is the same wether it is a Slave
tile or a Master
tile.
This also contains the TileArray
class, this contains the way the tiles should act together.
it contains the list of current in use addresses, and the position of each.
The protocol #
Command List #
Command | Description | Arguments |
---|---|---|
0x00 | Set Channel | 1 byte (channel number) |
0x01 | Set RGB data | 3 bytes (red, green, blue values) |
0x02 | Get pressure data | None |
0x03 | Set RGB and return pressure data | 3 bytes (red, green, blue values) |
0x04 | Reset tiles | None |
0x05 | Debug | 1 byte (debug data) |
0x06 | Send/receive pressure data | None |
Preserved Channels #
Channel | Description |
---|---|
0x00 | Reserved uninitialized channel (for tiles without a defined channel) |
0xFE | Reserved for master channel |
0xFF | All tiles listen to this channel (broadcast channel) |
Demo’s #
these are some of the demonstrations we made
Communication Demo #
Here is a demonstration from early on in the project, this shows how the Tiles communicate via RS485.
3x2 Demo #
This is a demonstration from when the wooden array was fully done, and we could try a 3x2 demonstration