Hello,
I am using following components:
- Arduino Nano
- RGB OLED display 1,5" : Waveshare, 128x128 Pixels, SPI
I want to use the display as a speedmeter just with a simple code:
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <stdio.h>
// Definitions for Display
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128
#define RST_PIN 8
#define DC_PIN 7 //9
#define CS_PIN 10
#define MOSI_PIN 11
#define SCLK_PIN 13
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_SSD1351 oled = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);
void setup() {
Serial.begin(9600);
oled.begin();
oled.fillRect(0, 0, 128, 128, BLACK);
...
}
void loop() {
oled.setFont(NULL);
oled.setTextSize(2);
oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.println("Speed:");
oled.setFont(&FreeMonoBold12pt7b);
oled.setTextColor(WHITE, BLACK);
oled.println(actualSpeed());
delay(20);
}
actualSpeed() is providing the speed as double.
Now I have some questions:
- Remove rest of the line:
Without oled.setFont(&FreeMonoBold12pt7b); I am getting a proper view on the display:
But when speed was higher (like 23.65) and then getting lower again, the last digit is not removed:
The speed value is correctly updating, by overwriting the old value, but how can I clean the space behind thre speed-value?
- Using individual fonts:
When using an individual font (having code oled.setFont(&FreeMonoBold12pt7b); included),
2.a: the speed value is somehow overlapping the text.line above ("Speed:"):
2.b: the old speed-value is not being deleted before placing the new speed-value:
How can I fix this?
As I am not an Arduino-/c-expert, I wonder, if you might give me some hints about how to adjust the code, to fix the issues.
Thanks a lot.