]> Vexing Labs - forthdeck.git/commitdiff
Minor changes, add docs main
authorAdam Shamblin <adam@vexingworkshop.com>
Wed, 27 Jul 2022 00:06:32 +0000 (18:06 -0600)
committerAdam Shamblin <adam@vexingworkshop.com>
Wed, 27 Jul 2022 00:06:32 +0000 (18:06 -0600)
Makefile
doc/README.md
doc/rng.md [new file with mode: 0644]
src/terminal.fs
src/timer.fs
src/wordle.fs

index ec57a30256ce65acf324dda2014b8b29194400c6..5a1c48dc5b5a154063ab721498c74da738156ada 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 # As recommended by the Mecrisp-Stellaris unofficial docs
 # @ https://mecrisp-stellaris-folkdoc.sourceforge.io/serial-terminals.html
 
 # As recommended by the Mecrisp-Stellaris unofficial docs
 # @ https://mecrisp-stellaris-folkdoc.sourceforge.io/serial-terminals.html
 
+TTY ?= /dev/ttyUSB0
 HW_FLOW_CONTROL ?= 1
 LINESPEED = ""
 
 HW_FLOW_CONTROL ?= 1
 LINESPEED = ""
 
@@ -9,7 +10,7 @@ ifeq ($(HW_FLOW_CONTROL), 0)
 endif
 
 connect:
 endif
 
 connect:
-       picocom -b 115200 -f h /dev/ttyUSB0 \
+       picocom -b 115200 -f h $(TTY) \
                --imap lfcrlf,crcrlf \
                --omap delbs,crlf \
                --send-cmd "ascii-xfr -s $(LINESPEED)"
                --imap lfcrlf,crcrlf \
                --omap delbs,crlf \
                --send-cmd "ascii-xfr -s $(LINESPEED)"
index b98bdeba256c14cb36a2ad4e9be9af7418e08383..dfdac99f0b98cf0f927adbc2ed20a98a32c6dfd0 100644 (file)
@@ -13,6 +13,7 @@ available using the `forthdeck` project.
 * [GPIO](gpio.md)
 * [Terminal](terminal.md)
 * [UART](uart.md)
 * [GPIO](gpio.md)
 * [Terminal](terminal.md)
 * [UART](uart.md)
+* [RNG](rng.md)
 * [Wordle](wordle.fs)
 
 ## System
 * [Wordle](wordle.fs)
 
 ## System
diff --git a/doc/rng.md b/doc/rng.md
new file mode 100644 (file)
index 0000000..60acd9b
--- /dev/null
@@ -0,0 +1,18 @@
+---
+title: Random Number Generator
+file: rng.fs
+---
+# RNG
+
+The random number generator relies upon the rp2040's Ring Oscilator and it's
+random bit register to generate a random integer.
+
+# Random Number Generator
+
+### random ( bits -- n )
+
+Given a number of bits, leave a number within that range on the stack.
+
+```forth
+8 random . 219 ok
+```
index 0182ed4829b4688dd73e9d535015cb38b2ba2c7f..723f143a6d1a2a5b68c163f677e16ccbe3d3a023 100644 (file)
@@ -59,7 +59,7 @@
 : [cyan/bg]     ( -- ) BG CYAN    + [format] ;
 
 \ Attributes
 : [cyan/bg]     ( -- ) BG CYAN    + [format] ;
 
 \ Attributes
-: [bold]      ( -- ) BOLD       [format] ;
+: [bold]      ( -- ) BRIGHT     [format] ;
 : [dim]       ( -- ) DIM        [format] ;
 : [italic]    ( -- ) ITALIC     [format] ;
 : [underline] ( -- ) UNDERLINE  [format] ;
 : [dim]       ( -- ) DIM        [format] ;
 : [italic]    ( -- ) ITALIC     [format] ;
 : [underline] ( -- ) UNDERLINE  [format] ;
index 7355d39fd89524081522b4029be17d43f3b71dc7..46e03b1c6992ef33ab319bae94fbfb4441696e5b 100644 (file)
@@ -1,4 +1,5 @@
 \ Words for dealing with the system timer peripheral
 \ Words for dealing with the system timer peripheral
+\ Section 4.6, rp2040 datasheet
 
 $e0000000 constant PPB_BASE
 PPB_BASE $e100 + constant NVIC_ISER \ Interrupt set-enable register
 
 $e0000000 constant PPB_BASE
 PPB_BASE $e100 + constant NVIC_ISER \ Interrupt set-enable register
index a148d016bfbbcc699c34748c67bd86968d059f03..953f2f77b962d5d3edade473987fd36053bfa862 100644 (file)
@@ -12,6 +12,9 @@
 CREATE lexicon SIZE ALLOT
 lexicon VARIABLE lex-ptr
 
 CREATE lexicon SIZE ALLOT
 lexicon VARIABLE lex-ptr
 
+: advance ( -- ) WORDSIZE lex-ptr +! ;
+: store ( size addr -- ) lex-ptr @ SWAP MOVE advance ;
+
 \ Given an address for storage, read and store
 \ a string to memory.
 : load-lexicon ( addr -- )
 \ Given an address for storage, read and store
 \ a string to memory.
 : load-lexicon ( addr -- )
@@ -19,13 +22,9 @@ lexicon VARIABLE lex-ptr
     lex-ptr @ WORDSIZE ACCEPT
     WORDSIZE =
   WHILE
     lex-ptr @ WORDSIZE ACCEPT
     WORDSIZE =
   WHILE
-    WORDSIZE lex-ptr +!
+    advance
   REPEAT ;
 
   REPEAT ;
 
-: advance ( -- ) WORDSIZE lex-ptr +! ;
-
-: store ( size addr -- ) lex-ptr @ SWAP MOVE advance ;
-
 : fake-lexicon ( addr -- )
   s" women" store
   s" nikau" store
 : fake-lexicon ( addr -- )
   s" women" store
   s" nikau" store
@@ -41,7 +40,7 @@ lexicon VARIABLE lex-ptr
 : char= ( char word index -- flag ) char@ = ;
 
 \ Select a random word from lexicon
 : char= ( char word index -- flag ) char@ = ;
 
 \ Select a random word from lexicon
-: randword. ( -- addr ) 2 random word. ;
+: randword. ( -- ) 2 random word. ;
 : randword@ ( -- addr ) 2 random word@ ;
 
 \ See if a word contains a letter
 : randword@ ( -- addr ) 2 random word@ ;
 
 \ See if a word contains a letter