1
0
forked from me/IronOS

Move out FontStyle

This commit is contained in:
Ben V. Brown
2023-06-29 18:38:50 +10:00
parent 62fb6d5209
commit da7dbd4b55
3 changed files with 25 additions and 6 deletions

View File

@@ -10,6 +10,7 @@
#ifndef OLED_HPP_ #ifndef OLED_HPP_
#define OLED_HPP_ #define OLED_HPP_
#include "Font.h" #include "Font.h"
#include "FontUtils.h"
#include "cmsis_os.h" #include "cmsis_os.h"
#include "configuration.h" #include "configuration.h"
#include <BSP.h> #include <BSP.h>
@@ -61,12 +62,6 @@ extern "C" {
#endif #endif
#define FRAMEBUFFER_START 17 #define FRAMEBUFFER_START 17
enum class FontStyle {
SMALL,
LARGE,
EXTRAS,
};
class OLED { class OLED {
public: public:
enum DisplayState : bool { OFF = false, ON = true }; enum DisplayState : bool { OFF = false, ON = true };

View File

@@ -0,0 +1,12 @@
#pragma once
#include <stdint.h>
enum class FontStyle {
SMALL,
LARGE,
EXTRAS,
FROM_TEXT, // Magically pick from the text
FROM_HEIGHT, // Pick font to best fill the height
};
constexpr uint8_t get_fontstyle_height(const FontStyle font);
constexpr uint8_t get_fontstyle_width(const FontStyle font);

View File

@@ -0,0 +1,12 @@
#include "FontUtils.h"
constexpr uint8_t get_fontstyle_height(const FontStyle font) {
if (font == FontStyle::SMALL)
return 8;
return 16;
}
constexpr uint8_t get_fontstyle_width(const FontStyle font) {
if (font == FontStyle::SMALL)
return 6;
return 12;
}