Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with v0.6.0 #4

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'CI'
on:
pull_request:
push:
branches:
- main

jobs:
find-latest-release:
uses: lf-lang/lingua-franca/.github/workflows/latest-release.yml@master

check-compile:
runs-on: ubuntu-latest
needs: find-latest-release
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Java 17
run: |
echo "$JAVA_HOME_17_X64/bin" >> $GITHUB_PATH
echo "JAVA_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
shell: bash
- name: Install dev dependencies
run: |
sudo apt update
sudo apt install cmake make gcc gcc-arm-none-eabi libnewlib-arm-none-eabi
- uses: lf-lang/action-check-lf-files@main
with:
check_mode: "compile"
no_compile_flag: false
exclude_dirs: '["failing", "experimental"]'
checkout_dir: '../lingua-franca'
compiler_ref: ${{ needs.find-latest-release.outputs.ref }}

check-format:
runs-on: ubuntu-latest
needs: find-latest-release
steps:
- uses: actions/checkout@v4
- name: Set up Java 17
run: |
echo "$JAVA_HOME_17_X64/bin" >> $GITHUB_PATH
echo "JAVA_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
shell: bash
- uses: lf-lang/action-check-lf-files@main
with:
check_mode: "format"
exclude_dirs: '["failing", "experimental"]'
checkout_dir: '../lingua-franca'
compiler_ref: ${{ needs.find-latest-release.outputs.ref }}
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
60 changes: 30 additions & 30 deletions src/AccelerometerDisplay.lf
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
/**
* Display three dimensions of accelerometer measurements on the LCD display of the
* <a href="https://www.pololu.com/docs/0J86">Pololu 3pi+ 2040 robot</a>.
* To run this program, first put the robot in BOOTSEL mode (hold button B while
* resetting). Then the sequence of commands is something like this:
*
* <a href="https://www.pololu.com/docs/0J86">Pololu 3pi+ 2040 robot</a>. To run this program, first
* put the robot in BOOTSEL mode (hold button B while resetting). Then the sequence of commands is
* something like this:
* ```
* $ cd ~/lf-pico
* $ lfc src/AccelerometerDisplay.lf
* ...
* $ picotool load -x bin/AccelerometerDisplay.elf
* ```

*
* This compiles the program, loads it into flash memory on the robot, and begins
* executing it.
* This compiles the program, loads it into flash memory on the robot, and begins executing it.
*
* @author Edward A. Lee
*/
target C {
platform: "RP2040",
threading: false,
target C {
platform: "RP2040",
single-threaded: true
}

import Accelerometer from "lib/IMU.lf"
import Display from "lib/Display.lf"

main reactor {
a = new Accelerometer()
d = new Display()
timer t(0, 250 msec)
reaction(t) -> a.trigger {=
lf_set(a.trigger, true);
=}
a = new Accelerometer()
d = new Display()
timer t(0, 250 msec)

reaction(t) -> a.trigger {=
lf_set(a.trigger, true);
=}

reaction(a.x, a.y, a.z) -> d.line0, d.line1, d.line2 {=
/// TODO: define max string size for line
/// based on font you can have 4 or 8 lines
static char buf0[17];
static char buf1[17];
static char buf2[17];
reaction(a.x, a.y, a.z) -> d.line0, d.line1, d.line2 {=
/// TODO: define max string size for line
/// based on font you can have 4 or 8 lines
static char buf0[17];
static char buf1[17];
static char buf2[17];

snprintf(buf0, 17, "x:%2.4f", a.x->value);
snprintf(buf1, 17, "y:%2.4f", a.y->value);
snprintf(buf2, 17, "z:%2.4f", a.z->value);
lf_set(d.line0, buf0);
lf_set(d.line1, buf1);
lf_set(d.line2, buf2);
=}
}
snprintf(buf0, 17, "x:%2.4f", a.x->value);
snprintf(buf1, 17, "y:%2.4f", a.y->value);
snprintf(buf2, 17, "z:%2.4f", a.z->value);

lf_set(d.line0, buf0);
lf_set(d.line1, buf1);
lf_set(d.line2, buf2);
=}
}
7 changes: 4 additions & 3 deletions src/Blink.lf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ target C {
name: "rp2040",
board: "pololu_3pi_2040_robot"
},
threading: false,
single-threaded: true
}

preamble {=
Expand All @@ -19,13 +19,14 @@ preamble {=
=}

main reactor {
timer t(0, 250 ms);
state led_on:bool = false;
timer t(0, 250 ms)
state led_on: bool = false

reaction(startup) {=
gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
=}

reaction(t) {=
self->led_on = !self->led_on;
printf("LED State: %b\n", self->led_on);
Expand Down
38 changes: 20 additions & 18 deletions src/BumpDisplay.lf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* Display messages when the bump sensors on the
* <a href="https://www.pololu.com/docs/0J86">Pololu 3pi+ 2040 robot</a>
* are triggered.
* <a href="https://www.pololu.com/docs/0J86">Pololu 3pi+ 2040 robot</a> are triggered.
* @author Abhi Gundrala
* @author Edward A. Lee
*/
Expand All @@ -10,26 +9,29 @@ target C {
name: "rp2040",
board: "pololu_3pi_2040_robot"
},
threading: false,
single-threaded: true
}

import Bump from "lib/Bump.lf"
import Display from "lib/Display.lf"

main reactor {
bump = new Bump();
disp = new Display();
logical action clear;
reaction(bump.left) -> disp.line0, clear {=
lf_set(disp.line0, "Left Bumped!");
lf_schedule(clear, SEC(2));
=}
reaction(bump.right) -> disp.line1, clear {=
lf_set(disp.line1, "Right Bumped!");
lf_schedule(clear, SEC(2));
=}
reaction(clear) -> disp.line0, disp.line1 {=
lf_set(disp.line0, "");
lf_set(disp.line1, "");
=}
bump = new Bump()
disp = new Display()
logical action clear

reaction(bump.left) -> disp.line0, clear {=
lf_set(disp.line0, "Left Bumped!");
lf_schedule(clear, SEC(2));
=}

reaction(bump.right) -> disp.line1, clear {=
lf_set(disp.line1, "Right Bumped!");
lf_schedule(clear, SEC(2));
=}

reaction(clear) -> disp.line0, disp.line1 {=
lf_set(disp.line0, "");
lf_set(disp.line1, "");
=}
}
10 changes: 5 additions & 5 deletions src/EncoderDisplay.lf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ target C {
name: "rp2040",
board: "pololu_3pi_2040_robot"
},
threading: false,
single-threaded: true
}

import Display from "lib/Display.lf"
Expand All @@ -19,7 +19,7 @@ main reactor {
display = new Display()
encoder = new Encoders()

timer t(0, 1s)
timer t(0, 1 s)

reaction(t) -> encoder.trigger {=
lf_set(encoder.trigger, true);
Expand All @@ -34,10 +34,10 @@ main reactor {
snprintf(buf, 17, "L: %d", encoder.left->value);
lf_set(display.line1, buf);
=}

reaction(encoder.right) -> display.line2 {=
static char buf[17];
snprintf(buf, 17, "R: %d", encoder.right->value);
lf_set(display.line2, buf);
lf_set(display.line2, buf);
=}
}
}
14 changes: 7 additions & 7 deletions src/GyroAngleDisplay.lf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Display measurements from the gyroscope on the
* <a href="https://www.pololu.com/docs/0J86">Pololu 3pi+ 2040 robot</a>
* with integration so the result is in degrees since reset.
* The gyroscope is provided by an
* <a href="https://www.pololu.com/file/0J1899/lsm6dso.pdf">ST LMS6DSO inertial measurement unit</a>.
* <a href="https://www.pololu.com/docs/0J86">Pololu 3pi+ 2040 robot</a> with integration so the
* result is in degrees since reset. The gyroscope is provided by an
* <a href="https://www.pololu.com/file/0J1899/lsm6dso.pdf">ST LMS6DSO inertial measurement
* unit</a>.
* @author Abhi Gundrala
* @author Edward A. Lee
*/
Expand All @@ -12,7 +12,7 @@ target C {
name: "rp2040",
board: "pololu_3pi_2040_robot"
},
threading: false,
single-threaded: true
}

import Display from "lib/Display.lf"
Expand All @@ -22,7 +22,7 @@ main reactor {
display = new Display()
gyro = new GyroAngle()

timer t(0, 100ms)
timer t(0, 100 ms)

reaction(t) -> gyro.trigger {=
lf_set(gyro.trigger, true);
Expand All @@ -49,4 +49,4 @@ main reactor {
snprintf(buf, 17, "z: %.1f", gyro.z->value);
lf_set(display.line3, buf);
=}
}
}
14 changes: 7 additions & 7 deletions src/GyroDisplay.lf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Display measurements from the gyroscope on the
* <a href="https://www.pololu.com/docs/0J86">Pololu 3pi+ 2040 robot</a>.
* The gyroscope is provided by an
* <a href="https://www.pololu.com/file/0J1899/lsm6dso.pdf">ST LMS6DSO inertial measurement unit</a>.
* The display shows angular velocity in degrees per second.
* <a href="https://www.pololu.com/docs/0J86">Pololu 3pi+ 2040 robot</a>. The gyroscope is provided
* by an
* <a href="https://www.pololu.com/file/0J1899/lsm6dso.pdf">ST LMS6DSO inertial measurement
* unit</a>. The display shows angular velocity in degrees per second.
* @author Abhi Gundrala
* @author Edward A. Lee
*/
Expand All @@ -12,7 +12,7 @@ target C {
name: "rp2040",
board: "pololu_3pi_2040_robot"
},
threading: false,
single-threaded: true
}

import Display from "lib/Display.lf"
Expand All @@ -22,7 +22,7 @@ main reactor {
display = new Display()
gyro = new Gyro()

timer t(0, 100ms)
timer t(0, 100 ms)

reaction(t) -> gyro.trigger {=
lf_set(gyro.trigger, true);
Expand All @@ -49,4 +49,4 @@ main reactor {
snprintf(buf, 17, "z: %.1f", gyro.z->value);
lf_set(display.line3, buf);
=}
}
}
Loading
Loading