---
title: TinyGo Code
description: A reference page in my new Starlight docs site.
hero:
  title: "TinyGo Code"
  tagline: A Go Compiler For Small Places.
  image:
    alt: A glittering, brightly colored logo
    file: ../../../assets/tinygo-logo.webp
---

[TinyGo](https://tinygo.org/) is a custom Go compiler for embedded systems and WebAssembly. It was used
to write the microcontroller code for recording the gyro data via Bluetooth.

## Setup

Grab the project files:

```bash
git clone https://avoid.sh/PetActivityMonitor/pet_activity_recorder_tinygo.git
```

And follow the information in the `README.md` file of the project.

## Usage

Only connect one microcontroller at the same time!

- Flash the code to the connected microcontroller.

```bash
make flash
```

- Flash the code in production mode (deactivated serial).

```bash
make production
```

- Flash the code in testing mode (enhanced optimisations that need more testing)

```bash
make testing
```

To set the microcontroller into a flashable state manually the project also includes a
`flashing_time.py` python script.

The script requires `pyserial`:

```bash
python -m pip install pyserial
```

When running the code with `./flashing_time` or `make prepare` (inside of the project directory) the microcontroller will be put in a flashable state.

This state can also be activated manually by tapping the reset button on the microcontroller twice in a short time.
