Hi, I am using some of the above code to output my f18 radar altimeter min height to an oled. As the guage on the hornet scales (ie not a 1 to1) I need to map the values.
I need some help with the maping,
0 to 34407 should show 0 to 400
34408 to 52559 should show 401 to 1000
above 52560 should show 1001 to 5000
This is my attempt at the mapping code
if (newValue < 34407) {
minHeight = map(newValue, 0, 34407, 0 , 400);
}
if (newValue > 34408 && < 52259) {
minHeight = map(newValue, 34408, 52259, 401 , 1000);
}
else minHeight = map(newValue, 52260, 65539, 1001, 5000);
but it no work....
Obviously I am not a coder and are just trying to reverse engineer all the examples I see. So the above is just an attempt that works if I remove the second "i"f and adjust the mapping values.
Any help would be appreciated.
This the full code for reference
#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
unsigned int minHeight = 0; //Set Height
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
DcsBios::setup();
}
void loop() {
DcsBios::loop();
}
void onRadaltMinHeightPtrChange(unsigned int newValue) {
if (newValue < 34407) {
minHeight = map(newValue, 0, 34407, 0 , 400);
}
if (newValue > 34408 && < 52259) {
minHeight = map(newValue, 34408, 52259, 401 , 1000);
}
else minHeight = map(newValue, 52260,65539, 1001, 5000);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(20,0);
display.print(minHeight);
display.display();
}
DcsBios::IntegerBuffer radaltMinHeightPtrBuffer(0x7518, 0xffff, 0, onRadaltMinHeightPtrChange);