Skip to content

Commit

Permalink
Merge tag '1.8' into debian
Browse files Browse the repository at this point in the history
Snek version 1.8
  • Loading branch information
keith-packard committed Mar 27, 2022
2 parents a7c9d95 + b233bf8 commit 224ca87
Show file tree
Hide file tree
Showing 65 changed files with 1,035 additions and 243 deletions.
10 changes: 4 additions & 6 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
FROM debian:unstable AS download-tarballs

RUN apt-get update && \
apt-get install -y wget gnupg && \
wget -O - https://maps.altusmetrum.org/archive/archive-key | apt-key add - && \
echo "deb http://maps.altusmetrum.org/archive unstable/" > /etc/apt/sources.list.d/keithp.list && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
Expand All @@ -23,8 +20,8 @@ RUN apt-get update && \
ruby-coderay \
gcc-arm-linux-gnueabi \
libc6-dev-armel-cross \
qemu-system-arm=1:5.0-5.5 \
qemu-system-misc=1:5.0-5.5 \
qemu-system-arm \
qemu-system-misc \
black \
python3-pip \
python3-serial \
Expand All @@ -35,7 +32,8 @@ RUN apt-get update && \
gcc-mingw-w64 \
librsvg2-bin \
icoutils \
icnsutils && \
icnsutils \
black && \
pip install pynsist

RUN mkdir snek
Expand Down
14 changes: 0 additions & 14 deletions .github/Dockerfile-black

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/black.yml

This file was deleted.

42 changes: 36 additions & 6 deletions .github/workflows/snek.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
name: snek

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main

env:
IMAGE_FILE: dockerimg.tar
IMAGE: snek
HASH_FILE: snek/.github/Dockerfile

jobs:
test:
Expand All @@ -11,11 +22,30 @@ jobs:
with:
path: snek

- name: 'Build snek container'
- name: Check for Docker Image
id: cache
uses: actions/cache@v2
with:
path: ${{ env.IMAGE_FILE }}
key: ${{ env.IMAGE_FILE }}-${{ hashFiles( env.HASH_FILE ) }}

- name: Set up Docker build
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@v1

- name: Build snek container
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@v2
with:
platforms: linux/amd64
file: .github/Dockerfile
tags: ${{ env.IMAGE }}:latest
outputs: type=docker,dest=${{ env.IMAGE_FILE }}

- name: Load Docker image
run: |
docker build -t snek \
-f snek/.github/Dockerfile \
snek
docker load -i $IMAGE_FILE
docker images -a $IMAGE
- name: 'Create install destinationn'
run: |
Expand All @@ -26,7 +56,7 @@ jobs:
docker run --rm \
--mount type=bind,source=`pwd`/artifacts,destination=/artifacts \
snek \
make DESTDIR=/artifacts PREFIX=/opt/snek SNEK_OTHEROS=1 SNEK_RISCV_TEST=1 check install install-otheros
make DESTDIR=/artifacts PREFIX=/opt/snek SNEK_OTHEROS=1 SNEK_RISCV_TEST=1 black check install install-otheros
- name: 'Upload results'
uses: actions/upload-artifact@v2
Expand Down
140 changes: 136 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ described below.
This board was designed to run Snek and control Lego Power Function motors.

* [Crowd Supply µduino](https://www.crowdsupply.com/uduino/uduino).
This board doesn't have any access to the programming pins, so
you'd need to get Snek pre-programmed before it was split off of
the carrier board.

* [Arduino Uno](https://store.arduino.cc/usa/arduino-uno-rev3)
* [Arduino Uno](https://store.arduino.cc/usa/arduino-uno-rev3). This
is pretty much the same as a Duemilanove board, but with a
different USB to serial converter.

* [Seeeduino XIAO](https://www.seeedstudio.com/Seeeduino-XIAO-Arduino-Microcontroller-SAMD21-Cortex-M0+-p-4426.html).

Expand All @@ -77,6 +82,10 @@ described below.

* [Arduino Nano Every](https://store.arduino.cc/usa/nano-every).

* [LilyPad Arduino 328](https://www.sparkfun.com/products/13342).
This port leaves out dictionaries and slices so that it has space
for the tone driver.

## To Do list

* Convert parser from LL to SLR. The hope here is to reduce the
Expand All @@ -87,6 +96,15 @@ described below.

Here's some places that have seen recent work

* [LilyPad Arduino 328](https://www.sparkfun.com/products/13342)
port. This is a round ATmega328p-based board designed for wearable
projects. This board runs at 8MHz, which can't run the serial port
at 115.2kbaud, so it runs at 57.6k instead. Thanks to Douglas
Fraser for this.

* Support multiple baud rates in snekde, auto-detect baud rate when
connecting to non-USB based devices.

* Fix NaN comparisons and make dicts containing NaN keys work.
[Jake Edge's article, “Revisiting NaNs in Python”](https://lwn.net/Articles/869231/)
led to the discovery that Snek had several bugs in NaN
Expand Down Expand Up @@ -193,9 +211,8 @@ system menu.
## The Mu Editor

[mu](https://codewith.mu/) is an IDE especially designed for new
Python developers. It already has support for embedded boards running
MicroPython and CircuitPython, and there are patches available for
[Snek as well](https://github.com/keith-packard/mu).
Python developers. It has support for boards running snek upstream,
but no release has been made with that code yet.

## The Snek Development Environment

Expand Down Expand Up @@ -239,3 +256,118 @@ suggestions and bug reports. Please feel free to send mail or use the
github process. I've created a mailing list for collaboration;
you'll need to subscribe to be able to post. Subscribe to the [snek
mailing list here](https://keithp.com/mailman/listinfo/snek)

## Releases

Here are more specific notes about Snek releases.

### Version 1.8

* Add 'str' builtin. Just like Python, the str builtin converts any
value to a string.

* Fix 'chained' comparisons (e.g. a < b < c). These generated
incorrect code that left the stack messed up unless all comparisons
were true.

* Allow 3 * 'a' as well as 'a' * 3. The code for evaluating
expressions only permitted the string to be on the left side.

* Add support in snekde for auto-detecting device baud rate between
57600 and 115200 baud.

* Add port to the ATMega 328 based LilyPad, in both the regular size
as well as the big version which replaces the boot loader to gain
more functionality.

### Version 1.7

* Fix NaN comparisons and make dicts containing NaN keys work.
[Jake Edge's article, “Revisiting NaNs in Python”](https://lwn.net/Articles/869231/)
led to the discovery that Snek had several bugs in NaN
comparisons. Snek now computes the right value for comparisons with
Nan, as well as permitting NaN to be used as a key in dictionaries.

* Add math functions to nano-every port; the ATmega4809 has plenty of
flash space for these.

### Version 1.6

* Support explicit serial synchronization using ENQ/ACK so that
applications sending lots of data do not require OS flow control
support. With many devices connecting via USB/serial adapters that
do not provide any flow control, adding explicit flow control to
the Snek implementation provides a way to make downloading code
reliable for them.

* Fixed incorrect precedence between bitwise and (&) and bitwise xor
(^) operators.

* Lots of improvements to the EV3 port making it more like
other Snek devices.

* [Narrow 1284](https://www.crowdsupply.com/pandauino/narrow) port.
This is a small board with the ATmega1284 SoC which is like the
ATmega328 but with much more Flash and RAM which provides way more
room for Snek to run.

* Seeed Grove Beginner Kit port. This is another ATmega328p based board
but with a range of devices provided in the kit. Snek supports the
LED, Buzzer, Light, Sound, OLED Display, Button, Rotary Potentiometer
and 3-axis Accelerometer.

* Seeeduino XIAO port. This is a SAMD21-based device on a tiny board
with a USB-C connector.

* Arduino Nano Every port. This uses the ATmega4809 which has 6kB of
RAM, providing much more space for Snek programs.

### Version 1.5

* Arduino Uno port. This port, is mostly the same as the Duemilanove
port but includes replacement firmware for the Atmega 16u2 on the Uno
board which acts as the USB interface.

* Handle 'chained' comparison operators (a < b < c) correctly.

* Add sound output support for the Adafruit Circuit Playground
Express board.

* Use Optiboot on the Duemilanove board so that Snek can be replaced
without needing a separate programming device.

### Version 1.4

* LEGO EV3 port.
This port, done by Mikhail Gusarov, includes custom functions for
the motors and sensors.

* HiFive1 Rev B port.
This uses a bunch of code from for all of the core and device support.

* Lots of bugs fixed in string interpolation.

* Lessons using LEGO with Snekboard
There are four lessons that show you how to build a simple robot
with step-by-step construction information, and then explore
programming on a Snekboard.

* Improved time.sleep precision. time.sleep is now accurate to the
resolution of the timer. On a Duemilanove, that's
4µs. time.monotonic still returns a float, so the longer
the board has been running, the lower the precision...

* Support for optiboot in Duemilanove code. Once you've installed
optiboot on your Duemilanove, you can install Snek using that over
the USB port, instead of needing an ISP.

### Version 1.3

* Ports to ESP32 and µduino

* Memory-corruption bug in string interpolation fixed

* Bunch of code refactoring saves some space

* Master now tested after every push on github

2 changes: 1 addition & 1 deletion chips/atmega/snek-328p.builtin
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ A4, -2, 18
A5, -2, 19
#include <snek-atmega.h>
#if !defined(SNEK_POOL)
#define SNEK_POOL 940
#define SNEK_POOL 900
#endif
#define SNEK_MAX_TOKEN 63
#define VALUE_STACK_SIZE 16
Expand Down
21 changes: 17 additions & 4 deletions chips/atmega/snek-328p.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static uint32_t on_pins;
/* digital pins all use PULL_UP by default */
static uint32_t pull_pins = 0x03fff;

#ifdef SNEK_TONE
#ifdef SNEK_BUILTIN_tone
static uint8_t tccr0a;
static uint8_t tccr0b;

Expand Down Expand Up @@ -137,7 +137,9 @@ pin_reg(uint8_t pin)
{
if (pin < 8)
return &PIND;
return &PINB;
if (pin < 14)
return &PINB;
return &PINC;
}

static volatile uint8_t *
Expand Down Expand Up @@ -312,7 +314,7 @@ set_out(uint8_t pin)
return SNEK_NULL;
}

#ifdef SNEK_TONE
#ifdef SNEK_BUILTIN_tone
/* Output tone on D5 */
snek_poly_t
snek_builtin_tone(snek_poly_t a)
Expand Down Expand Up @@ -362,6 +364,17 @@ snek_builtin_tone(snek_poly_t a)

return SNEK_NULL;
}

#ifdef SNEK_BUILTIN_tonefor
snek_poly_t
snek_builtin_tonefor(snek_poly_t a, snek_poly_t b)
{
snek_builtin_tone(a);
snek_builtin_on();
snek_builtin_time_sleep(b);
return snek_builtin_tone(SNEK_ZERO);
}
#endif
#endif

snek_poly_t
Expand Down Expand Up @@ -458,7 +471,7 @@ snek_poly_t
snek_builtin_stopall(void)
{
uint8_t p;
#ifdef SNEK_TONE
#ifdef SNEK_builtin_tone
tcc0_reset();
#endif
for (p = 0; p < NUM_PIN; p++)
Expand Down

0 comments on commit 224ca87

Please sign in to comment.