Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*~
146 changes: 146 additions & 0 deletions alnum4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
\ from https://github.com/adafruit/Adafruit_LED_Backpack
\ https://learn.adafruit.com/adafruit-led-backpack/0-54-alphanumeric

\ depends on i2c-new.txt, ht16k333.txt

-alnum4
marker -alnum4

: table ( --- )
create does> ( i -- mask ) swap cells + @ ;

flash
table alnum4.font
%0000000000000001 , %0000000000000010 , %0000000000000100 ,
%0000000000001000 , %0000000000010000 , %0000000000100000 ,
%0000000001000000 , %0000000010000000 , %0000000100000000 ,
%0000001000000000 , %0000010000000000 , %0000100000000000 ,
%0001000000000000 , %0010000000000000 , %0100000000000000 ,
%1000000000000000 , %0000000000000000 , %0000000000000000 ,
%0000000000000000 , %0000000000000000 , %0000000000000000 ,
%0000000000000000 , %0000000000000000 , %0000000000000000 ,
%0001001011001001 , %0001010111000000 , %0001001011111001 ,
%0000000011100011 , %0000010100110000 , %0001001011001000 ,
%0011101000000000 , %0001011100000000 ,
%0000000000000000 , \
%0000000000000110 , \ !
%0000001000100000 , \ "
%0001001011001110 , \ #
%0001001011101101 , \ $
%0000110000100100 , \ %
%0010001101011101 , \ &
%0000010000000000 , \ '
%0010010000000000 , \ (
%0000100100000000 , \ )
%0011111111000000 , \ *
%0001001011000000 , \ +
%0000100000000000 , \ ,
%0000000011000000 , \ -
%0000000000000000 , \ .
%0000110000000000 , \ /
%0000110000111111 , \ 0
%0000000000000110 , \ 1
%0000000011011011 , \ 2
%0000000010001111 , \ 3
%0000000011100110 , \ 4
%0010000001101001 , \ 5
%0000000011111101 , \ 6
%0000000000000111 , \ 7
%0000000011111111 , \ 8
%0000000011101111 , \ 9
%0001001000000000 , \ :
%0000101000000000 , \ ;
%0010010000000000 , \ <
%0000000011001000 , \ =
%0000100100000000 , \ >
%0001000010000011 , \ ?
%0000001010111011 , \ @
%0000000011110111 , \ A
%0001001010001111 , \ B
%0000000000111001 , \ C
%0001001000001111 , \ D
%0000000011111001 , \ E
%0000000001110001 , \ F
%0000000010111101 , \ G
%0000000011110110 , \ H
%0001001000000000 , \ I
%0000000000011110 , \ J
%0010010001110000 , \ K
%0000000000111000 , \ L
%0000010100110110 , \ M
%0010000100110110 , \ N
%0000000000111111 , \ O
%0000000011110011 , \ P
%0010000000111111 , \ Q
%0010000011110011 , \ R
%0000000011101101 , \ S
%0001001000000001 , \ T
%0000000000111110 , \ U
%0000110000110000 , \ V
%0010100000110110 , \ W
%0010110100000000 , \ X
%0001010100000000 , \ Y
%0000110000001001 , \ Z
%0000000000111001 , \ [
%0010000100000000 , \
%0000000000001111 , \ ]
%0000110000000011 , \ ^
%0000000000001000 , \ _
%0000000100000000 , \ `
%0001000001011000 , \ a
%0010000001111000 , \ b
%0000000011011000 , \ c
%0000100010001110 , \ d
%0000100001011000 , \ e
%0000000001110001 , \ f
%0000010010001110 , \ g
%0001000001110000 , \ h
%0001000000000000 , \ i
%0000000000001110 , \ j
%0011011000000000 , \ k
%0000000000110000 , \ l
%0001000011010100 , \ m
%0001000001010000 , \ n
%0000000011011100 , \ o
%0000000101110000 , \ p
%0000010010000110 , \ q
%0000000001010000 , \ r
%0010000010001000 , \ s
%0000000001111000 , \ t
%0000000000011100 , \ u
%0010000000000100 , \ v
%0010100000010100 , \ w
%0010100011000000 , \ x
%0010000000001100 , \ y
%0000100001001000 , \ z
%0000100101001001 , \ {
%0001001000000000 , \ |
%0010010010001001 , \ }
%0000010100100000 , \ ~
%0011111111111111 ,
ram

variable alnum4.buffer 8 allot

: alnum4.init ( addr --- )
ht16k33.init ;

\ : alnum4.erase ( --- )
\ alnum4.buffer 8 erase ;


: alnum4.raw ( mask n --- )
cell * alnum4.buffer + ! ;

: alnum4.char ( a d n --- )
>r
if [ 1 14 lshift ] then 0 else
swap
alnum4.font +
or
r> alnum4.raw ;

\ -alnum4-test
\ marker -alnum4-test

char :noname ( a d n ) r> if
26 changes: 26 additions & 0 deletions ht16k33.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
\ from https://github.com/adafruit/Adafruit_LED_Backpack

\ depends on i2c-new.txt

-ht16k33
marker -ht16k33

: ht16k33.init ( addr --- )
i2c.addr.write if
$21 i2c.tx
then ;

: ht16k33.bright ( level addr --- )
i2c.addr.write if
$e0 or i2c.tx
then ;

0 constant HT16K33_OFF
1 constant HT16K33_2Hz
2 constant HT16K33_1Hz
3 constant HT16K33_1/2Hz

: ht16k33.blink ( rate addr --- )
i2c.addr.write if
1 lshift $81 or i2c.tx
then ;
39 changes: 39 additions & 0 deletions max6675.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
\ from http://www.ulisp.com/show?2GYT uLisp Thermocouple interface example

\ depends on pinsDefinitions.txt

-max6675
marker -max6675

37 constant PORTB

PORTB %000001 defPIN: SO
PORTB %000010 defPIN: CS
PORTB %000100 defPIN: CLK

: tc.init ( --- )
SO input
CS output
CLK output
CS high ;

: tc.read ( --- n * 0.25°C )
CS low
0
16 for
CLK high
SO pin@ if
1 r@ lshift +
then
CLK low
next
CS high
3 rshift ;

-test-max6675
marker -test-max6675

: tc.test
begin
tc.read cr . 500 ms
key? until ;
30 changes: 16 additions & 14 deletions pinsDefinitions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
\ GNU General Public License
\ *********************************************************************

-pindef
marker -pindef

\ Use:
\ PORTD %10000000 defPIN: PD7 ( define portD pin #7)
: defPIN: ( PORTx mask --- <word> | <word> --- mask port)
Expand Down Expand Up @@ -49,20 +52,19 @@
;


-testLED
marker -testLED

\ tests
\ PORTB
37 constant PORTB \ Port B Data Register
PORTB %10000000 defPIN: LED
: init.ports ( ---)
LED output
;
\ -testLED
\ marker -testLED

init.ports
LED high
500 ms
LED low
\ \ tests
\ \ PORTB
\ 37 constant PORTB \ Port B Data Register
\ PORTB %100000 defPIN: LED
\ : init.ports ( ---)
\ LED output
\ ;

\ init.ports
\ LED high
\ 500 ms
\ LED low