Finally got the working mockup running. Currently the hardware includes:
- ESP32 dev module
- Arduino Micro Pro
- SD card reader
- BW LCD with a software LED control
- Hardware keyboard (a working mockup so far; the Chinese PCB manufacturer entered wrong delivery address, so the parcel is back to China)
The LCD part can be easily removed from the primary board - it is held attached by a header.
Power consumption in this configuration:
- Input at 4.96V (WiFi, BT off in all tests)
- The LCD screen LED is fully on (75 Ohm resistor) 103 mA
- The LCD screen LED is fully off (but the LCD is running) 98 mA
- The LCD screen is off (ESP32 and Micro Pro running) 94 mA
- The LCD screen is off, Micro Pro off (ESP32 running) 82 mA
- The total power is wherefore 500 mW, and two 5000 mAh batteries will last 2*5*3.7/0.5 = over 3 days of continuous operation.
I have also compared this to the power consumption of Arduino Mega 2560 with a TFT 480x320 color screen and an SD card (see the video in the Project Log 01). Two different Mega we used: "Classic" and "OSEPP" (in brackets).
- Input at 4.96 V (BASIC is running)
- With TFT connected: 108 (118) mA, 550 mW - this is comparable to the BW LCD system, but no keyboard injection capability.
- With TFT removed : 22(32) mA, 125 mW.
I could not find an elegant way of disconnecting/managing the TFT power and the TFT backlight as it is mounted on a shield.
Obviously, Mega with a BW LCD would make a decent calculator with about 30-50 mA consumption, which equates to one month of a continuous running! Unfortunately, this system has only 4-byte arithmetic, no real-time clock, no WiFi, etc.
The calculator connects to the PC in three ways:
- Via ESP32 USB - for programming ESP32 and direct operation of Terminal BASIC via VT100
- Via Arduino Micro USB - for programming Arduino and impersonating a wired keyboard (still writing code for this - should be an INJECT keyword in BASIC)
- Via BT or WIFI of ESP32 - have not tested software yet, but the hardware is OK - BASIC now has a SET WIFI_NAME, SET WIFI_PASSWORD, NETTIME() keywords, and so you can set time from the network or make a table clock in BASIC.
The Terminal BASIC on ESP32 is working... kind of. I have replaced the capitalized keywords with a lower-case.
The SD card code is not compiling properly as the ESP32 and the Arduino libraries are different - still working on it. The hardware is fully operational, and I am able to run independent tests:
The Terminal BASIC is seemingly having a hard time working with double-precision numbers on ESP32. This program calculates a factorial in integers:
Now replacing r% with r - for 4-byte floats:
Finally, we replace "r" with "r!" ("!" stands for long reals) results in busted stack!
Next: debugging Terminal BASIC on ESP32!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
As I wrote before, I was unable to see the long reals (doubles) problem on ESP32. But the same issue comes out on Arduino DUE. It appears from unaligned access to 8-byte values I think. Now I'm working on the fix, using slower, but more reliable approach of sequential byte read/write instead of reinterpreting unaligned areas of BASIC memory to numeric types.
It's a big disappointment, that compilers do not work around alignment problems. What sense of using C/C++ if the standard features (unions, pointers cast, variable length structures) doesn't work on some platforms and do work on others?
Are you sure? yes | no
It's weird, but I still can't reproduce this error. I didn't use autocapitalize feature during my tests. Also another configuration parameters need to be compared.
Here my test log:
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2020.01.22 00:46:49 =~=~=~=~=~=~=~=~=~=~=~= ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1044 load:0x40078000,len:8896 load:0x40080400,len:5816 entry 0x400806ac TERMINAL BASIC
VERSION 2.1.1-1277
65535 BYTES AVAILABLE
READY
A = 1 READY
A% = = 1 READY
A! = TRUE READY
A! = 1 READY
PRINT A! 1
READY
PRINT A! / 2 .5
READY
PRINT A!@ / 2.3 .4347826177
READY
CLS READY
10 PRINT "GIVE ME A Give me a" 20 INPUT A! % 30 r R! = 1 40 FOR I%=2 to a% TO A% 50 R! = R! * I% 60 NEXT I% 70 PRINT R! 80 END
LIST
10 PRINT "Give me a"
20 INPUT A%
30 R! = 1
40 FOR I% = 2 TO A%
50 R! = R! * I%
60 NEXT I%
70 PRINT R!
80 END
READY
RUN Give me a ?7 5040
READY
RUN Give me a ?8 40320
READY
RUN Give me a ?9 362880
READY
RUN Give me a ?10 3628800
READY
RUN Give me a ?11 39916800
READY
RUN Give me a ?12 479001600
READY
RUN Give me a ?13 6227020800
READY
RUN Give me a ?14 8.71782912E+10
READY
Are you sure? yes | no
Absolutely great job! I will look at TB code for the possible double floats problem.
Are you sure? yes | no