Skip to content

Commit c49f4bb

Browse files
authored
Merge pull request #292 from brilliantlabsAR/frame-lite-support
FL support
2 parents 8a1ed80 + 44b5645 commit c49f4bb

22 files changed

+620
-165
lines changed

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
"BMPGDBSerialPort": "/dev/ttyACM0",
7272
},
7373
"osx": {
74-
// "BMPGDBSerialPort": "/dev/cu.usbmodem72ADB7F21",
75-
"BMPGDBSerialPort": "/dev/cu.usbmodem72AE45F31",
74+
// "BMPGDBSerialPort": "/dev/cu.usbmodem72AE45F31",
75+
"BMPGDBSerialPort": "/dev/cu.usbmodem72AE30F31",
7676
}
7777
},
7878
{

production/production_script.sh

Lines changed: 125 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,25 @@ echo "-----------------------"
88
while :
99
do
1010

11+
NOW=`date -u +'%d/%m/%Y - %H:%M:%S'`
12+
1113
echo ""
12-
read -p "Press Enter key to start, or Ctrl-C to quit"
1314
echo "" >> log.txt
15+
read -p "Press Enter key to start, or Ctrl-C to quit"
1416

1517
# Automatically assign port depending if MacOS or Linux
1618
if [ "`uname`" = Darwin ]; then
17-
PORT=`ls /dev/cu.usbmodem*1 2> /dev/null | grep "cu."`
19+
PORT=`ls /dev/cu.usbmodem*1 2> /dev/null`
1820
else
19-
PORT=/dev/ttyACM0 2> /dev/null
21+
PORT=`ls /dev/ttyACM0 2> /dev/null`
2022
fi
2123

22-
# Create timestamp
23-
NOW=`date -u +'%d/%m/%Y - %H:%M:%S'`
24+
if [ $? -eq 1 ]; then
25+
echo "$NOW - Error: Programmer not found" | tee -a log.txt
26+
continue
27+
fi
2428

25-
# Unlock chip
29+
# Unlock chip (and ignore errors)
2630
echo "$NOW - Unlocking chip" | tee -a log.txt
2731
arm-none-eabi-gdb \
2832
-nx \
@@ -44,105 +48,122 @@ do
4448
-ex "monitor erase_mass" \
4549
2> /dev/null
4650

47-
# If successful, continue otherwise throw and error and return to top of loop
48-
if [ $? -eq 0 ]; then
49-
50-
# Get and print device ID
51-
echo -n "$NOW - " | tee -a log.txt
52-
arm-none-eabi-gdb \
53-
-nx \
54-
--batch-silent \
55-
-ex "target extended-remote ${PORT}" \
56-
-ex "monitor swd_scan" \
57-
-ex "attach 1" \
58-
-ex "set logging file /dev/stdout" \
59-
-ex "set logging enabled on" \
60-
-ex "monitor read deviceid" \
61-
-ex "set logging enabled off" \
62-
2> /dev/null \
63-
| tee -a log.txt
64-
65-
# Get and print device address
66-
echo -n "$NOW - " | tee -a log.txt
67-
arm-none-eabi-gdb \
68-
-nx \
69-
--batch-silent \
70-
-ex "target extended-remote ${PORT}" \
71-
-ex "monitor swd_scan" \
72-
-ex "attach 1" \
73-
-ex "set logging file /dev/stdout" \
74-
-ex "set logging enabled on" \
75-
-ex "monitor read deviceaddr" \
76-
-ex "set logging enabled off" \
77-
2> /dev/null \
78-
| tee -a log.txt
79-
80-
# Program sections
81-
echo "$NOW - Programming chip. Please wait"
82-
arm-none-eabi-gdb \
83-
-nx \
84-
--batch-silent \
85-
-ex "target extended-remote ${PORT}" \
86-
-ex 'monitor swd_scan' \
87-
-ex 'attach 1' \
88-
-ex 'load' \
89-
-ex 'compare-sections' \
90-
-ex 'kill' \
91-
frame-firmware-v*.hex \
92-
2> /dev/null
93-
94-
# If successful, start the camera focusing script otherwise throw error
95-
if [ $? -eq 0 ]; then
96-
echo "$NOW - Programmed successfully" | tee -a log.txt
97-
echo -n " Press y if display is working, otherwise n"
98-
read -s -n1 input
99-
100-
# If okay, test the microphone
101-
if [ $input == "y" ]; then
102-
echo -e -n $"\r\033[2K"
103-
echo "$NOW - Display okay" | tee -a log.txt
104-
105-
echo -e -n " Recording audio\r"
106-
python test_microphone_script.py
107-
echo -e -n $"\r\033[2K"
108-
echo -n " Press y if microphone is working, otherwise n"
109-
read -s -n1 input
110-
111-
# Run the camera focusing script
112-
if [ $input == "y" ]; then
113-
echo -e -n $"\r\033[2K"
114-
echo "$NOW - Microphone okay" | tee -a log.txt
115-
116-
python focus_camera_script.py 2> /dev/null
117-
118-
# Done
119-
if [ $? -eq 0 ]; then
120-
121-
echo -e -n $"\r\033[2K"
122-
echo "$NOW - Camera focused" | tee -a log.txt
123-
echo "$NOW - Done" | tee -a log.txt
124-
125-
else
126-
echo -e -n $"\r\033[2K"
127-
echo "$NOW - Error: Could not connect to start focusing" | tee -a log.txt
128-
fi
129-
130-
else
131-
echo -e -n $"\r\033[2K"
132-
echo "$NOW - Error: Microphone not working" | tee -a log.txt
133-
fi
134-
135-
else
136-
echo -e -n $"\r\033[2K"
137-
echo "$NOW - Error: Display not working" | tee -a log.txt
138-
fi
139-
140-
else
141-
echo "$NOW - Error: Chip could not be programmed" | tee -a log.txt
142-
fi
143-
144-
else
51+
if [ $? -eq 1 ]; then
14552
echo "$NOW - Error: Chip not found" | tee -a log.txt
53+
continue
54+
fi
55+
56+
# Get and print device ID
57+
echo -n "$NOW - " | tee -a log.txt
58+
arm-none-eabi-gdb \
59+
-nx \
60+
--batch-silent \
61+
-ex "target extended-remote ${PORT}" \
62+
-ex "monitor swd_scan" \
63+
-ex "attach 1" \
64+
-ex "set logging file /dev/stdout" \
65+
-ex "set logging enabled on" \
66+
-ex "monitor read deviceid" \
67+
-ex "set logging enabled off" \
68+
2> /dev/null \
69+
| tee -a log.txt
70+
71+
# Get and print device address
72+
echo -n "$NOW - " | tee -a log.txt
73+
arm-none-eabi-gdb \
74+
-nx \
75+
--batch-silent \
76+
-ex "target extended-remote ${PORT}" \
77+
-ex "monitor swd_scan" \
78+
-ex "attach 1" \
79+
-ex "set logging file /dev/stdout" \
80+
-ex "set logging enabled on" \
81+
-ex "monitor read deviceaddr" \
82+
-ex "set logging enabled off" \
83+
2> /dev/null \
84+
| tee -a log.txt
85+
86+
# Program sections
87+
echo "$NOW - Programming chip. Please wait"
88+
arm-none-eabi-gdb \
89+
-nx \
90+
--batch-silent \
91+
-ex "target extended-remote ${PORT}" \
92+
-ex 'monitor swd_scan' \
93+
-ex 'attach 1' \
94+
-ex 'load' \
95+
-ex 'compare-sections' \
96+
-ex 'kill' \
97+
frame-firmware-v*.hex \
98+
2> /dev/null
99+
100+
if [ $? -eq 1 ]; then
101+
echo "$NOW - Error: Chip could not be programmed" | tee -a log.txt
102+
continue
103+
fi
104+
105+
echo "$NOW - Programmed successfully" | tee -a log.txt
106+
107+
# Short delay to allow the chip to boot
108+
sleep 3
109+
110+
# Test display/LED
111+
echo -e -n " Running display/LED test\r"
112+
python test_display_led_script.py 2> /dev/null
113+
114+
if [ $? -eq 1 ]; then
115+
echo -e -n $"\r\033[2K"
116+
echo "$NOW - Error: Could not connect to start microphone test" | tee -a log.txt
117+
continue
118+
fi
119+
120+
echo -n " Press y if display/LED is working, otherwise n"
121+
read -s -n1 input
122+
123+
if [ $input == "n" ]; then
124+
echo -e -n $"\r\033[2K"
125+
echo "$NOW - Error: Display/LED not working" | tee -a log.txt
126+
continue
146127
fi
147128

129+
echo -e -n $"\r\033[2K"
130+
echo "$NOW - Display/LED okay" | tee -a log.txt
131+
132+
# Test microphone
133+
echo -e -n " Recording audio\r"
134+
python test_microphone_script.py 2> /dev/null
135+
136+
if [ $? -eq 1 ]; then
137+
echo -e -n $"\r\033[2K"
138+
echo "$NOW - Error: Could not connect to start microphone test" | tee -a log.txt
139+
continue
140+
fi
141+
142+
echo -e -n $"\r\033[2K"
143+
echo -n " Press y if microphone is working, otherwise n"
144+
read -s -n1 input
145+
146+
if [ $input == "n" ]; then
147+
echo -e -n $"\r\033[2K"
148+
echo "$NOW - Error: Microphone not working" | tee -a log.txt
149+
continue
150+
fi
151+
152+
echo -e -n $"\r\033[2K"
153+
echo "$NOW - Microphone okay" | tee -a log.txt
154+
155+
# Run the camera focusing script
156+
python test_focus_camera_script.py 2> /dev/null
157+
158+
if [ $? -eq 1 ]; then
159+
echo -e -n $"\r\033[2K"
160+
echo "$NOW - Error: Could not connect to start focusing" | tee -a log.txt
161+
continue
162+
fi
163+
164+
echo -e -n $"\r\033[2K"
165+
echo "$NOW - Camera focused" | tee -a log.txt
166+
167+
echo "$NOW - Done" | tee -a log.txt
168+
148169
done
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from frameutils import Bluetooth
2+
import asyncio
3+
4+
lua_script = """
5+
if frame.HARDWARE_VERSION == 'Frame' then
6+
width = 640
7+
height = 400
8+
t = string.rep('\\xFF', width * height / 8)
9+
frame.display.bitmap(1, 1, width, 2, 2, t)
10+
frame.display.show()
11+
frame.sleep(1)
12+
frame.display.bitmap(1, 1, width, 2, 9, t)
13+
frame.display.show()
14+
frame.sleep(1)
15+
frame.display.bitmap(1, 1, width, 2, 13, t)
16+
frame.display.show()
17+
frame.sleep(1)
18+
else
19+
frame.led.set_color(100, 0, 0)
20+
frame.sleep(1)
21+
frame.led.set_color(0, 100, 0)
22+
frame.sleep(1)
23+
frame.led.set_color(0, 0, 100)
24+
frame.sleep(1)
25+
end
26+
"""
27+
28+
29+
async def main():
30+
b = Bluetooth()
31+
await b.connect()
32+
await b.upload_file(lua_script, "main.lua")
33+
await b.send_reset_signal()
34+
await asyncio.sleep(3)
35+
await b.disconnect()
36+
37+
38+
asyncio.run(main())

production/focus_camera_script.py renamed to production/test_focus_camera_script.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,15 @@ async def main():
701701
local state = 'CAPTURE'
702702
local state_time = 0
703703
704-
frame.camera.set_gain(0)
705-
frame.camera.set_shutter(550)
706-
frame.camera.set_white_balance(255, 255, 255)
704+
if frame.HARDWARE_VERSION == 'Frame Lite' then
705+
frame.camera.set_gain(0)
706+
frame.camera.set_shutter(330)
707+
frame.camera.set_white_balance(255, 120, 220)
708+
else
709+
frame.camera.set_gain(0)
710+
frame.camera.set_shutter(550)
711+
frame.camera.set_white_balance(255, 255, 255)
712+
end
707713
708714
while true do
709715
if state == 'CAPTURE' then

0 commit comments

Comments
 (0)