Added large and mini fonts, using derived class to print The Dot Factory style font definitions
This commit is contained in:
parent
4924eac137
commit
4f9a077bd7
29
Arduino/BTCDieselHeater/FontTypes.h
Normal file
29
Arduino/BTCDieselHeater/FontTypes.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef __FONT_TYPES_H__
|
||||
#define __FONT_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#else
|
||||
#define PROGMEM
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t Width; // Char width in bits
|
||||
uint8_t Height;
|
||||
uint8_t Offset; // Offset into bitmap array bytes)
|
||||
} FONT_CHAR_INFO;
|
||||
|
||||
typedef struct {
|
||||
uint8_t nBitsPerLine; // Character "height"
|
||||
uint8_t StartChar; // Start character
|
||||
uint8_t EndChar; // End character
|
||||
uint8_t SpaceWidth;
|
||||
const FONT_CHAR_INFO* pCharInfo; // Character descriptor array
|
||||
const unsigned char* pBitmaps; // Character bitmap array
|
||||
} FONT_INFO;
|
||||
|
||||
#endif
|
196
Arduino/BTCDieselHeater/MiniFont.c
Normal file
196
Arduino/BTCDieselHeater/MiniFont.c
Normal file
|
@ -0,0 +1,196 @@
|
|||
#include "MiniFont.h"
|
||||
//
|
||||
// Font data for Tahoma 16pt
|
||||
//
|
||||
|
||||
// Character bitmaps for Tahoma 16pt
|
||||
const uint8_t miniFontBitmaps[] PROGMEM =
|
||||
{
|
||||
// @0 '.' (1 pixels wide)
|
||||
0x08, // #
|
||||
|
||||
// @1 '0' (3 pixels wide)
|
||||
0x70, // ###
|
||||
0x88, // # #
|
||||
0x70, // ###
|
||||
|
||||
// @4 '1' (3 pixels wide)
|
||||
0x48, // # #
|
||||
0xf8, // #####
|
||||
0x08, // #
|
||||
|
||||
// @7 '2' (3 pixels wide)
|
||||
0x98, // # ##
|
||||
0xa8, // # # #
|
||||
0x48, // # #
|
||||
|
||||
// @10 '3' (3 pixels wide)
|
||||
0x88, // # #
|
||||
0xa8, // # # #
|
||||
0xf8, // #####
|
||||
|
||||
// @13 '4' (3 pixels wide)
|
||||
0xe0, // ###
|
||||
0x20, // #
|
||||
0xf8, // #####
|
||||
|
||||
// @16 '5' (3 pixels wide)
|
||||
0xe8, // ### #
|
||||
0xa8, // # # #
|
||||
0x90, // # #
|
||||
|
||||
// @19 '6' (3 pixels wide)
|
||||
0x78, // ####
|
||||
0xa8, // # # #
|
||||
0xb8, // # ###
|
||||
|
||||
// @22 '7' (3 pixels wide)
|
||||
0x80, // #
|
||||
0x80, // #
|
||||
0xf8, // #####
|
||||
|
||||
// @25 '8' (3 pixels wide)
|
||||
0xf8, // #####
|
||||
0xa8, // # # #
|
||||
0xF8, // #####
|
||||
|
||||
// @28 '9' (3 pixels wide)
|
||||
0xe8, // ### #
|
||||
0xa8, // # # #
|
||||
0xF0, // ####
|
||||
|
||||
// @31 '`' (2 pixels wide)
|
||||
0xC0, // ##
|
||||
0xC0, // ##
|
||||
|
||||
// @33 'A' (3 pixels wide)
|
||||
0xf8, // #####
|
||||
0xa0, // # #
|
||||
0xf8, // #####
|
||||
|
||||
// @36 'C' (3 pixels wide)
|
||||
0x70, // ###
|
||||
0x88, // # #
|
||||
0x88, // # #
|
||||
|
||||
// @39 'H' (3 pixels wide)
|
||||
0xf8, // #####
|
||||
0x20, // #
|
||||
0xf8, // #####
|
||||
|
||||
// @42 'P' (3 pixels wide)
|
||||
0xf8, // #####
|
||||
0xa0, // # #
|
||||
0xe0, // ###
|
||||
|
||||
// @45 'V' (3 pixels wide)
|
||||
0xf0, // ####
|
||||
0x08, // #
|
||||
0xf0, // ####
|
||||
|
||||
// @48 'W' (3 pixels wide)
|
||||
0xf8, // #####
|
||||
0x10, // #
|
||||
0xf8, // #####
|
||||
|
||||
// @51 'z' (3 pixels wide)
|
||||
0x28, // # #
|
||||
0x38, // ###
|
||||
0x28, // # #
|
||||
};
|
||||
|
||||
// Character descriptors for Tahoma 16pt
|
||||
// { [Char width in bits], [Char height in bits], [Offset into tahoma_16ptCharBitmaps in bytes] }
|
||||
const FONT_CHAR_INFO miniFontDescriptors[] PROGMEM =
|
||||
{
|
||||
{1, 5, 0}, // '.'
|
||||
{0, 0, 0}, // '/'
|
||||
{3, 5, 1}, // '0'
|
||||
{3, 5, 4}, // '1'
|
||||
{3, 5, 7}, // '2'
|
||||
{3, 5, 10}, // '3'
|
||||
{3, 5, 13}, // '4'
|
||||
{3, 5, 16}, // '5'
|
||||
{3, 5, 19}, // '6'
|
||||
{3, 5, 22}, // '7'
|
||||
{3, 5, 25}, // '8'
|
||||
{3, 5, 28}, // '9'
|
||||
{0, 0, 0}, // ':'
|
||||
{0, 0, 0}, // ';'
|
||||
{0, 0, 0}, // '<'
|
||||
{0, 0, 0}, // '='
|
||||
{0, 0, 0}, // '>'
|
||||
{0, 0, 0}, // '?'
|
||||
{0, 0, 0}, // '@'
|
||||
{3, 5, 33}, // 'A'
|
||||
{0, 0, 0}, // 'B'
|
||||
{3, 5, 36}, // 'C'
|
||||
{0, 0, 0}, // 'D'
|
||||
{0, 0, 0}, // 'E'
|
||||
{0, 0, 0}, // 'F'
|
||||
{0, 0, 0}, // 'G'
|
||||
{3, 5, 39}, // 'H'
|
||||
{0, 0, 0}, // 'I'
|
||||
{0, 0, 0}, // 'J'
|
||||
{0, 0, 0}, // 'K'
|
||||
{0, 0, 0}, // 'L'
|
||||
{0, 0, 0}, // 'M'
|
||||
{0, 0, 0}, // 'N'
|
||||
{0, 0, 0}, // 'O'
|
||||
{3, 5, 42}, // 'P'
|
||||
{0, 0, 0}, // 'Q'
|
||||
{0, 0, 0}, // 'R'
|
||||
{0, 0, 0}, // 'S'
|
||||
{0, 0, 0}, // 'T'
|
||||
{0, 0, 0}, // 'U'
|
||||
{3, 5, 45}, // 'V'
|
||||
{3, 5, 48}, // 'W'
|
||||
{0, 0, 0}, // 'X'
|
||||
{0, 0, 0}, // 'Y'
|
||||
{0, 0, 0}, // 'Z'
|
||||
{0, 0, 0}, // '['
|
||||
{0, 0, 0}, // '\'
|
||||
{0, 0, 0}, // ']'
|
||||
{0, 0, 0}, // '^'
|
||||
{0, 0, 0}, // '_'
|
||||
{2, 5, 31}, // '`' use for degree symbol
|
||||
{0, 0, 0}, // 'a'
|
||||
{0, 0, 0}, // 'b'
|
||||
{0, 0, 0}, // 'c'
|
||||
{0, 0, 0}, // 'd'
|
||||
{0, 0, 0}, // 'e'
|
||||
{0, 0, 0}, // 'f'
|
||||
{0, 0, 0}, // 'g'
|
||||
{0, 0, 0}, // 'h'
|
||||
{0, 0, 0}, // 'i'
|
||||
{0, 0, 0}, // 'j'
|
||||
{0, 0, 0}, // 'k'
|
||||
{0, 0, 0}, // 'l'
|
||||
{0, 0, 0}, // 'm'
|
||||
{0, 0, 0}, // 'n'
|
||||
{0, 0, 0}, // 'o'
|
||||
{0, 0, 0}, // 'p'
|
||||
{0, 0, 0}, // 'q'
|
||||
{0, 0, 0}, // 'r'
|
||||
{0, 0, 0}, // 's'
|
||||
{0, 0, 0}, // 't'
|
||||
{0, 0, 0}, // 'u'
|
||||
{0, 0, 0}, // 'v'
|
||||
{0, 0, 0}, // 'w'
|
||||
{0, 0, 0}, // 'x'
|
||||
{0, 0, 0}, // 'y'
|
||||
{3, 5, 51}, // 'z'
|
||||
};
|
||||
|
||||
// Font information for Mini Font
|
||||
// easier to leave in RAM, not that big anyway
|
||||
const FONT_INFO miniFontInfo =
|
||||
{
|
||||
5, // Character height
|
||||
'.', // Start character
|
||||
'z', // End character
|
||||
1, // Width, in pixels, of space character
|
||||
miniFontDescriptors, // Character descriptor array
|
||||
miniFontBitmaps, // Character bitmap array
|
||||
};
|
||||
|
7
Arduino/BTCDieselHeater/MiniFont.h
Normal file
7
Arduino/BTCDieselHeater/MiniFont.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "FontTypes.h"
|
||||
|
||||
// Font data for Mini Font
|
||||
extern const uint8_t miniFontBitmaps[] PROGMEM; // stored in program flash memory
|
||||
extern const FONT_CHAR_INFO miniFontDescriptors[] PROGMEM; // stored in program flash memory
|
||||
extern const FONT_INFO miniFontInfo;
|
||||
|
238
Arduino/BTCDieselHeater/Tahoma16.c
Normal file
238
Arduino/BTCDieselHeater/Tahoma16.c
Normal file
|
@ -0,0 +1,238 @@
|
|||
#include "tahoma16.h"
|
||||
//
|
||||
// Font data for Tahoma 16pt
|
||||
//
|
||||
|
||||
// Character bitmaps for Tahoma 16pt
|
||||
const uint8_t tahoma_16ptBitmaps[] PROGMEM =
|
||||
{
|
||||
// @0 '.' (4 pixels wide)
|
||||
0x00, 0x0F, // ####
|
||||
0x00, 0x0F, // ####
|
||||
0x00, 0x0F, // ####
|
||||
0x00, 0x0F, // ####
|
||||
|
||||
// @8 '0' (11 pixels wide)
|
||||
0x0F, 0xF0, // ########
|
||||
0x3F, 0xFC, // ############
|
||||
0x7F, 0xFE, // ##############
|
||||
0xFF, 0xFF, // ################
|
||||
0xF0, 0x0F, // #### ####
|
||||
0xE0, 0x07, // ### ###
|
||||
0xF0, 0x0F, // #### ####
|
||||
0xFF, 0xFF, // ################
|
||||
0x7F, 0xFE, // ##############
|
||||
0x3F, 0xFC, // ############
|
||||
0x0F, 0xF0, // ########
|
||||
|
||||
// @30 '1' (10 pixels wide)
|
||||
0x38, 0x07, // ### ###
|
||||
0x38, 0x07, // ### ###
|
||||
0x38, 0x07, // ### ###
|
||||
0xFF, 0xFF, // ################
|
||||
0xFF, 0xFF, // ################
|
||||
0xFF, 0xFF, // ################
|
||||
0xFF, 0xFF, // ################
|
||||
0x00, 0x07, // ###
|
||||
0x00, 0x07, // ###
|
||||
0x00, 0x07, // ###
|
||||
|
||||
// @50 '2' (11 pixels wide)
|
||||
0x70, 0x07, // ### ###
|
||||
0xE0, 0x0F, // ### ####
|
||||
0xE0, 0x1F, // ### #####
|
||||
0xE0, 0x3F, // ### ######
|
||||
0xE0, 0x7F, // ### #######
|
||||
0xF1, 0xF7, // #### ##### ###
|
||||
0xFF, 0xE7, // ########### ###
|
||||
0x7F, 0xC7, // ######### ###
|
||||
0x7F, 0x87, // ######## ###
|
||||
0x3E, 0x07, // ##### ###
|
||||
0x00, 0x07, // ###
|
||||
|
||||
// @72 '3' (11 pixels wide)
|
||||
0x70, 0x0E, // ### ###
|
||||
0xF0, 0x0F, // #### ####
|
||||
0xE0, 0x07, // ### ###
|
||||
0xE3, 0x87, // ### ### ###
|
||||
0xE3, 0x87, // ### ### ###
|
||||
0xE3, 0x87, // ### ### ###
|
||||
0xE7, 0xCF, // ### ##### ####
|
||||
0xFF, 0xFF, // ################
|
||||
0x7E, 0xFE, // ###### #######
|
||||
0x7E, 0xFE, // ###### #######
|
||||
0x3C, 0x78, // #### ####
|
||||
|
||||
// @94 '4' (12 pixels wide)
|
||||
0x00, 0xF0, // ####
|
||||
0x01, 0xF0, // #####
|
||||
0x07, 0x70, // ### ###
|
||||
0x0E, 0x70, // ### ###
|
||||
0x38, 0x70, // ### ###
|
||||
0x70, 0x70, // ### ###
|
||||
0xFF, 0xFF, // ################
|
||||
0xFF, 0xFF, // ################
|
||||
0xFF, 0xFF, // ################
|
||||
0xFF, 0xFF, // ################
|
||||
0x00, 0x70, // ###
|
||||
0x00, 0x70, // ###
|
||||
|
||||
// @118 '5' (11 pixels wide)
|
||||
0x00, 0x0E, // ###
|
||||
0xFF, 0x87, // ######### ###
|
||||
0xFF, 0x87, // ######### ###
|
||||
0xFF, 0x87, // ######### ###
|
||||
0xFF, 0x87, // ######### ###
|
||||
0xE3, 0x87, // ### ### ###
|
||||
0xE3, 0xCF, // ### #### ####
|
||||
0xE3, 0xFF, // ### ##########
|
||||
0xE3, 0xFE, // ### #########
|
||||
0xE1, 0xFC, // ### #######
|
||||
0xE0, 0xF8, // ### #####
|
||||
|
||||
// @140 '6' (11 pixels wide)
|
||||
0x07, 0xF0, // #######
|
||||
0x1F, 0xFC, // ###########
|
||||
0x3F, 0xFE, // #############
|
||||
0x7F, 0xFF, // ###############
|
||||
0xFB, 0x0F, // ##### ## ####
|
||||
0xF7, 0x07, // #### ### ###
|
||||
0xE7, 0x8F, // ### #### ####
|
||||
0xE7, 0xFF, // ### ###########
|
||||
0xE7, 0xFE, // ### ##########
|
||||
0xE3, 0xFC, // ### ########
|
||||
0x01, 0xF8, // ######
|
||||
|
||||
// @162 '7' (11 pixels wide)
|
||||
0xE0, 0x01, // ### #
|
||||
0xE0, 0x07, // ### ###
|
||||
0xE0, 0x1F, // ### #####
|
||||
0xE0, 0x7F, // ### #######
|
||||
0xE1, 0xFF, // ### #########
|
||||
0xE7, 0xFC, // ### #########
|
||||
0xFF, 0xF0, // ############
|
||||
0xFF, 0xC0, // ##########
|
||||
0xFF, 0x00, // ########
|
||||
0xFC, 0x00, // ######
|
||||
0xF0, 0x00, // ####
|
||||
|
||||
// @184 '8' (11 pixels wide)
|
||||
0x3C, 0x3C, // #### ####
|
||||
0x7E, 0xFE, // ###### #######
|
||||
0x7F, 0xFE, // ##############
|
||||
0xFF, 0xFF, // ################
|
||||
0xE7, 0x8F, // ### #### ####
|
||||
0xE3, 0x87, // ### ### ###
|
||||
0xE3, 0xC7, // ### #### ###
|
||||
0xFF, 0xFF, // ################
|
||||
0x7F, 0xFE, // ##############
|
||||
0x7E, 0xFE, // ###### #######
|
||||
0x3C, 0x7C, // #### #####
|
||||
|
||||
// @206 '9' (11 pixels wide)
|
||||
0x1F, 0x80, // ######
|
||||
0x3F, 0xC7, // ######## ###
|
||||
0x7F, 0xE7, // ########## ###
|
||||
0xFF, 0xE7, // ########### ###
|
||||
0xF1, 0xE7, // #### #### ###
|
||||
0xE0, 0xEF, // ### ### ####
|
||||
0xF0, 0xDF, // #### ## #####
|
||||
0xFF, 0xFE, // ###############
|
||||
0x7F, 0xFC, // #############
|
||||
0x3F, 0xF8, // ###########
|
||||
0x0F, 0xE0, // #######
|
||||
|
||||
// @228 '<27>' (8 pixels wide)
|
||||
0x3C, 0x00, // ####
|
||||
0x7E, 0x00, // ######
|
||||
0xE7, 0x00, // ### ###
|
||||
0xC3, 0x00, // ## ##
|
||||
0xC3, 0x00, // ## ##
|
||||
0xE7, 0x00, // ### ###
|
||||
0x7E, 0x00, // ######
|
||||
0x3C, 0x00, // ####
|
||||
|
||||
// @244 'C' (12 pixels wide)
|
||||
0x07, 0xE0, // ######
|
||||
0x1F, 0xF8, // ##########
|
||||
0x3F, 0xFC, // ############
|
||||
0x7F, 0xFE, // ##############
|
||||
0xF8, 0x1F, // ##### #####
|
||||
0xF0, 0x0F, // #### ####
|
||||
0xE0, 0x07, // ### ###
|
||||
0xE0, 0x07, // ### ###
|
||||
0xE0, 0x07, // ### ###
|
||||
0xE0, 0x07, // ### ###
|
||||
0x70, 0x0E, // ### ###
|
||||
0x78, 0x1E, // #### ####
|
||||
};
|
||||
|
||||
// Character descriptors for Tahoma 16pt
|
||||
// { [Char width in bits], [Char height in bits], [Offset into tahoma_16ptCharBitmaps in bytes] }
|
||||
const FONT_CHAR_INFO tahoma_16ptDescriptors[] PROGMEM =
|
||||
{
|
||||
{4, 16, 0}, // '.'
|
||||
{0, 0, 0}, // '/'
|
||||
{11, 16, 8}, // '0'
|
||||
{10, 16, 30}, // '1'
|
||||
{11, 16, 50}, // '2'
|
||||
{11, 16, 72}, // '3'
|
||||
{12, 16, 94}, // '4'
|
||||
{11, 16, 118}, // '5'
|
||||
{11, 16, 140}, // '6'
|
||||
{11, 16, 162}, // '7'
|
||||
{11, 16, 184}, // '8'
|
||||
{11, 16, 206}, // '9'
|
||||
{0, 0, 0}, // ':'
|
||||
{0, 0, 0}, // ';'
|
||||
{0, 0, 0}, // '<'
|
||||
{0, 0, 0}, // '='
|
||||
{0, 0, 0}, // '>'
|
||||
{0, 0, 0}, // '?'
|
||||
{0, 0, 0}, // '@'
|
||||
{0, 0, 0}, // 'A'
|
||||
{0, 0, 0}, // 'B'
|
||||
{12, 16, 244}, // 'C'
|
||||
{0, 0, 0}, // 'D'
|
||||
{0, 0, 0}, // 'E'
|
||||
{0, 0, 0}, // 'F'
|
||||
{0, 0, 0}, // 'G'
|
||||
{0, 0, 0}, // 'H'
|
||||
{0, 0, 0}, // 'I'
|
||||
{0, 0, 0}, // 'J'
|
||||
{0, 0, 0}, // 'K'
|
||||
{0, 0, 0}, // 'L'
|
||||
{0, 0, 0}, // 'M'
|
||||
{0, 0, 0}, // 'N'
|
||||
{0, 0, 0}, // 'O'
|
||||
{0, 0, 0}, // 'P'
|
||||
{0, 0, 0}, // 'Q'
|
||||
{0, 0, 0}, // 'R'
|
||||
{0, 0, 0}, // 'S'
|
||||
{0, 0, 0}, // 'T'
|
||||
{0, 0, 0}, // 'U'
|
||||
{0, 0, 0}, // 'V'
|
||||
{0, 0, 0}, // 'W'
|
||||
{0, 0, 0}, // 'X'
|
||||
{0, 0, 0}, // 'Y'
|
||||
{0, 0, 0}, // 'Z'
|
||||
{0, 0, 0}, // '['
|
||||
{0, 0, 0}, // '\'
|
||||
{0, 0, 0}, // ']'
|
||||
{0, 0, 0}, // '^'
|
||||
{0, 0, 0}, // '_'
|
||||
{8, 16, 228}, // '`' use for degree symbol
|
||||
};
|
||||
|
||||
// Font information for Tahoma 16pt
|
||||
// easier to leave in RAM, not that big anyway
|
||||
const FONT_INFO tahoma_16ptFontInfo =
|
||||
{
|
||||
16, // Character height
|
||||
'.', // Start character
|
||||
'`', // End character
|
||||
2, // Width, in pixels, of space character
|
||||
tahoma_16ptDescriptors, // Character descriptor array
|
||||
tahoma_16ptBitmaps, // Character bitmap array
|
||||
};
|
||||
|
7
Arduino/BTCDieselHeater/Tahoma16.h
Normal file
7
Arduino/BTCDieselHeater/Tahoma16.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "FontTypes.h"
|
||||
|
||||
// Font data for Tahoma 16pt
|
||||
extern const uint8_t tahoma_16ptBitmaps[] PROGMEM; // stored in program flash memory
|
||||
extern const FONT_CHAR_INFO tahoma_16ptDescriptors[] PROGMEM; // stored in program flash memory
|
||||
extern const FONT_INFO tahoma_16ptFontInfo;
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
#include <SPI.h>
|
||||
#include "AdaFruit_SH1106.h"
|
||||
#include "CustomFont.h"
|
||||
#include "MiniFont.h"
|
||||
#include "tahoma16.h"
|
||||
#include "protocol.h"
|
||||
#include "display.h"
|
||||
#include "pins.h"
|
||||
|
@ -7,6 +9,9 @@
|
|||
#include "OLEDconsts.h"
|
||||
#include "BTCWifi.h"
|
||||
|
||||
#define MAXIFONT tahoma_16ptFontInfo
|
||||
#define MINIFONT miniFontInfo
|
||||
|
||||
#define X_FANICON 55
|
||||
#define Y_FANICON 39
|
||||
#define X_FUELICON 81
|
||||
|
@ -47,7 +52,8 @@
|
|||
|
||||
// 128 x 64 OLED support
|
||||
SPIClass SPI; // default constructor opens HSPI on standard pins : MOSI=13,CLK=14,MISO=12(unused)
|
||||
Adafruit_SH1106 display(OLED_DC_pin, -1, OLED_CS_pin);
|
||||
//Adafruit_SH1106 display(OLED_DC_pin, -1, OLED_CS_pin);
|
||||
CCustomFont display(OLED_DC_pin, -1, OLED_CS_pin);
|
||||
|
||||
bool animatePump = false;
|
||||
bool animateRPM = false;
|
||||
|
@ -66,7 +72,6 @@ void showGlowPlug(int power);
|
|||
void showFan(int RPM);
|
||||
void showFuel(float rate);
|
||||
void showRunState(int state, int errstate);
|
||||
void printMiniNumericString(int xPos, int yPos, const char* str);
|
||||
void printRightJustify(const char* str, int yPos, int RHS=128);
|
||||
|
||||
void initOLED()
|
||||
|
@ -105,7 +110,10 @@ void updateOLED(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
|||
if(isWifiConnected()) {
|
||||
showWifiIcon();
|
||||
display.fillRect(X_WIFIICON + 8, Y_WIFIICON + 5, 10, 7, BLACK);
|
||||
printMiniNumericString(X_WIFIICON + 9, Y_WIFIICON + 6, "AP");
|
||||
display.setFontInfo(&MINIFONT); // select Mini Font
|
||||
display.setCursor(X_WIFIICON+9, Y_WIFIICON+6);
|
||||
display.print("AP");
|
||||
display.setFontInfo(NULL);
|
||||
}
|
||||
|
||||
float voltage = HtrFrame.getVoltage_Supply() * 0.1f;
|
||||
|
@ -135,6 +143,14 @@ void updateOLED(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
|||
|
||||
showRunState(runstate, errstate);
|
||||
|
||||
#ifdef DEMO_LARGEFONT
|
||||
display.fillRect(20,20, 80,16, BLACK);
|
||||
display.setCursor(20,20);
|
||||
display.setFontInfo(&MAXIFONT); // Dot Factory Font
|
||||
display.print("25.6`");
|
||||
display.setFontInfo(NULL); // standard 5x7 font
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -193,7 +209,10 @@ void showThermometer(float desired, float actual)
|
|||
// print actual temperature
|
||||
#ifdef MINI_TEMPLABEL
|
||||
sprintf(msg, "%.1f`C", actual);
|
||||
printMiniNumericString(0, Y_BASELINE, msg);
|
||||
display.setCursor(0, Y_BASELINE);
|
||||
display.setFontInfo(&MINIFONT); // select Mini Font
|
||||
display.print(msg);
|
||||
display.setFontInfo(NULL);
|
||||
#else
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0, Y_BASELINE);
|
||||
|
@ -214,7 +233,10 @@ void showThermometer(float desired, float actual)
|
|||
}
|
||||
#ifdef MINI_TARGETLABEL
|
||||
int xPos = X_TARGETICON + 7 - strlen(msg) * 2; // 2 = 1/2 width mini font
|
||||
printMiniNumericString(xPos, Y_BASELINE, msg);
|
||||
display.setCursor(xPos, Y_BASELINE);
|
||||
display.setFontInfo(&MINIFONT); // select Mini Font
|
||||
display.print(msg);
|
||||
display.setFontInfo(NULL);
|
||||
#else
|
||||
int xPos = X_TARGETICON + 6 - strlen(msg) * 3; // 3 = 1/2 width normal font
|
||||
display.setCursor(xPos, Y_BASELINE);
|
||||
|
@ -239,7 +261,10 @@ void showBodyThermometer(int actual)
|
|||
#ifdef MINI_BODYLABEL
|
||||
sprintf(label, "%d`C", actual);
|
||||
int width = strlen(label) * 4;
|
||||
printMiniNumericString(127-width, Y_BASELINE, label);
|
||||
display.setCursor(125-width, Y_BASELINE);
|
||||
display.setFontInfo(&MINIFONT); // select Mini Font
|
||||
display.print(label);
|
||||
display.setFontInfo(NULL);
|
||||
#else
|
||||
sprintf(label, "%d", actual);
|
||||
int width = strlen(label) * 6;
|
||||
|
@ -265,7 +290,10 @@ void showBatteryIcon(float voltage)
|
|||
char msg[16];
|
||||
sprintf(msg, "%.1fV", voltage);
|
||||
int xPos = X_BATTICON + 7 - strlen(msg) * 2;
|
||||
printMiniNumericString(xPos, Y_BATTICON+12, msg);
|
||||
display.setCursor(xPos, Y_BATTICON+12);
|
||||
display.setFontInfo(&MINIFONT); // select Mini Font
|
||||
display.print(msg);
|
||||
display.setFontInfo(NULL);
|
||||
#else
|
||||
display.setCursor(85, 12);
|
||||
display.setTextColor(WHITE);
|
||||
|
@ -290,7 +318,10 @@ void showGlowPlug(int power)
|
|||
char msg[16];
|
||||
sprintf(msg, "%dW", power);
|
||||
int xPos = X_GLOWICON + 9 - strlen(msg) * 2;
|
||||
printMiniNumericString(xPos, Y_GLOWICON+12, msg);
|
||||
display.setCursor(xPos, Y_GLOWICON+12);
|
||||
display.setFontInfo(&MINIFONT); // select Mini Font
|
||||
display.print(msg);
|
||||
display.setFontInfo(NULL);
|
||||
#else
|
||||
display.setCursor(X_GLOWICON, Y_GLOWICON+12);
|
||||
display.print(power);
|
||||
|
@ -308,7 +339,10 @@ void showFan(int RPM)
|
|||
sprintf(msg, "%d", RPM);
|
||||
#ifdef MINI_FANLABEL
|
||||
int xPos = X_FANICON + 8 - strlen(msg) * 2; // 3 = 1/2 width font
|
||||
printMiniNumericString(xPos, Y_BASELINE, msg);
|
||||
display.setCursor(xPos, Y_BASELINE);
|
||||
display.setFontInfo(&MINIFONT); // select Mini Font
|
||||
display.print(msg);
|
||||
display.setFontInfo(NULL);
|
||||
#else
|
||||
int xPos = X_FANICON + 8 - ( strlen(msg) * 3); // 3 = 1/2 width font
|
||||
display.setCursor(xPos, Y_BASELINE);
|
||||
|
@ -325,7 +359,10 @@ void showFuel(float rate)
|
|||
sprintf(msg, "%.1f", rate);
|
||||
#ifdef MINI_FUELLABEL
|
||||
int xPos = X_FUELICON + 3 - strlen(msg) * 2; // 3 = 1/2 width font
|
||||
printMiniNumericString(xPos, Y_BASELINE, msg);
|
||||
display.setCursor(xPos, Y_BASELINE);
|
||||
display.setFontInfo(&MINIFONT); // select Mini Font
|
||||
display.print(msg);
|
||||
display.setFontInfo(NULL);
|
||||
#else
|
||||
int xPos = X_FUELICON + 3 - ( strlen(msg) * 3); // 3 = 1/2 width font
|
||||
display.setCursor(xPos, Y_BASELINE);
|
||||
|
@ -375,42 +412,6 @@ void showRunState(int runstate, int errstate)
|
|||
}
|
||||
|
||||
|
||||
void printMiniNumericString(int xPos, int yPos, const char* str)
|
||||
{
|
||||
// xPos = display.getCursorX();
|
||||
// yPos = display.getCursorY();
|
||||
const char* pNext = str;
|
||||
while(*pNext) {
|
||||
const uint8_t* pBmp = NULL;
|
||||
switch(*pNext) {
|
||||
case '0': pBmp = Mini0; break;
|
||||
case '1': pBmp = Mini1; break;
|
||||
case '2': pBmp = Mini2; break;
|
||||
case '3': pBmp = Mini3; break;
|
||||
case '4': pBmp = Mini4; break;
|
||||
case '5': pBmp = Mini5; break;
|
||||
case '6': pBmp = Mini6; break;
|
||||
case '7': pBmp = Mini7; break;
|
||||
case '8': pBmp = Mini8; break;
|
||||
case '9': pBmp = Mini9; break;
|
||||
case ' ': pBmp = MiniSpc; break;
|
||||
case '.': pBmp = MiniDP; break;
|
||||
case '`': pBmp = MiniDeg; break;
|
||||
case 'A': pBmp = MiniA; break;
|
||||
case 'C': pBmp = MiniC; break;
|
||||
case 'H': pBmp = MiniH; break;
|
||||
case 'P': pBmp = MiniP; break;
|
||||
case 'V': pBmp = MiniV; break;
|
||||
case 'W': pBmp = MiniW; break;
|
||||
case 'z': pBmp = Miniz; break;
|
||||
}
|
||||
if(pBmp) {
|
||||
display.drawBitmap(xPos, yPos, pBmp, 3, 5, WHITE);
|
||||
}
|
||||
xPos += 4;
|
||||
pNext++;
|
||||
}
|
||||
}
|
||||
|
||||
void printRightJustify(const char* str, int yPos, int RHS)
|
||||
{
|
||||
|
@ -419,9 +420,3 @@ void printRightJustify(const char* str, int yPos, int RHS)
|
|||
display.print(str);
|
||||
}
|
||||
|
||||
void printMiniRightJustify(const char* str, int yPos, int RHS)
|
||||
{
|
||||
int xPos = RHS - strlen(str) * 4;
|
||||
display.setCursor(xPos, yPos);
|
||||
// display.print(str);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue