Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font layout tweaks to be closer to the original unit. #15

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions GNC255/GNC255.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
#include <U8g2lib.h>
#include "allocateMem.h"
#include "commandmessenger.h"
#include "fonts.h"

Layout ComLayout = {
{u8g2_font_logisoso22_tn, 22, {10, 32}},
{u8g2_font_profont10_mr, 10, {0, 32}},
{u8g2_font_profont12_mr, 13, {18, 45}},
{u8g2_font_profont12_mr, 12, {107, 18}},
{u8g2_font_profont12_mr, 12, {120, 18}},
{gnc255frequency, 22, {31, 36}}, /* Value (frequency)*/
{u8g2_font_4x6_mr, 6, {19, 32}}, /* ValueLabel (ACT/STB) */
{u8g2_font_profont12_mr, 13, {33, 48}}, /* Valuelabel (active or standby label) */
{u8g2_font_profont12_mr, 12, {116, 24}}, /* ModeComLabel (COM mode indicator) */
{u8g2_font_profont12_mr, 12, {127, 24}}, /* ModeNavLabel (NAV mode indicator) */
};

Position OffsetActive = {
0,
0};

Position OffsetStandby = {
140,
116,
0};

GNC255::GNC255(uint8_t clk, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset)
Expand All @@ -34,14 +35,19 @@ void GNC255::attach()
Next call the constructor of your custom device
adapt it to the needs of your constructor
********************************************************************************** */
if (!FitInMemory(sizeof(U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI))) {
// if (!FitInMemory(sizeof(U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI))) {
if (!FitInMemory(sizeof(U8G2_SSD1362_256X64_F_4W_HW_SPI))) {
// Error Message to Connector
cmdMessenger.sendCmd(kStatus, F("Custom Device does not fit in Memory"));
return;
}

/* SSD1322 */
//_oledDisplay = new (allocateMemory(sizeof(U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI))) U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI(U8G2_R0, _clk, _data, _cs, _dc);
_oledDisplay = new (allocateMemory(sizeof(U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI))) U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI(U8G2_R0, 53, _dc, _reset);
//_oledDisplay = new (allocateMemory(sizeof(U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI))) U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI(U8G2_R0, 53, _dc, _reset);

// Surenoo SOG25664B2 (SSD1362) 7pin module
_oledDisplay = new (allocateMemory(sizeof(U8G2_SSD1362_256X64_F_4W_HW_SPI))) U8G2_SSD1362_256X64_F_4W_HW_SPI(U8G2_R0, _cs, _dc, _reset);
begin();
}

Expand Down Expand Up @@ -110,6 +116,9 @@ void GNC255::set(int16_t messageID, const char *data)
case 5: // set COM/NAV mode
setMode(strcmp(data, "0") == 0);
break;
case 6: // set contrast (brightness) of OLED
setContrast(atoi(data));
break;
default:
break;
}
Expand Down Expand Up @@ -164,4 +173,9 @@ void GNC255::_renderLabel(const char *text, Label label, Position offset, bool u

_oledDisplay->print(text);
if (update) _oledDisplay->sendBuffer();
}
}

void GNC255::setContrast(uint8_t displayContrast)
{
_oledDisplay->setContrast(displayContrast);
}
6 changes: 5 additions & 1 deletion GNC255/GNC255.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ class GNC255

private:
// U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI *_oledDisplay;
U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI *_oledDisplay;
// U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI *_oledDisplay;
/* Surenoo SOG25664B2 (SSD1362) 7pin module */
U8G2_SSD1362_256X64_F_4W_HW_SPI *_oledDisplay;
bool _initialised;
uint8_t _clk, _data, _cs, _dc, _reset;
bool _hasChanged;
char activeFrequency[8] = "123.456";
char standbyFrequency[8] = "123.456";
uint8_t displayContrast = 32;

void _update();
void _stop();
Expand All @@ -53,4 +56,5 @@ class GNC255
void updateActiveLabel(const char *frequency);
void updateStandbyLabel(const char *frequency);
void _renderLabel(const char *text, Label label, Position offset, bool update = false);
void setContrast(uint8_t displayContrast);
};
14 changes: 14 additions & 0 deletions GNC255/fonts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Fontname: gnc255frequency
Copyright: Created with Fony 1.4.7
Glyphs: 12/12
BBX Build Mode: 0
*/
const uint8_t gnc255frequency[224] U8G2_FONT_SECTION("gnc255frequency") =
"\14\0\4\4\4\5\2\3\5\13\25\0\0\25\0\25\0\0\0\0\0\0\307.\6\63|\205\4/\5\0"
"\244\7\60\17+}\227\63)\134\331\377\312E\232#\0\61\14)\217\62\226\315\377\315\3\6\62\21+"
"}\227\63)\134\15\234n\376p\340\203\7\3\63\25+}\227\63)\134\15\234\315\241+\7Nh\312E"
"\232#\0\64\33+}\267q\304J\31\32\61f\310\64C\306\14\31\63\344\301\203a\3\347\11\0\65\23"
"+}\207\17\14\316\60\211\212\205\63\64\345\42\315\21\0\66\24+}\27$)T\14\234a\22\25\256\354"
"\312E\232#\0\67\20+}\207\17\6\316\216\30e\343\6\316\257\0\70\24+}\227\63)\134\331jD"
"\222,F\331\225\213\64G\0\71\23+}\227\63)\134\331\225\13%\11\347BE\22$\0\0\0\0";
Loading