Hi all, the sketch below reads some inputs from a sim game to display a numerical output (ILS Frequency if anyone is interested)
It will read the game output fine, but when the frequency is changed, instead of overwriting the text, it is adding to it, so any lit pixels stay lit. I tried a clearDisplay command in the loop part, but this then means that only parts of the text are displayed
#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1305.h>
#include "Fonts/FreeSans18pt7b.h"
// Used for software SPI
#define OLED_CLK 13
#define OLED_MOSI 11
// Used for software or hardware SPI
#define OLED_CS 8
#define OLED_DC 9
// Used for I2C or SPI
#define OLED_RESET 10
// software SPI
//Adafruit_SSD1305 display(128, 32, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
// hardware SPI - use 7Mhz (7000000UL) or lower because the screen is rated for 4MHz, or it will remain blank!
Adafruit_SSD1305 display(128, 32, &SPI, OLED_DC, OLED_RESET, OLED_CS, 6000000UL);
// I2C
//Adafruit_SSD1305 display(128, 64, &Wire, OLED_RESET);
void setup() {
{
display.begin(0x3C);
delay(1000);
display.clearDisplay(); // clears the screen and buffer
display.setFont(&FreeSans18pt7b);
}
DcsBios::setup();
}
DcsBios::RotaryEncoder ilsVol("ILS_VOL", "-3200", "+3200", 16, 17);
DcsBios::RotaryEncoder ilsKhz("ILS_KHZ", "DEC", "INC", 18, 19);
DcsBios::RotaryEncoder ilsMhz("ILS_MHZ", "DEC", "INC", 15, 14);
void loop() {
DcsBios::loop();
display.setTextColor(WHITE, BLACK);
display.setCursor(66, 27);
display.print(".");
display.display();
}
void onIlsMhzChange(char* newValue) {
display.setTextColor(WHITE, BLACK);
display.setCursor(8, 27);
display.print(newValue);
display.display();
}
DcsBios::StringBuffer<3> ilsMhzStrBuffer(0x116e, onIlsMhzChange);
void onIlsKhzChange(char* newValue) {
display.setTextColor(WHITE, BLACK);
display.setCursor(75, 27);
display.print(newValue);
display.display();
}
DcsBios::StringBuffer<2> ilsKhzStrBuffer(0x1172, onIlsKhzChange);
Can anyone suggest how to get the sketch to refresh the text correctly?
Cheers
Les