# <shake>

An invisible motion sensor that publishes live acceleration readings as $id variables.

Category: Metadata. Also written `<accelerometer>`.

This tag needs a motion sensor, so try it on your phone.

```ham
<column style="items-center gap-8">
    <shake id="motion"
           precision="1"/>
    <text style="muted">Shake your phone</text>
    <text @text="#motion.value + ' m/s²'"
          style="font-3xl font-bold"></text>
    <text @text="'Last 10 s: ' + #motion.10s.total"
          style="muted text-sm"></text>
</column>
```

How Hype Apps draws it on a phone: [light](https://hypeapps.dev/img/tags/shake-light.webp), [dark](https://hypeapps.dev/img/tags/shake-dark.webp).

## Attributes

| Name | What it does | Default |
|---|---|---|
| `precision` | Decimals every published value is rounded to. | `3` |

## Readings

| Name | What it does |
|---|---|
| `avg` | The average magnitude over the window before it (#id.1s.avg). |
| `max` | The largest magnitude in the window before it (#id.5s.max). |
| `total` | The time integral of the magnitude over the window before it (#id.10s.total), sample-rate independent. |
| `value` | The instantaneous magnitude, gravity removed, in m/s²; with a window before it (#id.1s.value), the window's average. |
| `x.avg` | The x axis, as avg is. |
| `x.max` | The x axis, as max is. |
| `x.total` | The x axis, as total is. |
| `x.value` | The x axis, absolute, as value is; a window may follow the axis (#id.x.1s.value). |
| `y.avg` | The y axis, as avg is. |
| `y.max` | The y axis, as max is. |
| `y.total` | The y axis, as total is. |
| `y.value` | The y axis, as value is. |
| `z.avg` | The z axis, as avg is. |
| `z.max` | The z axis, as max is. |
| `z.total` | The z axis, as total is. |
| `z.value` | The z axis, as value is. |

Any tag also takes gestures: `@on.tap`, `@on.longpress`, `@on.doubletap` and `@on.swipeleft` (and right, up and down). `@click` runs on a tap too.

## Related tags

- [`<column>`](https://hypeapps.dev/docs/reference/column.md): Stacks its children top to bottom, with a gap between them and an alignment across.
- [`<text>`](https://hypeapps.dev/docs/reference/text.md): A run of text; with @text it shows an expression that updates as its variables change.
- [`<config>`](https://hypeapps.dev/docs/reference/config.md): App settings, not drawn itself: theme color, fonts, dark mode and the default look of each tag.
- [`<globals>`](https://hypeapps.dev/docs/reference/globals.md): Declares app-wide variables, kept across pages and optionally saved on the device.
- [`<notification>`](https://hypeapps.dev/docs/reference/notification.md): Wires local and push notifications into the page: schedule one, and act when one is tapped.
- [`<state>`](https://hypeapps.dev/docs/reference/state.md): Declares a draw tool's own variables and starting values, read and written as $tool.* by its handlers.
- [`<styles>`](https://hypeapps.dev/docs/reference/styles.md): Declares named style aliases: each attribute becomes a style token that expands to its value.

All tags: https://hypeapps.dev/docs/reference.md · The full reference: https://hypeapps.dev/llms.txt
