Skip to content

Commit 651fded

Browse files
committed
Initial version head tracker
1 parent 0fcaf86 commit 651fded

14 files changed

+1004
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.pio/
2+
.vscode/
3+
tmp/
4+
src/*generated*

code.astylerc

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
#Artistic Style file options for LibreCAD
2+
#Use:
3+
#first install Artistic Style: http://astyle.sourceforge.net/
4+
#change to the top directory of LibreCAD sources (the dir containing this file)
5+
#exec: astyle --options=./arilux.astylerc *.cpp
6+
#exec: astyle --options=./arilux.astylerc *.h
7+
#or
8+
#exec: astyle --options=./arilux.astylerc path_to_some_source_file/source_file
9+
10+
11+
#Indent a C/C++, file.
12+
--mode=c
13+
14+
# Bracket Style
15+
--style=attach
16+
17+
# Indent using # spaces per indent
18+
--indent=spaces=4
19+
20+
# Indent 'class' and 'struct' blocks so that the blocks 'public:',
21+
# 'protected:' and 'private:' are indented.
22+
#--indent-classes
23+
24+
# Indent 'switch' blocks so that the 'case X:' statements are
25+
# indented in the switch block.
26+
--indent-switches
27+
28+
# Indent 'case X:' blocks from the 'case X:' headers.
29+
# Case statements not enclosed in blocks are NOT indented.
30+
#--indent-cases
31+
32+
# Add extra indentation to namespace blocks.
33+
#--indent-namespaces
34+
35+
# Add extra indentation to labels so they appear 1 indent less than
36+
# the current indentation, rather than being flushed to the left.
37+
#--indent-labels
38+
39+
# Indent multi-line preprocessor definitions ending with a backslash.
40+
# Should be used with --convert-tabs for proper results.
41+
--indent-preprocessor
42+
43+
# Indent C++ comments beginning in column one.
44+
--indent-col1-comments
45+
46+
# Set the minimal indent that is added when a header is built of multiple lines.
47+
--min-conditional-indent=0
48+
49+
# Set the maximum of # spaces to indent a continuation line.
50+
# The # indicates a number of columns and must not be greater than 120.
51+
--max-instatement-indent=60
52+
53+
# Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...).
54+
--break-blocks
55+
56+
# Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...).
57+
# Treat closing header blocks (e.g. 'else', 'catch') as stand-alone blocks.
58+
#--break-blocks=all
59+
60+
# Insert space padding around operators.
61+
# Note that there is no option to unpad. Once padded, they stay padded.
62+
--pad-oper
63+
64+
# Insert space padding around parenthesis on both the outside and the inside.
65+
#--pad-paren
66+
67+
# Insert space padding around parenthesis on the outside only.
68+
# This can be used with unpad-paren below to remove unwanted spaces.
69+
#--pad-paren-out
70+
71+
# Insert space padding around parenthesis on the inside only.
72+
# This can be used with unpad-paren below to remove unwanted spaces.
73+
#--pad-paren-in
74+
75+
# Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...).
76+
# This can be used with unpad-paren below to remove unwanted spaces.
77+
--pad-header
78+
79+
# Remove extra space padding around parenthesis on the inside and outside.
80+
# This option can be used in combination with the paren padding options pad‑paren,
81+
# pad‑paren‑out, pad‑paren‑in, and pad‑header above. Only padding that has not
82+
# been requested by other options will be removed.
83+
# For example, if a source has parens padded on both the inside and outside,
84+
# and you want inside only. You need to use unpad-paren to remove the outside
85+
# padding, and pad‑paren‑in to retain the inside padding.
86+
# Using only pad‑paren‑in would not remove the outside padding.
87+
--unpad-paren
88+
89+
# Delete empty lines within a function or method. Empty lines outside of functions
90+
# or methods are NOT deleted. If used with break-blocks or break-blocks=all it will
91+
# delete all lines EXCEPT the lines added by the break-blocks options.
92+
# --delete-empty-lines
93+
94+
# Fill empty lines with the white space of the previous line.
95+
#--fill-empty-lines
96+
97+
# When used with --style=attach, --style=linux, or --style=stroustrup,
98+
# this breaks closing headers (e.g. 'else', 'catch', ...) from their immediately
99+
# preceding closing brackets. Closing header brackets are always broken with
100+
# broken brackets, horstmann brackets, indented blocks, and indented brackets.
101+
#--break-closing-brackets
102+
103+
# Break "else if" header combinations into separate lines. This option has no effect
104+
# if keep-one-line-statements is used, the "else if" statements will remain as they are.
105+
# If this option is NOT used, "else if" header combinations will be placed on a single line.
106+
#--break-elseifs
107+
108+
# Don't break one-line blocks.
109+
#--keep-one-line-blocks
110+
111+
# Don't break complex statements and multiple statements residing on a single line.
112+
#--keep-one-line-statements
113+
114+
#Add brackets to unbracketed one line conditional statements (e.g. 'if', 'for', 'while'...).
115+
# The statement must be on a single line. The brackets will be added according to the
116+
# currently requested predefined style. If no style is requested the brackets will be attached.
117+
# If --add-one-line-brackets is also used the result will be one line brackets.
118+
--add-brackets
119+
120+
121+
# Add one line brackets to unbracketed one line conditional statements
122+
# (e.g. 'if', 'for', 'while'...). The statement must be on a single line.
123+
# The option implies --keep-one-line-blocks and will not break the one line blocks.
124+
#--add-one-line-brackets
125+
126+
#Converts tabs into spaces in the non-indentation part of the line. The number of spaces
127+
# inserted will maintain the spacing of the tab. The current setting for spaces per tab is used.
128+
# It may not produce the expected results if convert-tabs is used when changing spaces per tab.
129+
# Tabs are not replaced in quotes.
130+
--convert-tabs
131+
132+
# Attach a pointer or reference operator (* or &) to either the variable type (left) or variable
133+
# name (right), or place it in middle (between the type and name). The spacing between the type and
134+
# name will be preserved, if possible. To format references separately use the following
135+
# align-reference option.
136+
--align-pointer=type
137+
138+
# This option will align references separate from pointers. Pointers are not changes by this option.
139+
# If pointers and references are to be aligned the same, use the previous align-pointer option.
140+
# The option align-reference=none will not change the reference alignment. The other options are
141+
# the same as for align-pointer.
142+
--align-reference=type
143+
144+
######################### File Options #########################################
145+
146+
#Append the suffix #### instead of '.orig' to original filename (e.g. --suffix=.bak).
147+
# If this is to be a file extension, the dot '.' must be included. Otherwise the suffix will be
148+
# appended to the current file extension.
149+
#--suffix=.orig
150+
151+
# Do not retain a backup of the original file. The original file is purged after it is formatted.
152+
#--suffix=none
153+
154+
# For each directory in the command line, process all subdirectories recursively. When using the
155+
# recursive option the file name statement should contain a wildcard. Linux users should place the
156+
# filepath and name in double quotes so the shell will not resolve the wildcards (e.g. "$HOME/src/*.cpp").
157+
# Windows users should place the filepath and name in double quotes if the path or name contains spaces.
158+
#--recursive
159+
160+
#Specify a file or sub directory #### to be excluded from processing.
161+
# Excludes are matched from the end of the filepath. An exclude option of "templates" will exclude ALL
162+
# directories named "templates". An exclude option of "cpp/templates" will exclude ALL "cpp/templates"
163+
# directories. You may proceed backwards in the directory tree to exclude only the required directories.
164+
# Specific files may be excluded in the same manner. An exclude option of "default.cpp" will exclude ALL
165+
# files named "default.cpp". An exclude option of "python/default.cpp" will exclude ALL files named
166+
# "default.cpp" contained in a "python" subdirectory. You may proceed backwards in the directory tree to
167+
# exclude only the required files.
168+
# Wildcards are NOT allowed. There may be more than one exclude statement.
169+
# The filepath and name may be placed in double quotes (e.g. ‑‑exclude="foo bar.cpp").
170+
#--exclude=####
171+
172+
173+
# Allow processing to continue if there are errors in the "exclude=###" options.
174+
# This option lets the excludes for several projects be entered in a single option file. This option may
175+
# be placed in the same option file as the excludes. It will display the unmatched excludes.
176+
# The following option will not display the unmatched excludes.
177+
#ignore-exclude-errors
178+
179+
# Allow processing to continue if there are errors in the "exclude=###" options.
180+
# This option lets the excludes for several projects be entered in a single option file. This option may
181+
# be placed in the same option file as the excludes. It will NOT display the unmatched excludes.
182+
# The preceding option will display the unmatched excludes.
183+
#ignore-exclude-errors-x
184+
185+
# Print errors to standard-output rather than to standard-error.
186+
# This option should be helpful for systems/shells that do not have this option, such as in Windows95.
187+
#--errors-to-stdout
188+
189+
# Preserve the original file's date and time modified. The date and time modified will not be changed
190+
# in the formatted file. This option is not effective if redirection is used to rename the input file.
191+
--preserve-date
192+
193+
# Verbose display mode. Display optional information, such as release number and statistical data.
194+
#--verbose
195+
196+
# Formatted files display mode. Display only the files that have been formatted. Do not display files that are unchanged.
197+
--formatted
198+
199+
# Quiet display mode. Suppress all output except error messages.
200+
#--quiet
201+
202+
# Force use of the specified line end style. Valid options are windows (CRLF), linux (LF), and macold (CR).
203+
# MacOld style is the format for OS 9 and earlier. Mac OS X uses the Linux style. If one of these options
204+
# is not used the line ends will be determined automatically from the input file.
205+
#--lineend=windows
206+
--lineend=linux
207+
#--lineend=macold
208+
209+
210+
211+
212+
213+
214+
215+
216+
217+

generateHtmlArray.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
cd web
4+
cat *.js | gzip -9 > jscript.js.gz
5+
xxd --include jscript.js.gz > ../src/jscript.generated.h
6+
rm jscript.js.gz
7+
8+
for f in *.html
9+
do
10+
cat $f > "${f}.nt"
11+
echo -ne "\0" >> "${f}.nt"
12+
xxd -i "${f}.nt" > ../src/"${f/\./_}".generated.h
13+
done
14+
rm -rf *.nt

img/calibration.png

93.3 KB
Loading

img/mpu6050_holder.png

38.1 KB
Loading

img/wifi_config.png

41.6 KB
Loading

platformio.ini

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
[platformio]
11+
12+
[common_env_data]
13+
lib_deps_embedded_external =
14+
https://github.com/tzapu/WiFiManager#development
15+
I2Cdevlib-MPU6050
16+
ArduinoJson
17+
18+
[env:wemos]
19+
platform = espressif8266
20+
framework = arduino
21+
board = esp01_1m
22+
#upload_resetmethod = nodemcu
23+
board_build.flash_mode = dio
24+
board_build.f_flash = 20000000L
25+
build_flags =
26+
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
27+
lib_deps =
28+
${common_env_data.lib_deps_embedded_external}
29+
upload_speed = 921600

readme.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Head tracking with esp8266/esp8265 and MPU6050
2+
3+
# Installation
4+
5+
Install platform IO
6+
7+
```bash
8+
# Build char* array for web
9+
./javascriptToHeader.sh
10+
platformio run --target upload -e wemos
11+
platformio device monitor --baud 115200
12+
```
13+
14+
# How to use
15+
16+
The device will create a new network so for a once time setup you need to have your computer or mobile phone connect to this network and congirue the wifi.
17+
18+
[Wifi Config Menu](img/wifi_config.png "Wifi Config")
19+
20+
If you did monitor your device it will show you the IP address of the access point.
21+
22+
While you are at it go to the setup page to tell setup the location and protocol to send data to. You can also calibrate the MPU (Motion Processing Unit). Read the instructions carefully!
23+
24+
[Calibration menu](img/calibration.png "Calibration")
25+
26+
* FreePie protocol sends Yaw Pitch and Roll using the FreePie format. This has been tested with OpenTrack
27+
* OpenTrackUDP sends Yaw Pitch and Roll using a simple floar array. This has been tested with OpenTrack.
28+
29+
# Where to put the MPU
30+
31+
I have designed a little box that can be printed using a 3D printer.
32+
It´s a bit tricky to print but it will work out if you put up some support material. The STL file (mpu6050_holder.stl) is included.
33+
34+
[Holder for MPU6050 menu](img/mpu6050_holder.png "mpu6050")
35+
36+
The ESP8266 can be put in a other box and you can connect the MPU6050 and ESP8266 using a 5 wire shielded cable. Make sure it´s not longer than 1.5 to 2 meter (I have tested 1.5m) otherwhise I2C communication mght fail.
37+

0 commit comments

Comments
 (0)