BeagleBoard/GSoC/2023 Proposal/MakecodePocketBeagle

= Makecode Arcade Target for PocketBeagle Gamepup= Student: Mrigank Pawagi Mentors: Vaishnav/Andrew Henderson/any other mentor Code: To be added Wiki: http://elinux.org/BeagleBoard/GSoC/2023_Proposal/MakecodePocketBeagle GSoC: To be added

=Status= This project is currently just a proposal.

=Proposal= The pull request to my entry task can be accessed here. This demonstrates my ability to cross-compile and test my compilation with QEMU.

About Me
IRC: mrigank Github: https://github.com/mrigankpawagi LinkedIn: https://www.linkedin.com/in/mrigankpawagi School: Indian Institute of Science (IISc), Bengaluru Country: India Primary languages: English, Hindi Typical work hours: 8AM-11PM IST (GMT+5:30) Why I want to participate in GSoC My first encounter with open source was with Google Code-In, where I got the opportunity to work with organizations like JBoss, Publiclab, and Drupal. Not only did I develop the skill to write better code by understanding conventions and learning to write good comments, but also improved my skills in communicating with other developers through documentation. Most importantly, I learned to use git! These skills have helped me over the years that followed and have made me realize that open-source development helps not only projects and organizations but also assists the growth of individuals as developers. Recently, while learning about flaky tests, I scanned through the open-sourced International Dataset of Flaky Tests (IDoFT) and using NonDex on GitHub Actions, confirmed flaky tests in multiple open-source repositories. I was also able to fix the flaky test in one of these projects (30 Seconds of Java 8). Google Summer of Code will give me the opportunity to continue my endeavors in the open-source space and continue to sharpen such skills which will benefit me for the entirety of my academic and professional career. In particular, I am highly interested in educational technology and have worked on several experimental projects to create interactive learning interfaces. I also received a grant from MIT Solv[ED] to explore the need and impact of such tools, with a focus on drag-and-drop interfaces like Makecode. The opportunity to work on one such tool myself by increasing access to PocketBeagle for beginners is truly exciting to me.

About your project
Project name: Makecode Arcade Target for PocketBeagle Gamepup

Description
Microsoft Makecode Arcade is a free game development environment that makes it possible for people who are new to coding, especially young students, to program games for the web and for handheld devices using a block-based programming interface. It also has an in-browser board simulator for running the game as one develops it. My project aims to develop and deploy a Makecode Arcade target for PocketBeagle boards with the Gamepup cape. This will make it easy for beginners to harness the power of PocketBeagle by making learning to code an enjoyable experience. Since Makecode Arcade allows sharing projects, tutorials, courses, etc. with everybody on the platform, PocketBeagle users will also be able to utilize these resources to their advantage as they get comfortable coding with the board. I will also create some demonstrations and tutorials to help people get started with Gamepup on Arcade.

I will use TypeScript/JavaScript to create support for PocketBeagle Gamepup in Arcade, which is essentially based on PXT. Using WebUSB, our interface will load ELF binary files produced by Makecode Arcade onto the board where the UF2-daemon will execute them. I also plan to create specialized Arcade blocks for the board to perform advanced tasks related to multiplayer capabilities, game currency, etc.

Details on planned tasks
I will begin by flashing my PocketBeagle with a Linux image that can execute UF2 files. I will then set the values of the GPIO pins connected to the Gamepup cape in the arcade.cfg configuration file. Once this is done, I will start working on specialized functionality for the PocketBeagle. I also plan to enhance audio capabilities (which are accessible from the buzzer on Gamepup, or a USB audio adaptor if the user wishes to use one) by expanding the number of supported file types. This can be done by installing mplayer on the board.

I will use the BoneScript library to control the GPIO pins on my board, through functions like pinMode, digitalWrite, digitalRead, attackInterrupt, etc. I will write my functions for each corresponding GPIO functionality as part of the TypeScript code which I use to define blocks for these functions. These blocks will then be available to the user for use in their Arcade game. Since BoneScript is pre-installed on Beagle boards, we should observe the desired functionality when the UF2 files from Arcade are flashed onto the board.

For more specific functionality like controlling LEDs, I will create extensions using the blocks from my previous step itself. This will make a nice tutorial for beginners who are interested in understanding how simple functions can be aggregated to create more complex modules. Makecode allows me to ship my Makecode functions too as extensions. I will carry out a similar process for taking input from push buttons and switches. These operations can be performed by a fairly direct application of digital read/write. For LED matrices, I will have to write relevant TypeScript functions from scratch, since I will be using the I2C port for that purpose.

A similar process (as switches) can be followed for implementing support for force, light, and distance sensors. The only difference, in this case, is that we will be using the analogWrite function (which is also available in BoneScript) instead of its digital counterpart. This is because these sensors provide a continuous input, unlike the discrete inputs from buttons and switches. Basic analog read/write operations can also provide a skeleton for the functionality of motors, servo motors, and dials. Therefore, in creating blocks for these components, I will focus on creating a similar tutorial, like that for LEDs and switches, that will teach abstraction to beginner coders. Real-time I/O is also an aggregate of already available input/output and interrupt functions, and can be implemented with the same approach.

Additional gaming functionality like game currency and other game dynamics can be implemented using existing blocks to create functions to simplify the process. As far as multiplayer capabilities are concerned, I would like to implement Bluetooth connectivity between two different boards, since this is something that has not been done before on Arcade. I will implement this support for use with the HC-05 Bluetooth module, and I will be using I2C port (using BoneScript's functions) to read and write from Bluetooth. These are tasks of less priority that I will implement at the end after all other functionality is tested and documented.

Note
I understand that parts of the above description may not be consistent with how BoneScript, Node JS, and UF2 actually work in the context of PocketBeagle (or BeagleBone). As my mentor pointed out, using BoneScript is independent of UF2 due to a socket connection with Makecode. This approach is however not optimum, as it is less maintainable. On the other hand, from what I have been able to figure out, using ELF binary outputs with the UF2-daemon may sometimes require additional C++ programs to bridge the functionality between our TypeScript code (which was compiled to ELF by Makecode Arcade) and the hardware. This is particularly true for most of the functionality that I plan to implement. I will be spending the entire month of April and also the community bonding period in May to fill my gaps in understanding of these different infrastructures and mapping out the right approach to implement my project.

Timeline
I will be open to extending the deadline if required.

Experience and approach
Although my University has rigorous coursework, I am usually able to take out 30-40 hours per week for extra- and co-curricular activities. Due to club activities and other projects, I have become comfortable with this schedule and am confident that I can devote 25-30 hours every week to this project.

Although I haven't used BeagleBoard before, I have had decent exposure to Raspberry Pi and Arduino. Besides several small robotics projects, I have worked with Raspberry Pi on a project aimed at creating personal servers which people can keep at their homes. These servers could store data and communication in a decentralized manner and could communicate with other servers in a one-to-one fashion. I have also been working with Professor Pradipta Biswas from the Center of Product Design and Manufacturing at IISc to create open-sourced, educational robotics projects using Arduino along with detailed guidelines. My experience with Linux goes beyond using Raspberry Pi – I have been using Ubuntu for personal use (particularly for software development) for quite a while, and have also used Linux Mint and Debian on VirtualBox for compiling programs in the absence of a cross-compiler. Moreover, I have used a lot of block programming tools (like MIT AppInventor, Thunkable, Scratch, etc.) as a kid, and a year ago also received an exploratory grant from MIT Solv[ED] to study the need and impact of such tools.

Finally, I have also had an extensive experience with JavaScript (and TypeScript with React). Some of my projects for which JavaScript (or TypeScript with React) was an integral tool include an assistant to optimize daily schedules (using a novel evolutionary algorithm), a platform to digitize small businesses and improve the local shopping experience, interactive interfaces to teach about exoplanets and optics, a platform to create and join local clubs based on common interests, a crowd-sourced news-verification platform, and an algorithm to analyze exoplanetary data to find the most habitable planet.

Thus, I feel that I am equipped with the basic skills required to start working, along with the prerequisites to learn new things on the go as I develop this project.

Contingency
I will make all possible efforts to continue working on my project even if I get stuck in the absence of my mentor. I will use all resources available to me to ensure that the quality and pace of my project are not adversely affected.

For this, I have Beagle's Slack and IRC channels to ask for help in the community. I can also ask questions on GitHub Discussions in relevant repositories like pxt, pxt-arcade, and uf2-linux, among others. I also have a huge collection of documentation to refer to, from both PXT and BeagleBoard. Several books on BeagleBoard programming are also available.

Benefit
If successfully completed, this project will become a starting point for officially adding a PocketBeagle Target to Makecode Arcade in the future. This will not only allow Beagle users (and other beginners to coding in general) to easily get started with programming their board but will also make the process very exciting and engaging - motivating more people to start using BeagleBoard to begin their programming journey. For the Beagle community, this project will function as a template to create Arcade targets for other boards and capes as well.