Skip to content

Commit 32575de

Browse files
committed
TEENSY: added run.sh
1 parent c190f2d commit 32575de

File tree

7 files changed

+79
-11
lines changed

7 files changed

+79
-11
lines changed

src/platform/teensy/libs/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,12 @@ set(SOURCES
119119

120120
add_library(libs STATIC ${SOURCES})
121121

122+
target_compile_options(libs PRIVATE -Wno-all -Wno-extra -Wno-pedantic)
122123
target_include_directories(libs PRIVATE ${ADC_DIR})
123124
target_include_directories(libs PRIVATE ${GFX_DIR})
124125
target_include_directories(libs PRIVATE ${MODULES_DIR}/Adafruit_BusIO)
125126
target_include_directories(libs PRIVATE ${MODULES_DIR}/SdFat/src)
126127
target_include_directories(libs PRIVATE ${SPI_DIR})
127128
target_include_directories(libs PRIVATE ${TEENSY_DIR})
128129
target_include_directories(libs PRIVATE ${WIRE_DIR})
130+

src/platform/teensy/run.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
#
4+
# Allows you to edit your SmallBASIC code in your favourite editor.
5+
# When you save, the program is transferred to the teensy and run.
6+
#
7+
# This works with the INTERACTIVE mode build
8+
# $ cd build && make .. -DINTERACTIVE=ON
9+
#
10+
# Requires inotify-tools available via:
11+
# $ sudo apt install inotify-tools
12+
#
13+
# Example usage:
14+
# $ ./run.sh myapp.bas
15+
#
16+
17+
if [ x$1 == "x" ]; then
18+
echo "usage: edit program.bas"
19+
exit
20+
fi
21+
22+
if [ ! -e $1 ]; then
23+
echo "Program file not found:" $1
24+
exit
25+
fi
26+
27+
if [ ! -c /dev/ttyACM0 ]; then
28+
echo "Teensy not found"
29+
exit
30+
fi
31+
32+
function update() {
33+
echo "Sending" $1
34+
cat $1 > /dev/ttyACM0
35+
timeout 5 cat /dev/ttyACM0
36+
}
37+
38+
update $1
39+
40+
echo "Waiting for changes"
41+
while inotifywait -e modify $1; do
42+
echo "Pushing changes"
43+
update $1
44+
done
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
rem
2+
rem see: https://www.pjrc.com/teensy/td_libs_SSD1306.html
3+
rem
4+
5+
import ssd1306 as display
6+
7+
display.init()
8+
display.clear()
9+
display.dim(5)
10+
display.setCursor(0, 0)
11+
display.invertDisplay(0)
12+
display.print("It works !")
13+
display.flush()
14+
15+
while 1
16+
display.print(".")
17+
display.flush()
18+
delay 1000
19+
wend

src/platform/teensy/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void serial_read() {
9898
bool eof = false;
9999
int lastRead = -1;
100100

101-
dev_print("Waiting for program... ");
101+
dev_print("Waiting for data... ");
102102
buffer.clear();
103103

104104
while (!eof) {

src/platform/teensy/src/module.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
//
99

1010
#include "config.h"
11-
#include "common/sbapp.h"
11+
#include <stdio.h>
12+
#include "include/var.h"
1213

1314
void error(var_p_t var, const char *field, int nMin, int nMax) {
1415
char message[256];

src/platform/teensy/src/noop.c

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <fcntl.h>
1111
#include <stdio.h>
12-
#include <stdlib.h>
1312
#include <sys/stat.h>
1413
#include <sys/times.h>
1514
#include <unistd.h>

src/platform/teensy/src/ssd1306.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@
2525
#define OLED_RESET -1
2626

2727
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
28+
bool init_done = false;
2829

2930
static int cmd_init(int argc, slib_par_t *params, var_t *retval) {
30-
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C, false, true)) {
31-
dev_print("SSD1306 initialization failed");
32-
for (;;);
31+
if (!init_done) {
32+
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C, false, true)) {
33+
dev_print("SSD1306 initialization failed");
34+
for (;;);
35+
}
36+
display.clearDisplay();
37+
display.setTextColor(SSD1306_WHITE);
38+
display.fillScreen(SSD1306_BLACK);
39+
display.setTextSize(1);
40+
init_done = true;
3341
}
34-
35-
display.clearDisplay();
36-
display.setTextColor(SSD1306_WHITE);
37-
display.fillScreen(SSD1306_BLACK);
38-
display.setTextSize(1);
3942
return 1;
4043
}
4144

0 commit comments

Comments
 (0)