PROGMEM use with int and float arrays

Arduino People,

I have been crawling the internet looking for examples of how to use PROGMEM. There are many examples but most 99% of them deal with strings. Those few that don't are so specific that I, a new to arduino coding lay person, do not understand. Mostly leaving my searches ending in a headache. All I'm looking for is how to use PROGMEM with int and float arrays and how to use them later on in the void setup()/loop(). Below is a simplified portion of my code that looks at two different arrays and a potentiometer then spits out a combination of the two. Eventually the code will drive an RGB LED and be used with an ATTiny85. So memory is important.

Also I understand that there is a PROGMEM already in the code. I got it from Adafruit and was only successful because I was able to copy their code. Nothing I try will get their example to do what I am looking for. Any assistance is greatly appreciated.

Ultimate question: How can I put int array tv[] and float array dv[] into PROGMEM and have them work later in the program?

int potPin = 0; 
int pv;
int r;
int g;
int b;
int tv[] = {
  255, 0, 0,
  0, 255, 0,
  0, 0, 255,
  125, 0, 0,
  0, 125, 0,
  0, 0, 125};
float dv[] = { 
  125, 0, 0,
  0, 125, 0,
  0, 0, 125,
  255, 0, 0,
  0, 255, 0,
  0, 0, 255};
const uint8_t PROGMEM gamma8[] = {
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
  2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,
  6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 11, 11,
  11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18,
  19, 19, 20, 21, 21, 22, 22, 23, 23, 24, 25, 25, 26, 27, 27, 28,
  29, 29, 30, 31, 31, 32, 33, 34, 34, 35, 36, 37, 37, 38, 39, 40,
  40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 49, 50, 51, 52, 53, 54,
  55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
  71, 72, 73, 74, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 88, 89,
  90, 91, 93, 94, 95, 96, 98, 99, 100, 102, 103, 104, 106, 107, 109, 110,
  111, 113, 114, 116, 117, 119, 120, 121, 123, 124, 126, 128, 129, 131, 132, 134,
  135, 137, 138, 140, 142, 143, 145, 146, 148, 150, 151, 153, 155, 157, 158, 160,
  162, 163, 165, 167, 169, 170, 172, 174, 176, 178, 179, 181, 183, 185, 187, 189,
  191, 193, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220,
  222, 224, 227, 229, 231, 233, 235, 237, 239, 241, 244, 246, 248, 250, 252, 255};

void setup() {
  Serial.begin(9600);
}
void loop() {
  pv = analogRead(potPin);
  Serial.println(pv);
  for(int i = 0; i <6; i++) {
    if (pv >= 512) {
      r = (tv[i*3]-dv[i*3])*((pv-511)/512)+dv[i*3];
      g = (tv[i*3+1]-dv[i*3+1])*((pv-511)/512)+dv[i*3+1];
      b = (tv[i*3+2]-dv[i*3+2])*((pv-511)/512)+dv[i*3+2];
    }
    else if (pv < 181) {
    }
    else {
      r = pv/511*dv[i*3];
      g = pv/511*dv[i*3+1];
      b = pv/511*dv[i*3+2];
    }
    r = pgm_read_byte(&gamma8[r]);
    g = pgm_read_byte(&gamma8[g]);
    b = pgm_read_byte(&gamma8[b]);
    Serial.println(r);
    Serial.println(g);
    Serial.println(b);
  }
  delay(1000);
}

Thanks!

Pretty much the same way...

const int tv[] PROGMEM = {
 255, 345, 0,
 0, 255, 0,
 0, 0, 255,
 125, 0, 0,
 0, 125, 0,
 0, 0, 125
};
const float dv[] PROGMEM = {
 123.45, 678.9, 0,
 0, 125, 0,
 0, 0, 125,
 255, 0, 0,
 0, 255, 0,
 0, 0, 255
};

void setup() {
 Serial.begin(9600);
 while (!Serial) {
   ; // wait for serial port to connect. Needed for native USB port only
 }
 int j = digitalRead(0);
 int i = pgm_read_word(&tv[j]);
 float f = pgm_read_float(&dv[j]);
 Serial.println(i);
 Serial.println(f);
}

THANKS!

Just to close the loop on this in case someone else, or me in the future, need to know how it turned out using the recommendations.

Memory usage before: 3728 flash / 304 ram
Memory usage after: 3766 flash / 196 ram

int potPin = 0; 
int pv;
int r;
int g;
int b;
const int PROGMEM tv[] = {
  255, 0, 0,
  0, 255, 0,
  0, 0, 255,
  125, 0, 0,
  0, 125, 0,
  0, 0, 125};
const float PROGMEM dv[] = { 
  125, 0, 0,
  0, 125, 0,
  0, 0, 125,
  255, 0, 0,
  0, 255, 0,
  0, 0, 255};
const int PROGMEM gamma8[] = {
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
  2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,
  6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 11, 11,
  11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18,
  19, 19, 20, 21, 21, 22, 22, 23, 23, 24, 25, 25, 26, 27, 27, 28,
  29, 29, 30, 31, 31, 32, 33, 34, 34, 35, 36, 37, 37, 38, 39, 40,
  40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 49, 50, 51, 52, 53, 54,
  55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
  71, 72, 73, 74, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 88, 89,
  90, 91, 93, 94, 95, 96, 98, 99, 100, 102, 103, 104, 106, 107, 109, 110,
  111, 113, 114, 116, 117, 119, 120, 121, 123, 124, 126, 128, 129, 131, 132, 134,
  135, 137, 138, 140, 142, 143, 145, 146, 148, 150, 151, 153, 155, 157, 158, 160,
  162, 163, 165, 167, 169, 170, 172, 174, 176, 178, 179, 181, 183, 185, 187, 189,
  191, 193, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220,
  222, 224, 227, 229, 231, 233, 235, 237, 239, 241, 244, 246, 248, 250, 252, 255};

void setup() {
  Serial.begin(9600);
}
void loop() {
  pv = analogRead(potPin);
  Serial.println(pv);
  for(int i = 0; i <6; i++) {
    if (pv >= 512) {
      r = (pgm_read_word(&tv[i*3])-pgm_read_float(&dv[i*3]))*((pv-511)/512)+pgm_read_float(&dv[i*3]);
      g = (pgm_read_word(&tv[i*3+1])-pgm_read_float(&dv[i*3+1]))*((pv-511)/512)+pgm_read_float(&dv[i*3+1]);
      b = (pgm_read_word(&tv[i*3+2])-pgm_read_float(&dv[i*3+2]))*((pv-511)/512)+pgm_read_float(&dv[i*3+2]);
    }
    else if (pv < 181) {
    }
    else {
      r = pv/511.*pgm_read_float(&dv[i*3]);
      g = pv/511.*pgm_read_float(&dv[i*3+1]);
      b = pv/511.*pgm_read_float(&dv[i*3+2]);
    }
    r = pgm_read_byte(&gamma8[r]);
    g = pgm_read_byte(&gamma8[g]);
    b = pgm_read_byte(&gamma8[b]);
    Serial.println(r);
    Serial.println(g);
    Serial.println(b);
  }
  delay(1000);
}