-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathmain.cpp
More file actions
104 lines (85 loc) · 2.62 KB
/
main.cpp
File metadata and controls
104 lines (85 loc) · 2.62 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright (c) 2010-2011, Fabian Greif
* Copyright (c) 2012-2014, 2016-2018, Niklas Hauser
* Copyright (c) 2014, Sascha Schade
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------
#include <modm/platform.hpp>
#include <modm/driver/display/ea_dog.hpp>
#include <modm/ui/display/font.hpp>
#include <modm/architecture/interface/clock.hpp>
using namespace modm::platform;
using namespace modm::literals;
using namespace std::chrono_literals;
// LCD Backlight
namespace led
{
typedef GpioOutputD7 R;
typedef GpioOutputD6 G;
typedef GpioOutputD5 B;
}
// define the pins used by the LCD
namespace lcd
{
typedef GpioOutputB7 Scl;
typedef GpioInputB6 Miso;
typedef GpioOutputB5 Mosi;
typedef GpioOutputD2 Cs;
typedef GpioOutputD3 A0;
typedef GpioOutputD4 Reset;
}
typedef BitBangSpiMaster< lcd::Scl, lcd::Mosi, lcd::Miso > SPI;
modm::DogM128< SPI, lcd::Cs, lcd::A0, lcd::Reset, true > display;
int
main()
{
// Enable a yellow backlight
led::R::set();
led::G::set();
led::B::reset();
led::R::setOutput();
led::G::setOutput();
led::B::setOutput();
SPI::connect< lcd::Scl::BitBang, lcd::Mosi::BitBang, lcd::Miso::BitBang >();
SPI::initialize<SystemClock, 2_MHz>();
display.initialize();
display.setFont(modm::font::ScriptoNarrow);
display.setCursor(modm::glcd::Point(0, 0));
display << "Hello World!\n";
display << "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
display << "abcdefghijklmnopqrstuvwxyz\n";
display << "0123456789!\"§$%&/()=?`´,;:-<>";
display.setFont(modm::font::AllCaps3x5);
display.setCursor(modm::glcd::Point(0, 32));
display << "Hello World!" << modm::endl;
display << "ABCDEFGHIJKLMNOPQRSTUVWXYZ" << modm::endl;
display << "abcdefghijklmnopqrstuvwxyz" << modm::endl;
display << 0 << 12 << 345 << 6789 << "!\"§$%&/()=?`´,;:-<>";
display.update();
modm::delay(2s);
display.clear();
display.setFont(modm::font::Assertion);
display.setCursor(modm::glcd::Point(0, 0));
display << "Hello World!\n";
display << "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
display << "abcdefghijklmnopqrstuvwxyz\n";
display << "0123456789!\"§$%&/()=?`´,;:-<>";
display.update();
modm::delay(2s);
display.clear();
display.setFont(modm::font::ArcadeClassic);
display.setCursor(modm::glcd::Point(0, 0));
display << "Hello World!\n\n";
display << "ABCDEFGHIJKLMNOP\nQRSTUVWXYZ\n";
display << "0123456789!\"§$%&/\n()=?`´,;:-<>";
display.update();
while (true)
{
}
}