PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Display
libsimplegfx
loadSetFonts.c
1
/*
2
* @file loadSetFonts.c
3
*
4
* @author Matthew Matz
5
*
6
* @version 0.5
7
*
8
* @copyright Copyright (C) Parallax, Inc. 2019. See end of file for
9
* terms of use (MIT License).
10
*
11
* @brief This is a driver that allows the Propeller Multicore Microcontroller to
12
* draw text, shapes, and bitmap files on various screens and displays.
13
*
14
* @detail This helper-library allows the Propeller Multicore Microcontroller to
15
* draw pixels, lines, circles, recatngles, rounded rectagles, triangles, formatted text
16
* in multiple fonts, bitmap images stored on an SD card on various screens and displays.
17
* At Parallax, we would like to thank Adafruit Industries as parts of this library
18
* were dervied from the Adafruit GFX library for Arduino. Please submit bug reports,
19
* suggestions, and improvements to this code to editor@parallax.com.
20
*
21
* @note If fonts are installed, they occupy EEPROM addresses 40576 to 63359.
22
*/
23
24
#include "simplegfx.h"
25
26
27
void
loadFonts(
screen_t
*dev,
i2c
*eeBus) {
28
dev->
eepromBus
= eeBus;
29
30
//check if fonts are installed in EEPROM, and set the default font if they are
31
dev->
font
[0] = 0;
32
char
testStr[] = {0,0,0,0,0,0};
33
i2c_in
(dev->
eepromBus
, 0b1010000, 43640, 2, testStr, 6);
34
if
(testStr[0] ==
'f'
&&
35
testStr[1] ==
'o'
&&
36
testStr[2] ==
'n'
&&
37
testStr[3] ==
't'
&&
38
testStr[4] ==
's'
&&
39
testStr[5] ==
'!'
) {
40
41
// Set a default font by setting EEPROM addresses
42
dev->
font
[0] = 1;
43
setTextFont(dev, 0);
44
}
45
}
46
47
void
setTextFont(
screen_t
*dev,
char
f) {
48
49
if
( f == 3 )
// Bubble
50
{
51
dev->
font
[1] = 44544;
52
dev->
font
[2] = 44416;
53
dev->
font
[3] = 43648;
54
dev->
font
[4] = 40576;
55
}
56
else
if
( f == 2 )
// Serif
57
{
58
dev->
font
[1] = 50048;
59
dev->
font
[2] = 49920;
60
dev->
font
[3] = 49152;
61
dev->
font
[4] = 46720;
62
}
63
else
if
( f == 1 )
// Script
64
{
65
dev->
font
[1] = 55552;
66
dev->
font
[2] = 55424;
67
dev->
font
[3] = 54656;
68
dev->
font
[4] = 52224;
69
}
70
else
// Sans
71
{
72
dev->
font
[1] = 61184;
73
dev->
font
[2] = 61056;
74
dev->
font
[3] = 60288;
75
dev->
font
[4] = 57728;
76
}
77
}
78
79
screen_st::font
int font[5]
Definition:
simplegfx.h:128
i2c_in
HUBTEXT int i2c_in(i2c *busID, int i2cAddr, int memAddr, int memAddrCount, unsigned char *data, int dataCount)
Receive data from device using I2C protocol.
Definition:
i2c_in.c:20
i2c_st
Definition:
simplei2c.h:25
screen_st::eepromBus
i2c * eepromBus
Definition:
simplegfx.h:150
screen_st
Definition:
simplegfx.h:111
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17