Next, we output the current temperature as text. We use TVout s
set_cursor
, and
print
that is 6 pixels wide and 8 pixels high. After that, we output the current
temperature in degrees Celsius using the 8x8 font. The TVout library doesn t
define a symbol for degrees Celsius, so we use the
21 to draw a small circle to simulate a degrees symbol.
We re done! That s all the code we need to make the TV thermometer work.
The only thing I haven t explained in detail is how outputting the thermometer
image works. You ll learn more about that in the next section.
Working with Graphics in TVout
In
TvThermometer.ino
it contains. Here s how it looks:
Video/TvThermometer/thermometer.h
#ifndef THERMOMETER_H
#define THERMOMETER_H
extern const unsigned char
#endif
Quite disappointing, isn t it? The file declares only a single variable named
. This variable is an array of unsigned character values, and the
thermometer
extern
keyword tells the compiler that we only want to declare the variable.
That is, we can refer to it in our program, but we still have to define it to
allocate some memory.
We actually define the
few lines for brevity):
Video/TvThermometer/thermometer.cpp
#include <Arduino.h>
Line 1
#include <avr/pgmspace.h>
-
#include "thermometer.h"
-
PROGMEM
const unsigned char
-
20, 94,
5
B00000000, B11110000, B00000000,
-
B00000001, B00001000, B00000000,
-
B00000010, B00000100, B00000000,
-
B00000010, B00000100, B00000000,
-
B00000010, B00000100, B00000000,
10
B00000010, B00000111, B10000000,
-
B00000010, B00000100, B00000000,
-
B00000010, B00000100, B00000000,
-
B00000010, B00000100, B00000000,
-
B00000010, B00000100, B00000000,
15
B00000010, B00000100, B00000000,
-
methods to output the text "Current Temperature" in a font
we ve included the
thermometer.h
thermometer[];
thermometer
variable in
thermometer[] = {
// 40.0
www.it-ebooks.info
Working with Graphics in TVout
select_font
draw_circle
method in line
file without explaining what
thermometer.cpp
(we ve skipped a
139
,
report erratum
discuss
Need help?
Do you have a question about the Arduino Uno and is the answer not in the manual?