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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//! # SSD1315
//!
//! The SSD1315 device driver serves for both SSD1315 and SSD1306. Supports both I2C and SPI interface.
//!
//! ## Usage
//!
//! Here is an example of how to use `ssd1315`:
//!
//! ```rust,ignore
//! use ssd1315::*;
//! use embedded_graphics::{
//! pixelcolor::BinaryColor,
//! prelude::*,
//! primitives::{Circle, PrimitiveStyle},
//! };
//!
//! // let i2c = ...; // Initialize your I2C peripheral here
//! let interface = interface::I2cDisplayInterface::new_interface(i2c);
//! // let interface = interface::SpiDisplayInterface::new_interface(spi, dc);
//!
//! let mut display = Ssd1315::new(interface);
//!
//! Circle::new(Point::new(0, 0), 40)
//! .into_styled(PrimitiveStyle::with_fill(BinaryColor::On))
//! .draw(&mut display)
//! .unwrap();
//!
//! display.init_screen();
//! display.flush_screen();
//! ```
//!
//! Congratulations! Now you can see a small circle displayed on your OLED screen!
//!
//! If you want to apply your own configuration to the SSD1315 (e.g. changing the contrast),
//! follow this example:
//!
//! ```rust,ignore
//! use ssd1315::*;
//! use embedded_graphics::{
//! pixelcolor::BinaryColor,
//! prelude::*,
//! primitives::{Circle, PrimitiveStyle},
//! };
//!
//! // let i2c = ...; // Initialize your I2C peripheral here
//! let interface = interface::I2cDisplayInterface::new_interface(i2c);
//! // let interface = interface::SpiDisplayInterface::new_interface(spi, dc);
//!
//! let mut config = config::Ssd1315DisplayConfig::default();
//! config.contrast = 0xff;
//!
//! let mut display = Ssd1315::new(interface);
//! display.set_custom_config(config);
//!
//! Circle::new(Point::new(0, 0), 40)
//! .into_styled(PrimitiveStyle::with_fill(BinaryColor::On))
//! .draw(&mut display)
//! .unwrap();
//!
//! display.init_screen();
//! display.flush_screen();
//! ```
//!
//! Alternatively, you can use a preset configuration provided by `ssd1315`:
//!
//! ```rust,no_run
//! use ssd1315::config;
//!
//! let config = config::Ssd1315DisplayConfig::preset_config();
//! ```
//!
//! Now you can see the change in contrast!
//!
//! You might also want to draw some raw image(s) manually to fit your specific requirements.
//! No problem! `ssd1315` fits your need! You can draw it/them in an easy way:
//!
//! ```rust,ignore
//! // let interface = ...; // Initialize your I2C or SPI interface here
//! let mut display = Ssd1315::new(interface);
//!
//! let raw_image = [[0b1010_1010; 128]; 8];
//! raw_image.draw_from_raw(&mut display);
//!
//! display.init_screen();
//! display.flush_screen();
//! ```
use ;
use Ssd1315DisplayConfig;
use ;
pub const DISPLAY_WIDTH: usize = 128;
pub const DISPLAY_HEIGHT: usize = 64;
/// A virtual SSD1315 device that holds interface data, a buffer
/// that maps to the actual buffer in the SSD1315 and a configuration.