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
63 changes: 63 additions & 0 deletions esp32/autoboot.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,66 @@ internals definitions
' autoexec ( leave on the stack for fini.fs )

forth definitions

forth definitions
internals
\ dump tool
: dump ( addr len -- )
cr cr ." --addr--- "
." 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ------chars-----"
2dup + { END_ADDR } \ store latest address to dump
swap { START_ADDR } \ store START address to dump
START_ADDR 16 / 16 * { 0START_ADDR } \ calc. addr for loop start
16 / 1+ { LINES }
base @ { myBASE } \ save current base
hex
\ outer loop
LINES 0 do
0START_ADDR i 16 * + \ calc start address for current line
cr <# # # # # [char] - hold # # # # #> type
space space \ and display address
\ first inner loop, display bytes
16 0 do
\ calculate real address
0START_ADDR j 16 * i + +
ca@ <# # # #> type space \ display byte in format: NN
loop
space
\ second inner loop, display chars
16 0 do
\ calculate real address
0START_ADDR j 16 * i + +
\ display char if code in interval 32-127
ca@ dup 32 < over 127 > or
if drop [char] . emit
else emit
then
loop
loop
myBASE base ! \ restore current base
cr cr
;

create crlf 13 C, 10 C,
: RECORDFILE ( "filename" "filecontents" "<EOF>" -- )
bl parse
W/O CREATE-FILE throw >R
BEGIN
tib #tib accept
tib over
S" <EOF>" startswith?
DUP IF
swap drop
ELSE
swap
tib swap
R@ WRITE-FILE throw
crlf 1+ 1 R@ WRITE-FILE throw
THEN
UNTIL
R> CLOSE-FILE throw
;
: MAIN ( -- )
s" /spiffs/main.fs" included
;

54 changes: 45 additions & 9 deletions esp32/optional/oled/oled.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Copyright 2023 Bradley D. Nelson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -13,8 +12,8 @@
// limitations under the License.

/*
* ESP32forth Oled v{{VERSION}}
* Revision: {{REVISION}}
* Adadptation Marc PETREMANN
* Updated 22 jan. 2026
*/

// You will need to install these libraries from the Library Manager:
Expand All @@ -34,25 +33,62 @@ static Adafruit_SSD1306 *oled_display = 0;
YV(oled, OledAddr, PUSH &oled_display) \
YV(oled, OledNew, oled_display = new Adafruit_SSD1306(n2, n1, &Wire, n0); DROPn(3)) \
YV(oled, OledDelete, delete oled_display) \
YV(oled, OledBegin, n0 = oled_display->begin(n1, n0); NIP) \
YV(oled, OledHOME, oled_display->setCursor(0, 0)) \
YV(oled, OledBegin, n0 = oled_display->begin(n1, n0, true, true); NIP) \
YV(oled, OledHOME, oled_display->setCursor(0,0)) \
YV(oled, OledCLS, oled_display->clearDisplay()) \
YV(oled, OledTextc, oled_display->setTextColor(n0); DROP) \
YV(oled, OledPrintln, oled_display->println(c0); DROP) \
YV(oled, OledNumln, oled_display->println(n0); DROP) \
YV(oled, OledNum, oled_display->print(n0); DROP) \
YV(oled, OledDisplay, oled_display->display()) \
YV(oled, OledPrint, oled_display->write(c0); DROP) \
YV(oled, OledSetRotation, oled_display->setRotation(n0); DROP) \
YV(oled, OledInvert, oled_display->invertDisplay(n0); DROP) \
YV(oled, OledTextsize, oled_display->setTextSize(n0); DROP) \
YV(oled, OledSetCursor, oled_display->setCursor(n1, n0); DROPn(2)) \
YV(oled, OledSetCursor, oled_display->setCursor(n1,n0); DROPn(2)) \
YV(oled, OledPixel, oled_display->drawPixel(n2, n1, n0); DROPn(3)) \
YV(oled, OledDrawL, oled_display->drawLine(n4, n3, n2, n1, n0); DROPn(5)) \
YV(oled, OledCirc, oled_display->drawCircle(n3, n2, n1, n0); DROPn(4)) \
YV(oled, OledCirc, oled_display->drawCircle(n3,n2, n1, n0); DROPn(4)) \
YV(oled, OledCircF, oled_display->fillCircle(n3, n2, n1, n0); DROPn(4)) \
YV(oled, OledRect, oled_display->drawRect(n4, n3, n2, n1, n0); DROPn(5)) \
YV(oled, OledRectF, oled_display->fillRect(n4, n3, n2, n1, n0); DROPn(5)) \
YV(oled, OledRectR, oled_display->drawRoundRect(n5, n4, n3, n2, n1, n0); DROPn(6)) \
YV(oled, OledRectRF, oled_display->fillRoundRect(n5, n4, n3, n2, n1, n0); DROPn(6))
YV(oled, OledRectRF, oled_display->fillRoundRect(n5, n4, n3, n2, n1, n0); DROPn(6)) \
YV(oled, OledDrawChar, oled_display->drawChar(n5, n4, n3, n2, n1, n0); DROPn(6)) \
YV(oled, OledDrawBitmap, oled_display->drawBitmap(n5, n4, (const uint8_t *) n3, n2, n1, n0); DROPn(6)) \
YV(oled, OledTriangle, oled_display->drawTriangle(n6, n5, n4, n3, n2, n1, n0); DROPn(7)) \
YV(oled, OledTriangleF, oled_display->fillTriangle(n6, n5, n4, n3, n2, n1, n0); DROPn(7)) \
YV(oled, OledEllipse, oled_display->drawEllipse(n4, n3, n2, n1, n0); DROPn(5)) \
YV(oled, OledEllipseF, oled_display->fillEllipse(n4, n3, n2, n1, n0); DROPn(5)) \
YV(oled, OledScrollL, oled_display->startscrollleft(n1, n0); DROPn(2)) \
YV(oled, OledScrollR, oled_display->startscrollright(n1, n0); DROPn(2)) \
YV(oled, OledScrollStop, oled_display->stopscroll())



const char oled_source[] = R"""(
vocabulary oled oled definitions
transfer oled-builtins
DEFINED? OledNew [IF]
128 value WIDTH
64 value HEIGHT
-1 constant OledReset
0 constant BLACK
1 constant WHITE
1 constant SSD1306_EXTERNALVCC
2 constant SSD1306_SWITCHCAPVCC
: OledInit
OledAddr @ 0= if
WIDTH HEIGHT OledReset OledNew
SSD1306_SWITCHCAPVCC $3C OledBegin drop
then
OledCLS
2 OledTextsize ( Draw 2x Scale Text )
WHITE OledTextc ( Draw white text )
0 0 OledSetCursor ( Start at top-left corner )
z" *Esp32forth*" OledPrintln OledDisplay
;
[THEN]
forth definitions
)""";

#include "gen/esp32_oled.h"