Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dashboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
egorguslyan
Dashboard
Commits
a7dbf3c3
Commit
a7dbf3c3
authored
3 years ago
by
egorguslyan
Browse files
Options
Downloads
Patches
Plain Diff
English font + first text boxes (3h 52m)
parent
c1a3a80d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Dashboard/Dashboard.ino
+13
-3
13 additions, 3 deletions
Dashboard/Dashboard.ino
Dashboard/font.h
+84
-0
84 additions, 0 deletions
Dashboard/font.h
Dashboard/textbox.h
+155
-0
155 additions, 0 deletions
Dashboard/textbox.h
with
252 additions
and
3 deletions
Dashboard/Dashboard.ino
+
13
−
3
View file @
a7dbf3c3
...
...
@@ -27,6 +27,8 @@
#include
<MHZ19_uart.h>
/********************************/
#include
"font.h"
#define LEDsPin 2
#define CO2RX A0
#define CO2TX A1
...
...
@@ -36,15 +38,18 @@
#define WIDTH 16
#define HEIGHT 9
#define numLeds (WIDTH * HEIGHT)
#define COLOR mHEX(0x9aa100)
microLED
<
numLeds
,
LEDsPin
,
MLED_NO_CLOCK
,
LED_WS2812
,
ORDER_GRB
,
CLI_AVER
/*, SAVE_MILLIS*/
>
matrix
(
WIDTH
,
HEIGHT
,
ZIGZAG
,
RIGHT_TOP
,
DIR_LEFT
);
#include
"textbox.h"
textbox
tb
;
MHZ19_uart
co2
;
void
setup
()
{
Serial
.
begin
(
9600
);
while
(
!
Serial
.
available
())
{}
//
Serial.println("Hello");
Serial
.
println
(
"Hello"
);
matrix
.
setBrightness
(
100
);
matrix
.
clear
();
matrix
.
show
();
...
...
@@ -52,11 +57,16 @@ void setup()
co2
.
begin
(
CO2TX
,
CO2RX
);
co2
.
setAutoCalibration
(
false
);
delay
(
500
);
tb
.
setup
(
"Hello"
,
TB_STATIC
,
0
,
0
,
16
);
tb
.
render
();
}
void
loop
()
{
matrix
.
clear
();
for
(
uint8_t
i
=
0
;
i
<
9
;
i
++
)
{
matrix
.
set
(
matrix
.
getPixNumber
(
15
,
i
),
mHEX
(
0
));
}
uint16_t
CO2
=
co2
.
getPPM
();
Serial
.
print
(
CO2
);
Serial
.
print
(
" "
);
...
...
@@ -67,7 +77,7 @@ void loop()
CO2
=
map
(
CO2
,
300
,
1500
,
0
,
9
);
for
(
uint8_t
i
=
0
;
i
<
CO2
;
i
++
)
{
matrix
.
set
(
matrix
.
getPixNumber
(
1
,
i
),
mHEX
(
0x
9
aa100
));
matrix
.
set
(
matrix
.
getPixNumber
(
1
5
,
i
),
mHEX
(
0x
0
aa100
));
}
//matrix.fill(mHEX(0x9aa100));
matrix
.
show
();
...
...
This diff is collapsed.
Click to expand it.
Dashboard/font.h
0 → 100644
+
84
−
0
View file @
a7dbf3c3
#pragma once
#define cords(width, offset, bytes) offset + bytes * 7 + (width - 1) * 49
// Example char
// const uint8_t char[] PROGMEM = {cords(x, y, b), 0b11111110, 0b11110111, 0b01011101, 0b11101111, 0b11100000};
const
uint8_t
font_space
[]
PROGMEM
=
{
cords
(
1
,
6
,
1
),
0
b00000000
};
const
uint8_t
font_notdef
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b11111110
,
0
b11110111
,
0
b01011101
,
0
b11101111
,
0
b11100000
};
const
uint8_t
font_dot
[]
PROGMEM
=
{
cords
(
2
,
4
,
1
),
0
b11011000
};
const
uint8_t
font_comma
[]
PROGMEM
=
{
cords
(
2
,
4
,
1
),
0
b11011001
};
const
uint8_t
font_exclamation
[]
PROGMEM
=
{
cords
(
1
,
0
,
1
),
0
b11110100
};
const
uint8_t
font_question
[]
PROGMEM
=
{
cords
(
3
,
0
,
3
),
0
b01010100
,
0
b10100100
,
0
b00010000
};
// Numbers
const
uint8_t
font_num0
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b01110100
,
0
b11101011
,
0
b01011010
,
0
b11100101
,
0
b11000000
};
const
uint8_t
font_num1
[]
PROGMEM
=
{
cords
(
3
,
0
,
3
),
0
b01011001
,
0
b00100100
,
0
b10111000
};
const
uint8_t
font_num2
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b01101001
,
0
b00010010
,
0
b01001000
,
0
b11110000
};
const
uint8_t
font_num3
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b01101001
,
0
b00010110
,
0
b00011001
,
0
b01100000
};
const
uint8_t
font_num4
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b00110010
,
0
b10010101
,
0
b00101111
,
0
b10001000
,
0
b01000000
};
const
uint8_t
font_num5
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b11111000
,
0
b10001110
,
0
b00011001
,
0
b01100000
};
const
uint8_t
font_num6
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b00110100
,
0
b10001110
,
0
b10011001
,
0
b01100000
};
const
uint8_t
font_num7
[]
PROGMEM
=
{
cords
(
3
,
0
,
3
),
0
b11100100
,
0
b10010100
,
0
b10010000
};
const
uint8_t
font_num8
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b01101001
,
0
b10010110
,
0
b10011001
,
0
b01100000
};
const
uint8_t
font_num9
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b01101001
,
0
b10010111
,
0
b00010001
,
0
b01100000
};
// English
const
uint8_t
font_A
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b01101101
,
0
b11000110
,
0
b00111111
,
0
b10001100
,
0
b01000000
};
const
uint8_t
font_B
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b11100100
,
0
b10100101
,
0
b11101000
,
0
b11000111
,
0
b11000000
};
const
uint8_t
font_C
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b01110100
,
0
b01100001
,
0
b00001000
,
0
b01000101
,
0
b11000000
};
const
uint8_t
font_D
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b11100100
,
0
b10100011
,
0
b00011000
,
0
b11001011
,
0
b10000000
};
const
uint8_t
font_E
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b11111000
,
0
b10001111
,
0
b10001000
,
0
b11110000
};
const
uint8_t
font_F
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b11111000
,
0
b10001111
,
0
b10001000
,
0
b10000000
};
const
uint8_t
font_G
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b01110100
,
0
b01100001
,
0
b00001001
,
0
b11000101
,
0
b11000000
};
const
uint8_t
font_H
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b10011001
,
0
b10011111
,
0
b10011001
,
0
b10010000
};
const
uint8_t
font_I
[]
PROGMEM
=
{
cords
(
1
,
0
,
1
),
0
b11111110
};
const
uint8_t
font_J
[]
PROGMEM
=
{
cords
(
3
,
0
,
3
),
0
b00100100
,
0
b10010011
,
0
b01010000
};
const
uint8_t
font_K
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b10011010
,
0
b10101100
,
0
b10101010
,
0
b10010000
};
const
uint8_t
font_L
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b10001000
,
0
b10001000
,
0
b10001000
,
0
b11110000
};
const
uint8_t
font_M
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b10001110
,
0
b11101011
,
0
b01011000
,
0
b11000110
,
0
b00100000
};
const
uint8_t
font_N
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b10001110
,
0
b01101011
,
0
b01011010
,
0
b11001110
,
0
b00100000
};
const
uint8_t
font_O
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b01101001
,
0
b10011001
,
0
b10011001
,
0
b01100000
};
const
uint8_t
font_P
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b11101001
,
0
b10011110
,
0
b10001000
,
0
b10000000
};
const
uint8_t
font_Q
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b01100100
,
0
b10100101
,
0
b00101001
,
0
b01011001
,
0
b10100000
};
const
uint8_t
font_R
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b11101001
,
0
b10011110
,
0
b11001010
,
0
b10010000
};
const
uint8_t
font_S
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b01101000
,
0
b10000110
,
0
b00010001
,
0
b01100000
};
const
uint8_t
font_T
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b11111001
,
0
b00001000
,
0
b01000010
,
0
b00010000
,
0
b10000000
};
const
uint8_t
font_U
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b10011001
,
0
b10011001
,
0
b10011001
,
0
b01100000
};
const
uint8_t
font_V
[]
PROGMEM
=
{
cords
(
3
,
0
,
3
),
0
b10110110
,
0
b11011011
,
0
b01010000
};
const
uint8_t
font_W
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b10001100
,
0
b01101011
,
0
b01011010
,
0
b11010101
,
0
b01000000
};
const
uint8_t
font_X
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b10001010
,
0
b10010100
,
0
b01000101
,
0
b00101010
,
0
b00100000
};
const
uint8_t
font_Y
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b10001010
,
0
b10010100
,
0
b01000010
,
0
b00010000
,
0
b10000000
};
const
uint8_t
font_Z
[]
PROGMEM
=
{
cords
(
5
,
0
,
5
),
0
b11111000
,
0
b01000100
,
0
b01000100
,
0
b01000011
,
0
b11100000
};
const
uint8_t
font_a
[]
PROGMEM
=
{
cords
(
5
,
2
,
3
),
0
b01100001
,
0
b01111001
,
0
b01100000
};
const
uint8_t
font_b
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b10001000
,
0
b10001110
,
0
b10011001
,
0
b11100000
};
const
uint8_t
font_c
[]
PROGMEM
=
{
cords
(
3
,
2
,
2
),
0
b01110010
,
0
b01000110
};
const
uint8_t
font_d
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b00010001
,
0
b00010111
,
0
b10011001
,
0
b01110000
};
const
uint8_t
font_e
[]
PROGMEM
=
{
cords
(
4
,
2
,
3
),
0
b01101001
,
0
b11101000
,
0
b01100000
};
const
uint8_t
font_f
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b00100101
,
0
b01000100
,
0
b11100100
,
0
b01000000
};
const
uint8_t
font_g
[]
PROGMEM
=
{
cords
(
4
,
2
,
3
),
0
b01111001
,
0
b01110001
,
0
b01100000
};
const
uint8_t
font_h
[]
PROGMEM
=
{
cords
(
3
,
0
,
3
),
0
b10010010
,
0
b01101011
,
0
b01101000
};
const
uint8_t
font_i
[]
PROGMEM
=
{
cords
(
1
,
2
,
1
),
0
b10111000
};
const
uint8_t
font_j
[]
PROGMEM
=
{
cords
(
3
,
2
,
2
),
0
b00100000
,
0
b11010100
};
const
uint8_t
font_k
[]
PROGMEM
=
{
cords
(
3
,
0
,
3
),
0
b10010010
,
0
b01011101
,
0
b01101000
};
const
uint8_t
font_l
[]
PROGMEM
=
{
cords
(
2
,
0
,
2
),
0
b10101010
,
0
b10100100
};
const
uint8_t
font_m
[]
PROGMEM
=
{
cords
(
5
,
2
,
4
),
0
b11110101
,
0
b01101011
,
0
b01011010
,
0
b10000000
};
const
uint8_t
font_n
[]
PROGMEM
=
{
cords
(
4
,
2
,
3
),
0
b11101001
,
0
b10011001
,
0
b10010000
};
const
uint8_t
font_o
[]
PROGMEM
=
{
cords
(
4
,
2
,
3
),
0
b01101001
,
0
b10011001
,
0
b01100000
};
const
uint8_t
font_p
[]
PROGMEM
=
{
cords
(
4
,
2
,
3
),
0
b11101001
,
0
b11101000
,
0
b10000000
};
const
uint8_t
font_q
[]
PROGMEM
=
{
cords
(
4
,
2
,
3
),
0
b01111001
,
0
b01110001
,
0
b00010000
};
const
uint8_t
font_r
[]
PROGMEM
=
{
cords
(
4
,
2
,
3
),
0
b10101101
,
0
b10001000
,
0
b10000000
};
const
uint8_t
font_s
[]
PROGMEM
=
{
cords
(
4
,
2
,
3
),
0
b01101000
,
0
b01100001
,
0
b01100000
};
const
uint8_t
font_t
[]
PROGMEM
=
{
cords
(
4
,
0
,
4
),
0
b01000100
,
0
b11100100
,
0
b01000101
,
0
b00100000
};
const
uint8_t
font_u
[]
PROGMEM
=
{
cords
(
4
,
2
,
3
),
0
b10011001
,
0
b10011001
,
0
b01110000
};
const
uint8_t
font_v
[]
PROGMEM
=
{
cords
(
3
,
2
,
2
),
0
b10110110
,
0
b11010100
};
const
uint8_t
font_w
[]
PROGMEM
=
{
cords
(
5
,
2
,
3
),
0
b10001100
,
0
b01101011
,
0
b01010101
};
const
uint8_t
font_x
[]
PROGMEM
=
{
cords
(
3
,
2
,
2
),
0
b10110101
,
0
b01011010
};
const
uint8_t
font_y
[]
PROGMEM
=
{
cords
(
3
,
2
,
2
),
0
b10110101
,
0
b10011100
};
const
uint8_t
font_z
[]
PROGMEM
=
{
cords
(
3
,
2
,
2
),
0
b11100101
,
0
b01001110
};
const
uint8_t
*
const
font
[]
PROGMEM
=
{
font_space
,
font_notdef
,
font_dot
,
font_comma
,
font_exclamation
,
font_question
,
font_num0
,
font_num1
,
font_num2
,
font_num3
,
font_num4
,
font_num5
,
font_num6
,
font_num7
,
font_num8
,
font_num9
,
font_A
,
font_a
,
font_B
,
font_b
,
font_C
,
font_c
,
font_D
,
font_d
,
font_E
,
font_e
,
font_F
,
font_f
,
font_G
,
font_g
,
font_H
,
font_h
,
font_I
,
font_i
,
font_J
,
font_j
,
font_K
,
font_k
,
font_L
,
font_l
,
font_M
,
font_m
,
font_N
,
font_n
,
font_O
,
font_o
,
font_P
,
font_p
,
font_Q
,
font_q
,
font_R
,
font_r
,
font_S
,
font_s
,
font_T
,
font_t
,
font_U
,
font_u
,
font_V
,
font_v
,
font_W
,
font_w
,
font_X
,
font_x
,
font_Y
,
font_y
,
font_Z
,
font_z
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Dashboard/textbox.h
0 → 100644
+
155
−
0
View file @
a7dbf3c3
#pragma once
#define TB_DISABLED 0
#define TB_STATIC 1
#define TB_REPEAT 2
#define TB_LOOP 3
#define TB_LOOP_WITH_DELAY 4
#define TB_BOUNCE 5
class
textbox
{
private:
/* data */
uint8_t
x
;
uint8_t
y
;
uint8_t
w
;
uint8_t
mode
;
uint8_t
speed
;
uint16_t
delay
;
uint16_t
offset
;
char
text
[
64
];
uint8_t
letter
[
8
];
uint64_t
lang
;
void
getLetter
(
char
c
);
public:
textbox
(
void
);
void
setup
(
char
_text
[],
uint8_t
_mode
,
uint8_t
_x
,
uint8_t
_y
,
uint8_t
_w
,
uint8_t
_speed
=
0
,
uint16_t
_delay
=
0
);
void
render
(
void
);
void
disable
(
void
);
};
textbox
::
textbox
(
void
)
{
x
=
0
;
y
=
0
;
w
=
0
;
mode
=
0
;
speed
=
0
;
delay
=
0
;
memset
(
text
,
NULL
,
64
*
sizeof
(
char
));
lang
=
0
;
}
void
textbox
::
setup
(
char
_text
[],
uint8_t
_mode
,
uint8_t
_x
,
uint8_t
_y
,
uint8_t
_w
,
uint8_t
_speed
=
0
,
uint16_t
_delay
=
0
)
{
strcpy
(
text
,
_text
);
mode
=
_mode
;
x
=
_x
;
y
=
_y
;
w
=
_w
;
offset
=
0
;
switch
(
mode
)
{
case
TB_LOOP
:
delay
=
0
;
goto
NO_DELAY
;
case
TB_REPEAT
:
case
TB_LOOP_WITH_DELAY
:
case
TB_BOUNCE
:
delay
=
_delay
;
NO_DELAY:
speed
=
_speed
;
break
;
case
TB_DISABLED
:
case
TB_STATIC
:
default:
speed
=
0
;
delay
=
0
;
break
;
}
render
();
}
void
textbox
::
render
(
void
)
{
if
(
mode
==
TB_DISABLED
)
return
;
uint8_t
index
=
0
;
uint8_t
position
=
0
;
while
(
position
<
16
)
{
getLetter
(
text
[
index
]);
uint8_t
y
=
letter
[
1
];
uint8_t
x
=
0
;
uint8_t
maxX
=
letter
[
0
];
for
(
uint8_t
i
=
0
;
i
<
letter
[
2
];
i
++
)
{
for
(
int8_t
j
=
7
;
j
>=
0
;
j
--
)
{
//char sprf[25];
uint8_t
state
=
bitRead
(
letter
[
i
+
3
],
j
);
//sprintf(sprf, "%d %d %d %d %d %d %d\n", index, letter[0], letter[1], letter[2], i, j, state);
//Serial.print(sprf);
matrix
.
set
(
matrix
.
getPixNumber
(
x
+
position
,
y
),
mHSVfast
((
index
+
1
)
*
10
,
255
,
255
));
x
++
;
if
(
x
>=
maxX
)
{
x
=
0
;
y
++
;
}
if
(
y
>
6
)
goto
BREAKFORS
;
}
}
BREAKFORS
:
position
+=
maxX
;
index
++
;
}
}
void
textbox
::
disable
(
void
)
{
setup
(
""
,
TB_DISABLED
,
0
,
0
,
0
);
}
void
textbox
::
getLetter
(
char
c
)
{
memset
(
letter
,
0
,
8
*
sizeof
(
uint8_t
));
uint8_t
index
;
uint8_t
ctoi
=
(
uint8_t
)
c
;
if
(
ctoi
>=
65
&&
ctoi
<=
90
)
index
=
16
+
2
*
(
ctoi
-
65
);
else
if
(
ctoi
>=
97
&&
ctoi
<=
122
)
index
=
17
+
2
*
(
ctoi
-
97
);
else
if
(
ctoi
>=
48
&&
ctoi
<=
57
)
index
=
ctoi
-
42
;
else
switch
(
ctoi
)
{
case
32
:
index
=
0
;
break
;
case
46
:
index
=
2
;
break
;
case
44
:
index
=
3
;
break
;
case
33
:
index
=
4
;
break
;
case
63
:
index
=
5
;
break
;
default:
index
=
1
;
break
;
}
Serial
.
println
(
index
);
uint8_t
readed
=
pgm_read_byte
(
font
[
index
][
0
]);
Serial
.
println
(
readed
);
letter
[
0
]
=
readed
/
49
+
1
;
// width
letter
[
1
]
=
readed
%
7
;
// offset
letter
[
2
]
=
readed
/
7
%
7
;
// bytes
for
(
uint8_t
i
=
0
;
i
<
letter
[
2
];
i
++
)
{
letter
[
i
+
3
]
=
pgm_read_byte
(
font
[
index
][
i
+
1
]);
Serial
.
println
(
letter
[
i
+
3
]);
}
Serial
.
println
();
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment