Move out FontStyle
This commit is contained in:
@@ -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 };
|
||||||
|
|||||||
12
source/Core/Inc/FontUtils.h
Normal file
12
source/Core/Inc/FontUtils.h
Normal 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);
|
||||||
12
source/Core/Src/FontUtils.cpp
Normal file
12
source/Core/Src/FontUtils.cpp
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user