# saveFrame cuts off top and left side of frame

**URL:** <https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026>\
**Category:** Coding Questions\
**Created:** [July 23, 2018, 8:20pm UTC](https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026 "2018-07-23T20:20:33Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![DZR](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@DZR](https://discourse.processing.org/u/DZR)\
**Post date:** [July 31, 2018, 12:42am UTC](https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026/21 "2018-07-31T00:42:07Z")

</div>

```auto
And this is the Arduino Code:

/ ***************************************************************************
 

```

This is a library for the AMG88xx GridEYE 8x8 IR camera

This sketch tries to read the pixels from the sensor

Designed specifically to work with the Adafruit AMG88 breakout  
----\> [http://www.adafruit.com/products/3538](http://www.adafruit.com/products/3538)

These sensors use I2C to communicate. The device’s I2C address is 0x69

Adafruit invests time and resources providing this open source code,  
please support Adafruit andopen-source hardware by purchasing products  
from Adafruit!

Written by Dean Miller for Adafruit Industries.

```auto
  BSD license, all text above must be included in any redistribution
 *************************************************************************** /

```

#include \<Wire.h\>  
#include \<Adafruit\_AMG88xx.h\>

Adafruit\_AMG88xx amg;

float pixels[AMG88xx\_PIXEL\_ARRAY\_SIZE];

void setup() {  
Serial.begin(115200);  
Serial.println(F(“AMG88xx pixels”));

```
bool status;

// default settings
status = amg.begin();
if (!status) {
    Serial.println("Could not find a valid AMG88xx sensor, check wiring!");
    while (1);
}

Serial.println("-- Pixels Test --");

Serial.println();

delay(100); // let sensor boot up

```

}

void loop() {  
//read all the pixels  
amg.readPixels(pixels);

```
Serial.print("[");
for(int i=1; i<=AMG88xx_PIXEL_ARRAY_SIZE; i++){
  Serial.print(pixels[i-1]/10);
  Serial.print(", ");
  if( i%8 == 0 ) Serial.println();
}
Serial.println("]");
Serial.println();

//delay a second
delay(1000);

```

}`Preformatted text`Preformatted text

```auto

```

---

<div class="post-metadata">

**Author:** ![aigos](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@aigos](https://discourse.processing.org/u/aigos)\
**Post date:** [July 31, 2018, 1:32am UTC](https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026/22 "2018-07-31T01:32:14Z")

</div>

Here’s my arduino code for the amg8833, note, in the processing code, match “COM3” or whatever number to what the serial port is in the Arduino IDE

```auto
#include <Wire.h>
#include <Adafruit_AMG88xx.h>

Adafruit_AMG88xx amg;

float pixels[AMG88xx_PIXEL_ARRAY_SIZE];

float Tmax = 36.0; //what max and min temps are (actually 0-80)
float Tmin = 16.0;
float valMax = 5.0; //values that processing uses to map the colors
float valMin = 1.0;

float range = (Tmax - Tmin); //used to normalize to range 2
float range2 = (valMax - valMin);
float pix;
int resetPin = 12;

void setup() {
  digitalWrite(resetPin, HIGH);
  delay(200);
  pinMode(resetPin, OUTPUT);
  Serial.println("RESET");
  
  
  Serial.begin(115200);

  bool status;

  // default settings
  status = amg.begin();
  if (!status) {
    Serial.println("Could not find a valid AMG88xx sensor, check wiring!");
    while (1);
  }

  delay(100); // let sensor boot up
}

void loop() {
  //read all the pixels
  amg.readPixels(pixels);

  for (int i = 0; i < AMG88xx_PIXEL_ARRAY_SIZE; i++) {
    pix = (abs((pixels[i] - Tmin)) / range);
    if (pix >= 0 && pix <= 1) {
      Serial.print(((pix * range2) + valMin), 3);
      Serial.print(',');
    } else {
      delay(10);
      digitalWrite(resetPin, LOW);
    }
  }

  Serial.println();
  //delay a second
  delay(100);
}

```

---

<div class="post-metadata">

**Author:** ![aigos](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@aigos](https://discourse.processing.org/u/aigos)\
**Post date:** [July 31, 2018, 1:33am UTC](https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026/23 "2018-07-31T01:33:42Z")

</div>

```auto
#include <Wire.h>
#include <Adafruit_AMG88xx.h>

Adafruit_AMG88xx amg;

float pixels[AMG88xx_PIXEL_ARRAY_SIZE];

float Tmax = 36.0; //what max and min temps are (actually 0-80)
float Tmin = 16.0;
float valMax = 5.0; //values that processing uses to map the colors
float valMin = 1.0;

float range = (Tmax - Tmin); //used to normalize to range 2
float range2 = (valMax - valMin);
float pix;
int resetPin = 12;

void setup() {
  digitalWrite(resetPin, HIGH);
  delay(200);
  pinMode(resetPin, OUTPUT);
  Serial.println("RESET");
  
  
  Serial.begin(115200);

  bool status;

  // default settings
  status = amg.begin();
  if (!status) {
    Serial.println("Could not find a valid AMG88xx sensor, check wiring!");
    while (1);
  }

  delay(100); // let sensor boot up
}

void loop() {
  //read all the pixels
  amg.readPixels(pixels);

  for (int i = 0; i < AMG88xx_PIXEL_ARRAY_SIZE; i++) {
    pix = (abs((pixels[i] - Tmin)) / range);
    if (pix >= 0 && pix <= 1) {
      Serial.print(((pix * range2) + valMin), 3);
      Serial.print(',');
    } else {
      delay(10);
      digitalWrite(resetPin, LOW);
    }
  }

  Serial.println();
  //delay a second
  delay(100);
}

```

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [July 31, 2018, 5:12am UTC](https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026/24 "2018-07-31T05:12:24Z")

</div>

@DZR please can you format your code as @kfrajer asked?

> [@kfrajer](#):
>
> Please provide your latest code. No screenshots. Copy and paste, select code and hit the `</>` button before publishing your post so to format your code.

You can still edit your code to do so.

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![DZR](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@DZR](https://discourse.processing.org/u/DZR)\
**Post date:** [July 31, 2018, 5:29pm UTC](https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026/25 "2018-07-31T17:29:20Z")

</div>

I thought I had done that. See above. “Preformatted text”

---

<div class="post-metadata">

**Author:** ![DZR](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@DZR](https://discourse.processing.org/u/DZR)\
**Post date:** [August 1, 2018, 5:27pm UTC](https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026/26 "2018-08-01T17:27:18Z")

</div>

Ok. I think I followed your instructions from your email. Thank you for the reply. I appreciate any help.

---

<div class="post-metadata">

**Author:** ![DZR](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@DZR](https://discourse.processing.org/u/DZR)\
**Post date:** [August 2, 2018, 11:27pm UTC](https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026/27 "2018-08-02T23:27:04Z")

</div>

Can someone help me please?

---

<div class="post-metadata">

**Author:** ![aigos](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@aigos](https://discourse.processing.org/u/aigos)\
**Post date:** [August 2, 2018, 11:44pm UTC](https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026/28 "2018-08-02T23:44:29Z")

</div>

In the line “Pixels[i-1]/10” You’ll want to change that to ((Pixels[i-1]/20)+1). Because, as I said, you want a number between 1 and 5 and the range it can read is from 0-80, so you should only expect those values. and just dividing by 10 alone doesnt properly normalize it

[Previous page](https://discourse.processing.org/t/saveframe-cuts-off-top-and-left-side-of-frame/2026.md?page=1)
