# Linear compass display to use with a MPU

**URL:** <https://discourse.processing.org/t/linear-compass-display-to-use-with-a-mpu/48060>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [March 9, 2026, 8:18pm UTC](https://discourse.processing.org/t/linear-compass-display-to-use-with-a-mpu/48060 "2026-03-09T20:18:02Z")\
**Posts on this page:** 1\
**Showing post:** 28

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 27, 2026, 8:27pm UTC](https://discourse.processing.org/t/linear-compass-display-to-use-with-a-mpu/48060/28 "2026-03-27T20:27:48Z")

</div>

Hello @philtkp,

This aligned the numbers to the scale:

```auto
    ahm.text(""+i*20, 20, 20*i -10, -150, 20); // draws left side degrees   
    ahm.text(""+i*20, -20, 20*i -10, 150, 20); // draws right side degrees

```

I do not often use the text box so had to look that up!

Reference:  
_[text() / Reference / Processing.org](https://processing.org/reference/text_.html)_

This also worked on my end:

```processing
  pitch = ((int) map(mouseX, 00, width, -95, 95));
  pitch = constrain(pitch, -90, 90);
  
  int ym = 160-90; // y margin
  pitchDeg = (int) map(pitch, -90, 90, ym, 300- ym); // You want this mapped to the scale
  println(pitch, pitchDeg);
  
  ahm.noStroke();
  ahm.fill(0, 180, 255);//fills sky
  ahm.rect(0, 0, 300, 300);
  ahm.fill(95, 55, 40); //Fills ground
  
  ahm.rect(0, 0, 300, pitchDeg);

```

What data is being received for yaw, pitch and roll?  
Helps on my end to simulate with mouse or otherwise.  
I like to simulate!

> [@How to draw real-time data in a specific canvas area？](https://discourse.processing.org/t/how-to-draw-real-time-data-in-a-specific-canvas-area/45631/5):
>
> Hello @cola, Another example with simulated data in a thread: // Draw data generated in a thread in realtime. // Data is buffered and drawn with each frame. // // Author: GLV // Date: 2025-01-22 PGraphics d0; FloatList data0; int i; void setup() { size(600, 500); d0 = createGraphics(400, 100); data0 = new FloatList(); frameRate(60); // default thread("requestData"); // start thread to generate data } //\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*…

Have fun!

`:)`

---

_[View the full topic](https://discourse.processing.org/t/linear-compass-display-to-use-with-a-mpu/48060)._
