Slide 1

Slide 1 text

Building an arcade with Android By Eric Boissonneault Android Developer @ Transit

Slide 2

Slide 2 text

Agenda ● Discovering a smart lighting product ● Searching for the SDK ● Making my own Android library ● Various experiments ● What about a game? ● Adding controller inputs ● Future improvements and ideas

Slide 3

Slide 3 text

Twinkly Squares

Slide 4

Slide 4 text

Twinkly Squares ● Master tile ○ USB-C powered ○ Using ESP32 microcontroller ○ Wifi capabilities ○ BT capabilities ○ 4 ports for tile cables ● Extension tiles ○ 2 ports for tile cables ● Maximum of 16 tiles (1 master + 15 extension) ● 1 tile = 64 pixels (8x8) ● Current configuration is 9 tiles (24x24) ● Total of 576 pixels ● Pixels mapping is done through the official app

Slide 5

Slide 5 text

Twinkly lights mapping

Slide 6

Slide 6 text

Twinkly product features Effects (animated GIFs) Single color Sound reactive

Slide 7

Slide 7 text

Available SDKs ● No official SDK Source: https://xled-docs.readthedocs.io/ ● An on-device API exists ● API specifications have been reversed-engineered ● Various client implementations can now be found ● No Android SDK

Slide 8

Slide 8 text

Hypothesis Successfully create an Android SDK capable of updating frames… ● Fast enough? ● Over a long period of time? ● Without experiencing lag?

Slide 9

Slide 9 text

Implementation Requirements ● REST Endpoint ○ Authenticate ○ Get the pixels layout ○ Switch to real-time mode ● UDP Endpoint ○ Send frames using the real-time mode

Slide 10

Slide 10 text

Creating a background service

Slide 11

Slide 11 text

Creating a background service

Slide 12

Slide 12 text

Background service: REST API REST API authentication, fetch pixels layout, setup the real-time mode

Slide 13

Slide 13 text

REST API Implementation

Slide 14

Slide 14 text

Background service: Real-time UDP frames Every 25ms: Sends frame if pixels changed OR after 10 seconds idle (keep-alive)

Slide 15

Slide 15 text

UDP datagram (frame) implementation Source: https://xled-docs.readthedocs.io/

Slide 16

Slide 16 text

Board class: Pixels Matrix Representation

Slide 17

Slide 17 text

Experiment 0: Display all pixels in the correct order

Slide 18

Slide 18 text

Experiment 1: Edges and corners

Slide 19

Slide 19 text

Experiment 2: Bitmap

Slide 20

Slide 20 text

Experiment 3: Bitmap horizontal / vertical translation

Slide 21

Slide 21 text

Experiment 4: Text

Slide 22

Slide 22 text

Experiment 5: Tetris

Slide 23

Slide 23 text

Experiment 6: Battleship

Slide 24

Slide 24 text

What about a game? Tug Of War

Slide 25

Slide 25 text

Game implementation

Slide 26

Slide 26 text

Player interaction (input) and sending pixel frames (output)

Slide 27

Slide 27 text

Game controller inputs L2 and R2 buttons

Slide 28

Slide 28 text

Arcade buttons

Slide 29

Slide 29 text

Upcoming game improvements ● Modify the board layout (72x8) ● Adjustable edges for a game ● Pause the game ● Add animations before the game starts and after winning ● Support multiplayer 2v2, 3v3, 4v4 ● Add a leaderboard ● Build a plexiglass table to insert the Twinkly Squares and arcade buttons

Slide 30

Slide 30 text

Idea on my bucket list ● Twinkly Matrix (new product) ● Challenge with mapping the lights ○ X,Y coordinates aren’t accurate ○ Custom mapping tool needed ● Face recognition using a camera with OpenCV ○ Select face area ○ Convert to a pixel matrix ● Project the face pixels into the Twinkly Matrix ● Add animations and various interactions ● Extend the layout from 10x50 lights to 200x40 lights

Slide 31

Slide 31 text

References ● Twinkly products: https://twinkly.com/ ● Twinkly unofficial SDKs documentation: https://xled-docs.readthedocs.io/ ● ChatGPT: https://chat.openai.com/ ● GitHub Copilot: https://github.com/features/copilot ● Arcade buttons: Search for SJ@JX Android on Amazon

Slide 32

Slide 32 text

Questions? Thank you!