File tree 3 files changed +21
-5
lines changed
3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 12
12
0b00000001 ,
13
13
]
14
14
15
+ sys .stdout .buffer .write (b'.q.c.s' )
15
16
while True :
16
17
for pattern in patterns :
17
18
#sys.stdout.buffer.write(b'.c')
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const HELP_MESSAGE: &str = "
21
21
.s - strobe active row\r
22
22
.c - clear active row\r
23
23
.i - toggle instant strobe\r
24
+ .q - set quiet (high speed) mode\r
24
25
\r
25
26
anything else will be interpreted as data to active row\r
26
27
use '..' to enter a literal '.'-byte as data\r
@@ -80,6 +81,7 @@ fn main() -> ! {
80
81
const CLEAR : u8 = 'c' as u8 ;
81
82
const HELP : u8 = 'h' as u8 ;
82
83
const INSTANT : u8 = 'i' as u8 ;
84
+ const QUIET : u8 = 'q' as u8 ;
83
85
84
86
let mut command_mode = false ;
85
87
let mut active_row = Row0 ;
@@ -139,6 +141,10 @@ fn main() -> ! {
139
141
}
140
142
command_mode = false ;
141
143
} ,
144
+ ( true , QUIET , _) => {
145
+ usb_serial. set_quiet ( true ) ;
146
+ command_mode = false ;
147
+ } ,
142
148
( true , _, _) => {
143
149
usb_serial. write_str ( "Invalid command character\r \n " ) ;
144
150
command_mode = false ;
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ impl UsbBus {
48
48
pub struct UsbSerial < ' a > {
49
49
dev : UsbDevice < ' a , usb:: UsbBus < usb:: Peripheral > > ,
50
50
serial : SerialPort < ' a , usb:: UsbBus < usb:: Peripheral > > ,
51
+ quiet_mode : bool ,
51
52
}
52
53
53
54
impl < ' a > UsbSerial < ' a > {
@@ -67,6 +68,7 @@ impl<'a> UsbSerial<'a> {
67
68
UsbSerial {
68
69
dev : usb_dev,
69
70
serial : usb_serial,
71
+ quiet_mode : false ,
70
72
}
71
73
}
72
74
@@ -80,13 +82,16 @@ impl<'a> UsbSerial<'a> {
80
82
}
81
83
82
84
pub fn write ( & mut self , buf : & [ u8 ] ) -> usize {
83
- loop {
84
- let result = self . serial . write ( buf) ;
85
- if let Ok ( count) = result {
86
- return count;
85
+ if self . quiet_mode {
86
+ return buf. len ( ) ;
87
+ } else {
88
+ loop {
89
+ let result = self . serial . write ( buf) ;
90
+ if let Ok ( count) = result {
91
+ return count;
92
+ }
87
93
}
88
94
}
89
-
90
95
}
91
96
92
97
pub fn write_str ( & mut self , message : & str ) -> usize {
@@ -108,5 +113,9 @@ impl<'a> UsbSerial<'a> {
108
113
return bytes_written
109
114
110
115
}
116
+
117
+ pub fn set_quiet ( & mut self , quiet_mode : bool ) {
118
+ self . quiet_mode = quiet_mode;
119
+ }
111
120
}
112
121
You can’t perform that action at this time.
0 commit comments