1
1
// const INTERVAL: u16 = 100u16; // Controls the speed of morse code generation
2
2
3
- mod morse_queues {
3
+ pub mod morse_queues {
4
4
const CHAR_QUEUE_LENTGH : usize = 1024 ;
5
5
const STATE_QUEUE_LENGTH : usize = 32 ;
6
6
7
- struct CharQueue {
7
+ pub struct CharQueue {
8
8
queue : [ char ; CHAR_QUEUE_LENTGH ] ,
9
9
length : usize ,
10
10
write_position : usize ,
11
11
read_position : usize ,
12
12
}
13
13
14
- struct PinControlQueue {
14
+ pub struct PinControlQueue {
15
15
queue : [ PinControlDescriptor ; STATE_QUEUE_LENGTH ] ,
16
16
length : usize ,
17
17
write_position : usize ,
@@ -161,12 +161,12 @@ mod morse_queues {
161
161
read_position : 0 ,
162
162
} ;
163
163
164
- struct PinControlDescriptor {
164
+ pub struct PinControlDescriptor {
165
165
pin_state : bool ,
166
166
duration : u8 ,
167
167
}
168
168
169
- fn push_dot ( ) {
169
+ pub fn push_dot ( ) {
170
170
let dot = PinControlDescriptor {
171
171
pin_state : true ,
172
172
duration : 1 ,
@@ -179,7 +179,7 @@ mod morse_queues {
179
179
push_state ( interval) ;
180
180
}
181
181
182
- fn push_dash ( ) {
182
+ pub fn push_dash ( ) {
183
183
let dash = PinControlDescriptor {
184
184
pin_state : true ,
185
185
duration : 3 ,
@@ -192,15 +192,15 @@ mod morse_queues {
192
192
push_state ( interval) ;
193
193
}
194
194
195
- fn push_space ( ) {
195
+ pub fn push_space ( ) {
196
196
let space = PinControlDescriptor {
197
197
pin_state : false ,
198
198
duration : 7 ,
199
199
} ;
200
200
push_state ( space) ;
201
201
}
202
202
203
- fn push_letter_interval ( ) {
203
+ pub fn push_letter_interval ( ) {
204
204
let space = PinControlDescriptor {
205
205
pin_state : false ,
206
206
duration : 3 ,
@@ -211,7 +211,7 @@ mod morse_queues {
211
211
static mut COUNT_DOWN : u8 = 0 ;
212
212
static mut CURRENT_PIN_STATE : bool = false ;
213
213
214
- fn get_next_state ( ) -> bool {
214
+ pub fn get_next_state ( ) -> bool {
215
215
let mut pin_state: bool ;
216
216
unsafe {
217
217
if COUNT_DOWN <= 0 {
@@ -228,7 +228,7 @@ mod morse_queues {
228
228
}
229
229
}
230
230
231
- fn push_char ( letter : char ) {
231
+ pub fn push_char ( letter : char ) {
232
232
unsafe {
233
233
let index = CHAR_QUEUE . write_position as usize ;
234
234
let queue = & mut CHAR_QUEUE ;
@@ -238,7 +238,7 @@ mod morse_queues {
238
238
}
239
239
}
240
240
241
- fn pop_char ( ) -> char {
241
+ pub fn pop_char ( ) -> char {
242
242
unsafe {
243
243
if CHAR_QUEUE . length == 0 {
244
244
return '\r' ; // Use CR to indicate empty queue
@@ -250,7 +250,7 @@ mod morse_queues {
250
250
}
251
251
}
252
252
253
- fn push_state ( state : PinControlDescriptor ) {
253
+ pub fn push_state ( state : PinControlDescriptor ) {
254
254
unsafe {
255
255
let index = PIN_CONTROL_QUEUE . write_position as usize ;
256
256
let queue = & mut PIN_CONTROL_QUEUE ;
@@ -261,7 +261,7 @@ mod morse_queues {
261
261
}
262
262
}
263
263
264
- fn pop_state ( ) -> PinControlDescriptor {
264
+ pub fn pop_state ( ) -> PinControlDescriptor {
265
265
unsafe {
266
266
if PIN_CONTROL_QUEUE . length == 0 {
267
267
return PinControlDescriptor {
@@ -280,7 +280,7 @@ mod morse_queues {
280
280
}
281
281
}
282
282
283
- fn emit_morse_letter ( letter : char ) {
283
+ pub fn emit_morse_letter ( letter : char ) {
284
284
let downcased_letter = letter. to_ascii_lowercase ( ) ; // Add support for Latin 1 later.
285
285
match downcased_letter {
286
286
'a' => {
@@ -694,13 +694,13 @@ mod morse_queues {
694
694
}
695
695
}
696
696
697
- fn emit_morse_dot ( ) {
697
+ pub fn emit_morse_dot ( ) {
698
698
push_dot ( ) ;
699
699
}
700
- fn emit_morse_dash ( ) {
700
+ pub fn emit_morse_dash ( ) {
701
701
push_dash ( ) ;
702
702
}
703
- fn emit_morse_space ( ) {
703
+ pub fn emit_morse_space ( ) {
704
704
push_space ( ) ;
705
705
}
706
706
}
0 commit comments