Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Janis Heims
kraken
Commits
6ec785b8
Commit
6ec785b8
authored
Mar 06, 2022
by
TechnoElf
Browse files
Connect more displays
parent
be5ad753
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main.rs
View file @
6ec785b8
...
@@ -7,7 +7,7 @@ use std::collections::HashMap;
...
@@ -7,7 +7,7 @@ use std::collections::HashMap;
use
std
::
fmt
::
Debug
;
use
std
::
fmt
::
Debug
;
use
std
::
time
::
Duration
;
use
std
::
time
::
Duration
;
use
display_interface_spi
::
SPIInterface
NoCS
;
use
display_interface_spi
::
SPIInterface
;
use
embedded_graphics
::
prelude
::
*
;
use
embedded_graphics
::
prelude
::
*
;
use
embedded_graphics
::
pixelcolor
::
Rgb565
;
use
embedded_graphics
::
pixelcolor
::
Rgb565
;
...
@@ -27,7 +27,7 @@ use rppal::hal::Delay;
...
@@ -27,7 +27,7 @@ use rppal::hal::Delay;
use
rppal
::
spi
::{
Spi
,
Bus
,
SlaveSelect
,
Mode
};
use
rppal
::
spi
::{
Spi
,
Bus
,
SlaveSelect
,
Mode
};
use
rppal
::
gpio
::{
Gpio
,
OutputPin
};
use
rppal
::
gpio
::{
Gpio
,
OutputPin
};
use
st7789
::
ST7789
;
//
use st7789::ST7789;
use
ili9341
::
Ili9341
;
use
ili9341
::
Ili9341
;
const
GATEWAY
:
&
str
=
"192.168.254.1:80"
;
const
GATEWAY
:
&
str
=
"192.168.254.1:80"
;
...
@@ -38,32 +38,39 @@ struct State {
...
@@ -38,32 +38,39 @@ struct State {
}
}
fn
main
()
{
fn
main
()
{
println!
(
"{:?}"
,
http_post
(
GATEWAY
,
"/"
,
""
));
//println!("{:?}", http_post(GATEWAY, "/", ""));
let
spi_bus_0
=
Spi
::
new
(
Bus
::
Spi0
,
SlaveSelect
::
Ss0
,
16000000
,
Mode
::
Mode0
)
.unwrap
();
let
spi_bus_1
:
Spi
=
unsafe
{
mem
::
transmute_copy
(
&
spi_bus_0
)
};
let
spi_bus_2
:
Spi
=
unsafe
{
mem
::
transmute_copy
(
&
spi_bus_0
)
};
let
spi_bus_0
=
Spi
::
new
(
Bus
::
Spi0
,
SlaveSelect
::
Ss0
,
5000000
,
Mode
::
Mode0
)
.unwrap
();
//let spi_bus_1 = Spi::new(Bus::Spi0, SlaveSelect::Ss1, 5000000, Mode::Mode0).unwrap();
let
dc_0
=
Gpio
::
new
()
.unwrap
()
.get
(
12
)
.unwrap
()
.into_output
();
let
dc_0
=
Gpio
::
new
()
.unwrap
()
.get
(
12
)
.unwrap
()
.into_output
();
//let dc_1: OutputPin = unsafe { mem::transmute_copy(&dc_0) };
let
rst_0
=
Gpio
::
new
()
.unwrap
()
.get
(
13
)
.unwrap
()
.into_output
();
let
rst_0
=
Gpio
::
new
()
.unwrap
()
.get
(
13
)
.unwrap
()
.into_output
();
//let rst_1: OutputPin = unsafe { mem::transmute_copy(&rst_0) };
let
dc_1
:
OutputPin
=
unsafe
{
mem
::
transmute_copy
(
&
dc_0
)
};
let
rst_1
:
OutputPin
=
unsafe
{
mem
::
transmute_copy
(
&
rst_0
)
};
let
display_bus_0
=
SPIInterfaceNoCS
::
new
(
spi_bus_0
,
dc_0
);
let
dc_2
:
OutputPin
=
unsafe
{
mem
::
transmute_copy
(
&
dc_0
)
};
//let display_bus_1 = SPIInterfaceNoCS::new(spi_bus_1, dc_1);
let
rst_2
:
OutputPin
=
unsafe
{
mem
::
transmute_copy
(
&
rst_0
)
};
let
cs_disp_0
=
Gpio
::
new
()
.unwrap
()
.get
(
27
)
.unwrap
()
.into_output
();
let
cs_touch_0
=
Gpio
::
new
()
.unwrap
()
.get
(
26
)
.unwrap
()
.into_output
();
let
cs_disp_1
=
Gpio
::
new
()
.unwrap
()
.get
(
25
)
.unwrap
()
.into_output
();
let
cs_touch_1
=
Gpio
::
new
()
.unwrap
()
.get
(
24
)
.unwrap
()
.into_output
();
let
cs_disp_2
=
Gpio
::
new
()
.unwrap
()
.get
(
23
)
.unwrap
()
.into_output
();
let
cs_touch_2
=
Gpio
::
new
()
.unwrap
()
.get
(
22
)
.unwrap
()
.into_output
();
let
display_bus_0
=
SPIInterface
::
new
(
spi_bus_0
,
dc_0
,
cs_disp_0
);
let
display_bus_1
=
SPIInterface
::
new
(
spi_bus_1
,
dc_1
,
cs_disp_1
);
let
display_bus_2
=
SPIInterface
::
new
(
spi_bus_2
,
dc_2
,
cs_disp_2
);
let
mut
display_0
=
Ili9341
::
new
(
display_bus_0
,
rst_0
,
&
mut
Delay
::
new
(),
ili9341
::
Orientation
::
Landscape
,
ili9341
::
DisplaySize240x320
)
.unwrap
();
let
mut
display_0
=
Ili9341
::
new
(
display_bus_0
,
rst_0
,
&
mut
Delay
::
new
(),
ili9341
::
Orientation
::
Landscape
,
ili9341
::
DisplaySize240x320
)
.unwrap
();
//let mut display_1 = ST7789::new(display_bus_1, rst_1, 240, 240);
let
mut
display_1
=
Ili9341
::
new
(
display_bus_1
,
rst_1
,
&
mut
Delay
::
new
(),
ili9341
::
Orientation
::
Landscape
,
ili9341
::
DisplaySize240x320
)
.unwrap
();
let
mut
display_2
=
Ili9341
::
new
(
display_bus_2
,
rst_2
,
&
mut
Delay
::
new
(),
ili9341
::
Orientation
::
Landscape
,
ili9341
::
DisplaySize240x320
)
.unwrap
();
//display_0.init(&mut Delay::new()).unwrap();
//display_1.init(&mut Delay::new()).unwrap();
//display_0.set_orientation(Orientation::Portrait).unwrap();
//display_1.set_orientation(Orientation::Portrait).unwrap();
display_0
.clear
(
Rgb565
::
new
(
255
,
255
,
255
))
.unwrap
();
//display_1.clear(Rgb565::new(255, 255, 255)).unwrap();
let
mut
state
=
State
::
default
();
let
mut
state
=
State
::
default
();
state
.content
.resize
(
4
,
(
String
::
new
(),
(
0
,
0
,
0
)));
state
.content
.resize
(
6
,
(
String
::
new
(),
(
0
,
0
,
0
)));
draw_screen
(
&
mut
display_0
,
&
state
.content
[
0
]
.0
,
&
state
.content
[
0
]
.1
,
&
state
.content
[
1
]
.0
,
&
state
.content
[
1
]
.1
);
draw_screen
(
&
mut
display_0
,
&
state
.content
[
0
]
.0
,
&
state
.content
[
0
]
.1
,
&
state
.content
[
1
]
.0
,
&
state
.content
[
1
]
.1
);
//draw_screen(&mut display_1, &state.content[2].0, &state.content[2].1, &state.content[3].0, &state.content[3].1);
draw_screen
(
&
mut
display_1
,
&
state
.content
[
2
]
.0
,
&
state
.content
[
2
]
.1
,
&
state
.content
[
3
]
.0
,
&
state
.content
[
3
]
.1
);
draw_screen
(
&
mut
display_2
,
&
state
.content
[
4
]
.0
,
&
state
.content
[
4
]
.1
,
&
state
.content
[
5
]
.0
,
&
state
.content
[
5
]
.1
);
eprintln!
(
"Starting server..."
);
eprintln!
(
"Starting server..."
);
...
@@ -86,7 +93,8 @@ fn main() {
...
@@ -86,7 +93,8 @@ fn main() {
stream
.flush
()
.unwrap
();
stream
.flush
()
.unwrap
();
draw_screen
(
&
mut
display_0
,
&
state
.content
[
0
]
.0
,
&
state
.content
[
0
]
.1
,
&
state
.content
[
1
]
.0
,
&
state
.content
[
1
]
.1
);
draw_screen
(
&
mut
display_0
,
&
state
.content
[
0
]
.0
,
&
state
.content
[
0
]
.1
,
&
state
.content
[
1
]
.0
,
&
state
.content
[
1
]
.1
);
//draw_screen(&mut display_1, &state.content[2].0, &state.content[2].1, &state.content[3].0, &state.content[3].1);
draw_screen
(
&
mut
display_1
,
&
state
.content
[
2
]
.0
,
&
state
.content
[
2
]
.1
,
&
state
.content
[
3
]
.0
,
&
state
.content
[
3
]
.1
);
draw_screen
(
&
mut
display_2
,
&
state
.content
[
4
]
.0
,
&
state
.content
[
4
]
.1
,
&
state
.content
[
5
]
.0
,
&
state
.content
[
5
]
.1
);
},
},
Err
(
r
)
=>
{
Err
(
r
)
=>
{
eprintln!
(
"Invalid request: {} {}"
,
method
,
uri
);
eprintln!
(
"Invalid request: {} {}"
,
method
,
uri
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment