1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <pololu/orangutan.h>
#include <string.h>
/*
* 3pi-serial-master - An example serial master program for the Pololu
* 3pi Robot.
This can run on any board supported by the library;
* it is intended as an example of how to use the master/slave
* routines.
*
*
http://www.pololu.com/docs/0J21
*
http://www.pololu.com/docs/0J20
*
*/
// Data for generating the characters used in load_custom_characters
// and display_readings.
By reading levels[] starting at various
// offsets, we can generate all of the 7 extra characters needed for a
// bargraph.
This is also stored in program space.
const
char
levels[] PROGMEM = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
// This function loads custom characters into the LCD.
Up to 8
// characters can be loaded; we use them for 6 levels of a bar graph
// plus a back arrow and a musical note character.
void
load_custom_characters()
{
lcd_load_custom_character(0,0);
// no offset, e.g. one bar
lcd_load_custom_character(1,1);
// two bars
lcd_load_custom_character(2,2);
// etc...
lcd_load_custom_character(4,3);
// skip level 3
lcd_load_custom_character(5,4);
lcd_load_custom_character(6,5);
clear();
// the LCD must be cleared for the characters to take effect
}
// 10 levels of bar graph characters
const
char
bar_graph_characters[10] = {
' '
,0,0,1,2,3,3,4,5,255};
void
display_levels(unsigned
int
*sensors)
{
clear();
int
i;
for
(i=0;i<5;i++) {
// Initialize the array of characters that we will use for the
// graph.
Using the space, an extra copy of the one-bar
// character, and character 255 (a full black box), we get 10
// characters in the array.
Pololu 3pi Robot User’s Guide
© 2001–2019 Pololu Corporation
10. Expansion Information
Page 78 of 85
Содержание 0J5840
Страница 24: ...Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 5 How Your 3pi Works Page 24 of 85...
Страница 67: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 67 of 85...
Страница 77: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 77 of 85...