\ ********************************************************************* 
\ Display characters for OLED SSD1306 128x32 display 
\    Filename:      SSD10306dispChars.txt 
\    Date:          11 feb 2022 
\    Updated:       22 feb 2022 
\    File Version:  1.0 
\    MCU:           ESP32-WROOM-32 
\    Forth:         ESP32forth all versions 7.x++ 
\    Copyright:     Marc PETREMANN 
\    Author:        Marc PETREMANN 
\    GNU General Public License 
\ ********************************************************************* 
 
DEFINED? --dispChars [if] forget --dispChars  [then] 
create --dispChars 
 
hex 
create FONTS   \ 5x8 
  00 c, 00 c, 00 c, 00 c, 00 c, \ 
  00 c, 00 c, 4f c, 00 c, 00 c, \ ! 
  00 c, 03 c, 00 c, 03 c, 00 c, \ " 
  14 c, 3e c, 14 c, 3e c, 14 c, \ # 
  24 c, 2a c, 7f c, 2a c, 12 c, \ $ 
  63 c, 13 c, 08 c, 64 c, 63 c, \ % 
  36 c, 49 c, 55 c, 22 c, 50 c, \ & 
  00 c, 00 c, 07 c, 00 c, 00 c, \ ' 
  00 c, 1c c, 22 c, 41 c, 00 c, \ ( 
  00 c, 41 c, 22 c, 1c c, 00 c, \ ) 
  0a c, 04 c, 1f c, 04 c, 0a c, \ * 
  04 c, 04 c, 1f c, 04 c, 04 c, \ + 
  50 c, 30 c, 00 c, 00 c, 00 c, \ , 
  08 c, 08 c, 08 c, 08 c, 08 c, \ - 
  60 c, 60 c, 00 c, 00 c, 00 c, \ . 
  00 c, 60 c, 1c c, 03 c, 00 c, \ / 
  3e c, 41 c, 49 c, 41 c, 3e c, \ 0 
  00 c, 02 c, 7f c, 00 c, 00 c, \ 1 
  46 c, 61 c, 51 c, 49 c, 46 c, \ 2 
  21 c, 49 c, 4d c, 4b c, 31 c, \ 3 
  18 c, 14 c, 12 c, 7f c, 10 c, \ 4 
  4f c, 49 c, 49 c, 49 c, 31 c, \ 5 
  3e c, 51 c, 49 c, 49 c, 32 c, \ 6 
  01 c, 01 c, 71 c, 0d c, 03 c, \ 7 
  36 c, 49 c, 49 c, 49 c, 36 c, \ 8 
  26 c, 49 c, 49 c, 49 c, 3e c, \ 9 
  00 c, 33 c, 33 c, 00 c, 00 c, \ : 
  00 c, 53 c, 33 c, 00 c, 00 c, \ ; 
  00 c, 08 c, 14 c, 22 c, 41 c, \ < 
  14 c, 14 c, 14 c, 14 c, 14 c, \ = 
  41 c, 22 c, 14 c, 08 c, 00 c, \ > 
  06 c, 01 c, 51 c, 09 c, 06 c, \ ? 
  3e c, 41 c, 49 c, 15 c, 1e c, \ @ 
  78 c, 16 c, 11 c, 16 c, 78 c, \ A 
  7f c, 49 c, 49 c, 49 c, 36 c, \ B 
  3e c, 41 c, 41 c, 41 c, 22 c, \ C 
  7f c, 41 c, 41 c, 41 c, 3e c, \ D 
  7f c, 49 c, 49 c, 49 c, 49 c, \ E 
  7f c, 09 c, 09 c, 09 c, 09 c, \ F 
  3e c, 41 c, 41 c, 49 c, 7b c, \ G 
  7f c, 08 c, 08 c, 08 c, 7f c, \ H 
  00 c, 41 c, 7f c, 41 c, 00 c, \ I 
  38 c, 40 c, 40 c, 41 c, 3f c, \ J 
  7f c, 08 c, 08 c, 14 c, 63 c, \ K 
  7f c, 40 c, 40 c, 40 c, 40 c, \ L 
  7f c, 06 c, 18 c, 06 c, 7f c, \ M 
  7f c, 06 c, 18 c, 60 c, 7f c, \ N 
  3e c, 41 c, 41 c, 41 c, 3e c, \ O 
  7f c, 09 c, 09 c, 09 c, 06 c, \ P 
  3e c, 41 c, 51 c, 21 c, 5e c, \ Q 
  7f c, 09 c, 19 c, 29 c, 46 c, \ R 
  26 c, 49 c, 49 c, 49 c, 32 c, \ S 
  01 c, 01 c, 7f c, 01 c, 01 c, \ T 
  3f c, 40 c, 40 c, 40 c, 7f c, \ U 
  0f c, 30 c, 40 c, 30 c, 0f c, \ V 
  1f c, 60 c, 1c c, 60 c, 1f c, \ W 
  63 c, 14 c, 08 c, 14 c, 63 c, \ X 
  03 c, 04 c, 78 c, 04 c, 03 c, \ Y 
  61 c, 51 c, 49 c, 45 c, 43 c, \ Z 
  00 c, 7f c, 41 c, 00 c, 00 c, \ [ 
  00 c, 03 c, 1c c, 60 c, 00 c, \ \ 
  00 c, 41 c, 7f c, 00 c, 00 c, \ ] 
  0c c, 02 c, 01 c, 02 c, 0c c, \ ^ 
  40 c, 40 c, 40 c, 40 c, 40 c, \ _ 
  00 c, 01 c, 02 c, 04 c, 00 c, \ ` 
  20 c, 54 c, 54 c, 54 c, 78 c, \ a 
  7f c, 48 c, 44 c, 44 c, 38 c, \ b 
  38 c, 44 c, 44 c, 44 c, 44 c, \ c 
  38 c, 44 c, 44 c, 48 c, 7f c, \ d 
  38 c, 54 c, 54 c, 54 c, 18 c, \ e 
  08 c, 7e c, 09 c, 09 c, 00 c, \ f 
  0c c, 52 c, 52 c, 54 c, 3e c, \ g 
  7f c, 08 c, 04 c, 04 c, 78 c, \ h 
  00 c, 00 c, 7d c, 00 c, 00 c, \ i 
  00 c, 40 c, 3d c, 00 c, 00 c, \ j 
  7f c, 10 c, 28 c, 44 c, 00 c, \ k 
  00 c, 00 c, 3f c, 40 c, 00 c, \ l 
  7c c, 04 c, 18 c, 04 c, 78 c, \ m 
  7c c, 08 c, 04 c, 04 c, 78 c, \ n 
  38 c, 44 c, 44 c, 44 c, 38 c, \ o 
  7f c, 12 c, 11 c, 11 c, 0e c, \ p 
  0e c, 11 c, 11 c, 12 c, 7f c, \ q 
  00 c, 7c c, 08 c, 04 c, 04 c, \ r 
  48 c, 54 c, 54 c, 54 c, 24 c, \ s 
  04 c, 3e c, 44 c, 44 c, 00 c, \ t 
  3c c, 40 c, 40 c, 20 c, 7c c, \ u 
  1c c, 20 c, 40 c, 20 c, 1c c, \ v 
  1c c, 60 c, 18 c, 60 c, 1c c, \ w 
  44 c, 28 c, 10 c, 28 c, 44 c, \ x 
  46 c, 28 c, 10 c, 08 c, 06 c, \ y 
  44 c, 64 c, 54 c, 4c c, 44 c, \ z 
  00 c, 08 c, 77 c, 41 c, 00 c, \ { 
  00 c, 00 c, 7f c, 00 c, 00 c, \ | 
  00 c, 41 c, 77 c, 08 c, 00 c, \ } 
  10 c, 08 c, 18 c, 10 c, 08 c, \ ~ 
decimal 
 
\ Translates ASCII to address of bitpatterns: 
: a>bp ( c -- c-adr ) 
    32 max 127 min 
    32 - 5 * FONTS + 
  ; 
 
\ Draw character: 
: txChar ( c --) 
    \ if 'cr' go to next line 
    dup $0d = 
    if 
        crLine drop 
        exit 
    then 
    \ otherwise, display character 
    SSD1306beginTransmission 
    CTRL_DATAS Wire.send 
    a>bp                \ start addr 
    5 Wire.write drop 
    $00 Wire.send  \ transmit 'blank' 
    SSD1306endTransmission 
  ; 
 
\ display string to SSD1306 OLED screen 
: txString ( adr len --) 
    for  
        aft 
            dup c@ txChar 
            1+ 
        then 
    next 
    drop 
  ; 
 
 
\ exemple for test 
dispinit 
OledCLS 
0 setLine 
s" This the first line" txString  
1 setline 
s" Ici deuxieme ligne" txString  
2 setLine 
s" Ici troisieme ligne" txString  
3 setLine 
s" Ici quatrieme ligne" txString 
 
 
 
 
 
 
\ redirect chars emit to OLED display 
\ : toOLED ( ---) 
\     ['] char.tx 'emit ! 
\   ; 
 
\ redirect chars emit to terminal 
\ : toTERM ( ---) 
\     ['] tx0 'emit ! 
\   ; 
 
 
 

Legal: site web personnel sans commerce / personal site without seling