Recent Posts

Pages: 1 ... 4 5 [6] 7 8 ... 10
51
BBC BASIC / BBC BASIC for SDL 2.0 version 1.22a released
« Last post by Richard Russell on May 28, 2021, 04:56:15 PM »
I've released version 1.22a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, MacOS, Linux, Raspbian, Android, iOS and in-browser.  The changes in this version are as follows:

  • BASIC Interpreter / Run Time Engine

    Cmd+left, Cmd+right, Cmd+up and Cmd+down are mapped to Home, End, Ctrl+Home and Ctrl+End, respectively, for improved compatibility with Apple Macs.

    In the in-browser edition *RUN now runs JavaScript code (previously it did nothing useful) e.g. OSCLI "window.open(""http://www.rtrussell.co.uk"")"

    The QUIT n statement can now accept a parameter of zero (ARM and 64-bit editions only, 32-bit x86 editions always could).

    A few performance optimisations have been carried out (e.g. fixing memory alignment issues).

  • IDEs and Utilities

    In SDLIDE.bbc Alt+left and Alt+right are mapped to Word Left and Word Right, respectively, for improved compatibility with Apple Macs.

    Added a -P command-line switch to SDLIDE.bbc to activate the profiler.

    The Android and iOS editions report if a later version is available.

  • Libraries

    Changed gleslib.bbc and ogllib.bbc to call glLightfv by address rather than name.

  • Example Programs

    Added Newton's Cradle simulation (cradle.bbc in examples/physics).

    Bundled the set of instructive Box2D demos in examples/physics/samples (these all use Debug Draw graphics).

    Updated sudoku.bbc to add Tidy and New Game options (the difficulty of the generated game is very variable!).

This version may be downloaded, for all the supported platforms, from the usual location.  The GitHub repository has been updated (used to build the MacOS, Raspbian, Android, iOS, 64-bit Linux and in-browser editions, currently).
52
BBC BASIC / BBC BASIC for SDL 2.0 version 1.21a released
« Last post by Richard Russell on April 16, 2021, 01:41:25 PM »
I've released version 1.21a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, MacOS, Linux, Raspbian, Android, iOS and in-browser.  The changes in this version are as follows:
  • BASIC Interpreter / Run Time Engine

    Mapped keyboard shortcuts Cmd+A, Cmd+C, Cmd+F, Cmd+V, Cmd+X and Cmd+Z to their Ctrl equivalents for improved compatibility with Apple Macs.

    Fixed a couple of minor differences between the 32-bit x86 editions and the ARM/64-bit editions.

  • IDEs and Utilities

    Added compiler directives to SDLIDE.bbc to simplify building a standalone version in BB4W.

    Modified memusage.bbc, profiler.bbc, searchin.bbc and sdldebug.bbc to be compatible with BB4W as well as BBCSDL.

  • Libraries

    Added box2ddbg.bbc to support Box2D Debug Graphics, largely compatible with the equivalent BB4W library.

    Fixed a bug in box2dlib.bbc affecting Gear Joints on 64-bit platforms.

    Fixed a bug in dlglib.bbc causing the trackbar control not to scale to the specified range.

    Fixed a bug in treeview.bbc causing mouse clicks not to be reliably detected.

  • Example Programs

    Added pinball.bbc (in examples/physics) which demonstrates combining Box2D and 3D rendering.

    Added voronoi.bbc (in examples/graphics/) which is another shader demo.

    Modified recorder.bbc to increase the range of level adjustment (100% is now 'mid-range').

    Modified the other demos in examples/physics to take advantage of the box2ddbg library (press D to display the Debug Graphics).
This version may be downloaded, for all the supported platforms, from the usual location.  The GitHub repository has been updated (used to build the MacOS, Raspbian, Android, iOS, 64-bit Linux and in-browser editions, currently).
53
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 21, 2021, 12:49:05 AM »
I was able to get my NeoPixel stick working under MicroPython on my ESP32-PICO-D4 controller.

The picture doesn't do the color presentation any justice. Looks great live.

I can see this being used to create outdoor billboards. A string of NeoPixels to decorate a Christmas tree is another idea.

Code: Python
  1. import machine, neopixel
  2. n = 8
  3. p = 5
  4. np = neopixel.NeoPixel(machine.Pin(p), n)
  5. np[0] = (255, 0, 0)
  6. np[1] = (0, 255, 0)
  7. np[2] = (0, 0, 255)
  8. np[3] = (128, 0, 0)
  9. np[4] = (0, 128, 0)
  10. np[5] = (0, 0, 128)
  11. np[6] = (125, 204, 223)
  12. np[7] = (255, 0, 153)
  13. np.write()
  14.  

This example I converted from CircuitPython displays a rainbow effect.

NeoPixel Rainbow video clip. I hide the stick to cut down on the glare.  8)

Code: Python
  1. # MicroPython demo - NeoPixel
  2. import time
  3.  
  4. import machine
  5. import neopixel
  6.  
  7. pixel_pin = machine.Pin(5)
  8. num_pixels = 8
  9.  
  10. pixels = neopixel.NeoPixel(pixel_pin, num_pixels)
  11.  
  12.  
  13. def wheel(pos):
  14.     # Input a value 0 to 255 to get a color value.
  15.     # The colours are a transition r - g - b - back to r.
  16.     if pos < 0 or pos > 255:
  17.         return (0, 0, 0)
  18.     if pos < 85:
  19.         return (255 - pos * 3, pos * 3, 0)
  20.     if pos < 170:
  21.         pos -= 85
  22.         return (0, 255 - pos * 3, pos * 3)
  23.     pos -= 170
  24.     return (pos * 3, 0, 255 - pos * 3)
  25.  
  26.  
  27. def rainbow_cycle(wait):
  28.     for j in range(255):
  29.         for i in range(num_pixels):
  30.             rc_index = (i * 256 // num_pixels) + j
  31.             pixels[i] = wheel(rc_index & 255)
  32.         pixels.write()
  33.         time.sleep(wait)
  34.  
  35.  
  36. while True:
  37.     rainbow_cycle(0)  # Increase the number to slow down the rainbow
  38.  


54
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 18, 2021, 07:26:12 PM »
I tried to install the ESP-IDF tools on my RPi 4B running Ubuntu 64 bit.

This sucks!


jrs@RPi-Dev:~/esp/esp-idf$ ./install.sh
Detecting the Python interpreter
Checking "python" ...
/home/jrs/esp/esp-idf/tools/detect_python.sh: line 16: python: command not found
Checking "python3" ...
Python 3.8.6
"python3" has been detected
Installing ESP-IDF tools
Installing tools: xtensa-esp32-elf, xtensa-esp32s2-elf, xtensa-esp32s3-elf, riscv32-esp-elf, esp32ulp-elf, esp32s2ulp-elf, openocd-esp32
ERROR: tool xtensa-esp32-elf does not have versions compatible with platform linux-arm64
jrs@RPi-Dev:~/esp/esp-idf$



On a positive note I was able to install the ESP32 development tools on my 4 GB / 2 core @ 2.13 ghz AMD old laptop. It's running Ubuntu 20.04 64 bit OS. Runs a lot faster than my RPi 3B.

55
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 18, 2021, 05:31:02 AM »
I have spent hours trying to get my DHT11 and DHT22 working on Micropython using the DHT library. The measure() call returns a ETIMEOUT with every attempt.

Has anyone gotten this to work?

You don't need to join the forum to respond. Send an e-mail to support@raspberrybasic.org with suggestions would be appreciated.
56
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 17, 2021, 12:11:11 AM »
ESP32-PICO-D4

Detailed Spec.

ESP32 contains two low-power Xtensa 32-bit LX6 microprocessors. (240 MHz) The internal memory includes:

* 448 KB of ROM for booting and core functions.
* 520 KB of on-chip SRAM for data and instructions.
* 8 KB of SRAM in RTC, which is called RTC FAST Memory and can be used for data storage; it is accessedby the main CPU during RTC Boot from the Deep-sleep mode.
* 8 KB of SRAM in RTC, which is called RTC SLOW Memory and can be accessed by the co-processorduring the Deep-sleep mode.
* 1 Kbit of eFuse: 256 bits are used for the system (MAC address and chip configuration) and the remaining768 bits are reserved for customer applications, including flash-encryption and chip-ID
* 4 MB Flash
* Wi-Fi and Bluetooth
$10


ESP32-DEVKITC32D

Detailed Spec.

ESP32-D0WD contains a dual-core Xtensa 32-bit LX6 MCU microprocessor. (240 MHz) The internal memory includes:

* 448 KB of ROM for booting and core functions.
* 520 KB of on-chip SRAM for data and instructions.
* 8 KB of SRAM in RTC, which is called RTC FAST Memory and can be used for data storage; it is accessedby the main CPU during RTC Boot from the Deep-sleep mode.
* 8 KB of SRAM in RTC, which is called RTC SLOW Memory and can be accessed by the co-processorduring the Deep-sleep mode.
* 1 Kbit of eFuse: 256 bits are used for the system (MAC address and chip configuration) and the remaining768 bits are reserved for customer applications, including flash-encryption and chip-ID.
* 4 MB Flash
* Wi-Fi and Bluetooth
$10


Raspberry Pi Pico

* Dual-core Arm Cortex-M0+ processor, flexible clock running up to 133 MHz
* 264KB on-chip SRAM
* 2MB on-board QSPI Flash
$4
57
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 16, 2021, 08:33:03 PM »
This is a ESP32-PICO MicroPython pystone_lowmem benchmark example. This also shows how to use upip to install additional libraries.

Code: Python
  1. >>>
  2. MPY: soft reboot
  3. MicroPython v1.14 on 2021-02-02; ESP32 module with ESP32
  4. Type "help()" for more information.
  5. >>> import network
  6. >>> sta_if = network.WLAN(network.STA_IF)
  7. >>> sta_if.active()
  8. False
  9. >>> sta_if.active(True)
  10. True
  11. >>>
  12. >>> sta_if.scan()
  13. [(b'jrs', b'\xd8\x07\xb6\xf8\xb1\x97', 10, -31, 4, False), (b'BillingsHouse', b'D\x1c\x12\xd8\x99\x96', 1, -64, 3, False), (b'Nika', b'\xec\xaa\xa02\xb0h', 6, -79, 3, False), (b'chicken shit', b'\xd4\xab\x82\xc7\x8d\x92', 1, -84, 3, False), (b'AOL', b'\xbc\x9bh\xa6\x0f\x18', 11, -84, 3, False), (b'2018NEW3beginsYIP!', b'\xd4\xab\x82\xc3\x15\xea', 11, -84, 3, False), (b'My Bell', b'\x80>H\xb7o\xc5', 11, -86, 4, False), (b'Anahouse', b'\x84\x00-\x03\xc1\x98', 11, -89, 3, False), (b'Guapo', b'\xac\xdbHB\xa9\x86', 11, -89, 3, False), (b'IslandHouse', b'P\xd4\xf7\x02b\x89', 2, -90, 3, False), (b'password', b'<z\x8a9\xce`', 1, -91, 3, False), (b'BK WiFi', b'\\\xe3\x0e\xbc\x13\xb5', 6, -91, 3, False), (b'UmbrellaCorp', b'\x84\xd8\x1bfu\xce', 1, -95, 3, False)]
  14. >>> sta_if.connect('jrs', 'MY_PASSWORD')
  15. >>> sta_if.isconnected()
  16. True
  17. >>> import upip
  18. >>> upip.install("micropython-pystone_lowmem")
  19. Installing to: /lib/
  20. Warning: micropython.org SSL certificate is not validated
  21. Installing micropython-pystone_lowmem 3.4.2.post4 from https://micropython.org/pi/pystone_lowmem/pystone_lowmem-3.4.2.post4.tar.gz
  22. >>> import pystone_lowmem
  23. >>>
  24. >>> pystone_lowmem.main()
  25. Pystone(1.2) time for 500 passes = 536ms
  26. This machine benchmarks at 932 pystones/second
  27. >>>
  28.  

This is the same benchmark but using my ESP32-DEVKITC32D board and increasing the processor frequency rate.

Code: Python
  1. >>>
  2. MPY: soft reboot
  3. MicroPython v1.14 on 2021-02-02; ESP32 module with ESP32
  4. Type "help()" for more information.
  5. >>> import network
  6. >>> sta_if = network.WLAN(network.STA_IF)
  7. >>> sta_if.active()
  8. False
  9. >>> sta_if.active(True)
  10. True
  11. >>> sta_if.connect('jrs', 'MY_PASSWORD')
  12. >>> sta_if.isconnected()
  13. True
  14. >>> import upip
  15. >>> upip.install("micropython-pystone_lowmem")
  16. Installing to: /lib/
  17. Warning: micropython.org SSL certificate is not validated
  18. Installing micropython-pystone_lowmem 3.4.2.post4 from https://micropython.org/pi/pystone_lowmem/pystone_lowmem-3.4.2.post4.tar.gz
  19. >>> import pystone_lowmem
  20. >>> pystone_lowmem.main()
  21. Pystone(1.2) time for 500 passes = 537ms
  22. This machine benchmarks at 931 pystones/second
  23. >>> import machine
  24. >>> machine.freq(240000000)
  25. >>> pystone_lowmem.main()
  26. Pystone(1.2) time for 500 passes = 432ms
  27. This machine benchmarks at 1157 pystones/second
  28. >>>
  29.  

I retried the ESP32-PICO (not related to RPi Pico) and increased the frequency to 240000000 it ran faster than my ESP32-DEVKITC32D board.  :o


>>> pystone_lowmem.main()
Pystone(1.2) time for 500 passes = 428ms
This machine benchmarks at 1168 pystones/second
>>>


I need to do a side-by-side comparison to see what makes them different.

I found a post that shows the RPI Pico pystone_lowmem results.


>>> exec(open('Pi_Pico_Pystone_lowmem.py').read())
Pystone(1.2) time for 500 passes = 460ms
This machine benchmarks at 1086 pystones/second

>>>

58
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 15, 2021, 09:28:47 PM »
I got MicroPython running on my ESP32-PICO board. The sensor blinks each time it's scanned.

Picture


pi@RPi3B:~/esp $ /home/pi/esp/esp-idf/components/esptool_py/esptool/esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py v3.1-dev
Serial port /dev/ttyUSB0
Connecting........_
Detecting chip type... ESP32
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:5f:c1:54
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 5.1s
Hard resetting via RTS pin...
pi@RPi3B:~/esp $

pi@RPi3B:~/esp $ /home/pi/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 esp32-idf4-20210202-v1.14.bin
esptool.py v3.1-dev
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:5f:c1:54
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Compressed 1484624 bytes to 951640...
Wrote 1484624 bytes (951640 compressed) at 0x00001000 in 24.2 seconds (effective 491.4 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
pi@RPi3B:~/esp $

59
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 15, 2021, 12:45:30 AM »
I was able to get my DS18B20 temperature sensor to work with the ESP32-DEVKITC32D board.

The interpretive method of programming sure beats having to compile an image and flash it to the controller with each experiment.

I'm going to flash my ESP32-PICO with MicroPython to free up my faster board for more demanding projects.


>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import time, ds18x20
=== from machine import Pin
=== import onewire
===
=== ow = onewire.OneWire(Pin(12))
=== ds = ds18x20.DS18X20(ow)
=== i = 1
=== while i < 11:
===   roms = ds.scan()
===   ds.convert_temp()
===   for rom in roms:
===     print("Sensor " + str(rom) + ": " + str(ds.read_temp(rom)))
===   time.sleep_ms(2000)
===   i += 1
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.3125
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.3125
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.3125
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.3125
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
>>> print(rom)
bytearray(b'(\xff&\xc2\x80\x17\x04\x93')
>>> print(roms)
[bytearray(b'(\xff&\xc2\x80\x17\x04\x93')]
>>> print(ow)
<OneWire object at 3ffe5360>
>>> print(ds)
<DS18X20 object at 3ffe5370>
>>>

60
General Discussion / ESP32 MicroPython
« Last post by John Spikowski on March 14, 2021, 09:35:57 AM »
I was able to get MicroPython loaded on my ESP32-DEVKITC32D board. I'm using Putty on the RPi 3B to connect via /dev/ttyUSB0.


>>> help('modules')
__main__          gc                ubinascii         urandom
_boot             inisetup          ubluetooth        ure
_onewire          machine           ucollections      urequests
_thread           math              ucryptolib        uselect
_uasyncio         micropython       uctypes           usocket
_webrepl          neopixel          uerrno            ussl
apa106            network           uhashlib          ustruct
btree             ntptime           uheapq            usys
builtins          onewire           uio               utime
cmath             uarray            ujson             utimeq
dht               uasyncio/__init__ umqtt/robust      uwebsocket
ds18x20           uasyncio/core     umqtt/simple      uzlib
esp               uasyncio/event    uos               webrepl
esp32             uasyncio/funcs    upip              webrepl_setup
flashbdev         uasyncio/lock     upip_utarfile     websocket_helper
framebuf          uasyncio/stream   upysh
Plus any modules on the filesystem
>>>
>>> machine.freq(240000000)
>>> machine.freq()
240000000
>>>




Pages: 1 ... 4 5 [6] 7 8 ... 10