From 4469ae981b6b034852f73276c3a192be06fbe9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phillip=20K=C3=BChne?= Date: Wed, 4 Jul 2018 14:02:04 +0200 Subject: [PATCH] Simulation --- .gitignore | 32 + platformio.sublime-workspace | 1727 ---------------------------------- src/main.cpp | 133 ++- 3 files changed, 98 insertions(+), 1794 deletions(-) delete mode 100644 platformio.sublime-workspace diff --git a/.gitignore b/.gitignore index 6c69f4c..46e94c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,34 @@ .pioenvs .piolibdeps + + +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings diff --git a/platformio.sublime-workspace b/platformio.sublime-workspace deleted file mode 100644 index 02ba463..0000000 --- a/platformio.sublime-workspace +++ /dev/null @@ -1,1727 +0,0 @@ -{ - "auto_complete": - { - "selected_items": - [ - [ - "dis", - "distance\tint distance" - ], - [ - "loo", - "lookLeft\tint lookLeft()" - ], - [ - "ul", - "ultrasonic\tint ultrasonic(int A2, int)" - ], - [ - "set", - "setServo\tvoid setServo(int degrees)" - ], - [ - "de", - "degrees\tint degrees" - ], - [ - "Pi", - "PIN_IN1\tconst int PIN_IN1" - ], - [ - "Se", - "SERVO_PIN\tconst int SERVO_PIN" - ], - [ - "PIN", - "PIN_IN2\tconst int PIN_IN2" - ], - [ - "PIn", - "PIN_IN3\tconst int PIN_IN3" - ], - [ - "PI", - "PIN_IN4" - ], - [ - "p", - "println" - ], - [ - "P", - "PIN_IN4" - ], - [ - "di", - "digitalWrite" - ], - [ - "at", - "attributes" - ], - [ - "fun", - "function" - ], - [ - "mem", - "members" - ], - [ - "int", - "intval" - ], - [ - "json", - "json_encode" - ], - [ - "js", - "json_encode" - ], - [ - "fir", - "first" - ], - [ - "fi", - "first" - ], - [ - "first", - "firstlat" - ], - [ - "tes", - "testJson" - ], - [ - "o", - "overpassOutput" - ], - [ - "for", - "foreach\tforeach …" - ], - [ - "col-3", - "col-3 \tBootstrap 4 Class" - ], - [ - "back", - "background-color" - ], - [ - "nav", - "navbar-brand \tBootstrap 4 Class" - ], - [ - "navb", - "navbar-light \tBootstrap 4 Class" - ], - [ - "l", - "li\tTag" - ], - [ - "cont", - "container-fluid \tBootstrap 4 Class" - ], - [ - "in", - "include" - ], - [ - "cm", - "composer" - ] - ] - }, - "buffers": - [ - { - "file": "platformio.ini", - "settings": - { - "buffer_size": 444, - "encoding": "UTF-8", - "line_ending": "Unix" - } - }, - { - "file": "src/main.cpp", - "settings": - { - "buffer_size": 4700, - "encoding": "UTF-8", - "line_ending": "Unix" - } - }, - { - "file": ".piolibdeps/Ultrasonic_ID1507/README.md", - "settings": - { - "buffer_size": 4822, - "encoding": "UTF-8", - "line_ending": "Unix" - } - }, - { - "file": ".piolibdeps/Ultrasonic_ID1507/src/Ultrasonic.h", - "settings": - { - "buffer_size": 1047, - "encoding": "UTF-8", - "line_ending": "Unix" - } - }, - { - "file": ".piolibdeps/Adafruit SSD1306_ID135/Adafruit_SSD1306.h", - "settings": - { - "buffer_size": 5771, - "encoding": "UTF-8", - "line_ending": "Unix" - } - }, - { - "contents": "# Arduino library for HC-SR04 ultrasonic distance sensor.\n\nHC-SR04 is an ultrasonic sensor that measures distances from 2 to 400cm.\n\n![HC-SR04](/hcsr04.jpg)\n\nThis is a simple library for it!\n\n## Usage\nSensor is initialized by creating instance of class UltraSonicDistanceSensor and providing trigger and echo pins:\n`UltraSonicDistanceSensor sensor(triggerPin, echoPin);`.\n\nThen, to measure the distance, you just call `measureDistanceCm()`, which will return distance in centimeters (double). If distance is larger than 400cm, it will return negative value.\n\n\n## Example\n\nIn this simple example, we need to connect sensors pins like this:\n\n- vcc to 5V\n- trig to digital pin 13\n- echo to digital pin 12\n- gnd to gnd\n\n```\n#include \n\n// Initialize sensor that uses digital pins 13 and 12.\nint triggerPin = 13;\nint echoPin = 12;\nUltraSonicDistanceSensor distanceSensor(triggerPin, echoPin);\n\nvoid setup () {\n Serial.begin(9600); // We initialize serial connection so that we could print values from sensor.\n}\n\nvoid loop () {\n // Every 500 miliseconds, do a measurement using the sensor and print the distance in centimeters.\n double distance = distanceSensor.measureDistanceCm()\n Serial.println(distance);\n delay(500);\n}\n```\n", - "file": ".piolibdeps/HCSR04_ID2968/README.md", - "file_size": 1247, - "file_write_time": 131631654060000000, - "settings": - { - "buffer_size": 1247, - "line_ending": "Unix" - } - } - ], - "build_system": "", - "build_system_choices": - [ - ], - "build_varint": "", - "command_palette": - { - "height": 221.0, - "last_filter": "", - "selected_items": - [ - [ - "Pretty", - "Pretty JSON: Format (Pretty Print) JSON" - ], - [ - "Install ", - "Package Control: Install Package" - ], - [ - "Insta", - "Package Control: Install Package" - ], - [ - "Instal", - "Package Control: Install Package" - ], - [ - "Disco", - "Package Control: Discover Packages" - ], - [ - "Inst", - "Package Control: Install Package" - ], - [ - "Prett", - "Pretty JSON: Validate" - ], - [ - "Pa", - "Package Control: Discover Packages" - ], - [ - "Pret", - "Pretty JSON: Format and Sort JSON" - ], - [ - "Pre", - "Pretty JSON: Validate" - ], - [ - "JSON", - "Set Syntax: JSON" - ], - [ - "Onst", - "Set Syntax: ActionScript" - ], - [ - "Lint ", - "SublimeLinter: Lint This View" - ], - [ - "Lint", - "SublimeLinter: Toggle Highlights" - ], - [ - "Ter", - "Terminal: Open" - ], - [ - "Install", - "Package Control: Install Package" - ], - [ - "Browse", - "View In Browser" - ], - [ - "Remove ", - "Package Control: Remove Package" - ], - [ - "Termin", - "Terminal: Open" - ], - [ - "Packa", - "Package Control: Discover Packages" - ], - [ - "Browser", - "View In Browser" - ], - [ - "Package", - "Package Control: List Packages" - ], - [ - "inst", - "Package Control: Install Package" - ], - [ - "View", - "View In Browser" - ], - [ - "Pack", - "Package Control: Install Package" - ], - [ - "Brwo", - "View In Browser" - ], - [ - "View in", - "View In Browser" - ], - [ - "Brwser", - "Browser Integration: Launch Browser" - ] - ], - "width": 413.0 - }, - "console": - { - "height": 143.0, - "history": - [ - "import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)" - ] - }, - "distraction_free": - { - "menu_visible": true, - "show_minimap": false, - "show_open_files": false, - "show_tabs": false, - "side_bar_visible": false, - "status_bar_visible": false - }, - "expanded_folders": - [ - "/home/phillipk/Code/Robotik", - "/home/phillipk/Code/Robotik/.piolibdeps", - "/home/phillipk/Code/Robotik/.piolibdeps/Ultrasonic_ID1507", - "/home/phillipk/Code/Robotik/.piolibdeps/Ultrasonic_ID1507/src", - "/home/phillipk/Code/Robotik/src" - ], - "file_history": - [ - "/tmp/out.json", - "/home/phillipk/Code/Robotik/src/bmesafix.sh", - "/tmp/CEFSourceIrPB9s.txt", - "/home/phillipk/Arduino/libraries/HCSR04_ultrasonic_sensor/src/HCSR04.cpp", - "/home/phillipk/Code/Robotik/portmappings.md", - "/home/phillipk/Code/Robotik/src/main.cpp", - "/home/phillipk/.zshrc", - "/home/phillipk/Code/Robotik/src/main.c", - "/home/phillipk/Code/Robotik/lib/readme.txt", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Autotool/20-1.hs", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Autotool/20-2.hs", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Autotool/20-3.hs", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Aufgaben/KW21/3.hs", - "/tmp/geo.json", - "/home/phillipk/Downloads/interpreter (4)", - "/home/phillipk/Code/phptest/data2.php", - "/home/phillipk/Code/phptest/data.php", - "/home/phillipk/Code/phptest/vendor/mediasuitenz/overpass2geojson/lib/Overpass2Geojson.php", - "/home/phillipk/Downloads/interpreter (1)", - "/home/phillipk/Downloads/dietpi.log", - "/run/user/1000/gvfs/sftp:host=phillipathome.dynv6.net,user=root/mnt/dietpi_userdata/gitea/custom/conf/app.ini", - "/home/phillipk/.cache/.fr-NViqgV/Read Me !.txt", - "/tmp/nl.html", - "/home/phillipk/Code/Softwareprojekt/Cityfix/code/cityfix_docker/cityfix_api/Dockerfile", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Autotool/19-1.hs", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Autotool/19-2.hs", - "/home/phillipk/.local/share/Steam/steamapps/common/World of Goo/docs/linux-issues.txt", - "/home/phillipk/.WorldOfGoo/config.txt", - "/home/phillipk/.local/share/Steam/steamapps/common/World of Goo/properties/config.txt", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Haskell/1405a.hs", - "/home/phillipk/.config/sublime-text-3/Packages/User/Preferences.sublime-settings", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Autotool/19-0.hs", - "/home/phillipk/Downloads/interpreter", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Multimediale Webprogrammierung/mmwp_Sem04/Eigen/style.css", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Multimediale Webprogrammierung/mmwp_Sem04/Eigen/index.html", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Multimediale Webprogrammierung/mmwp_Sem04/bootstrap-4.1.0-dist/Einzufügende_Zeilen.txt", - "/home/phillipk/.config/sublime-text-3/Packages/User/Emmet.sublime-settings", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Multimediale Webprogrammierung/mmwp_Sem04/0. Ausgangsdatei/Default_Starter_HTML5.html", - "/home/phillipk/Arduino/libraries/Servo8Bit/Servo8Bit.cpp", - "/home/phillipk/Arduino/libraries/Servo8Bit/Servo8Bit.h", - "/home/phillipk/Arduino/libraries/Servo8Bit/Readme.txt", - "/home/phillipk/Arduino/libraries/Servo/src/avr/Servo.cpp", - "/home/phillipk/Arduino/libraries/Servo8Bit/example.cpp", - "/home/phillipk/Arduino/libraries/Servo/src/Servo.h", - "/home/phillipk/Arduino/libraries/Servo8Bit/Makefile", - "/home/phillipk/Arduino/libraries/Servo/src/avr/ServoTimers.h", - "/home/phillipk/Code/Softwareprojekt/Cityfix/code/cityfix_docker/docker-compose.prod.yml", - "/home/phillipk/Code/Softwareprojekt/Cityfix/.gitlab-ci.yml", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Aufgaben/Serie 2/Main.hs", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Aufgaben/Serie 2/15-1.hs", - "/home/phillipk/Code/Softwareprojekt/Cityfix/code/cityfix_docker/cityfix_apache_prod/Dockerfile", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Aufgaben/Serie 2/15-2.hs", - "/home/phillipk/Arduino/libraries/readme.txt", - "/home/phillipk/Code/Softwareprojekt/Cityfix/code/cityfix_frontend/frontend/package.json", - "/home/phillipk/Code/Softwareprojekt/Cityfix/code/cityfix_frontend/frontend/package-lock.json", - "/home/phillipk/Code/Softwareprojekt/Cityfix/code/cityfix_frontend/frontend/.gitignore", - "/home/phillipk/Downloads/samplecat/PKGBUILD", - "/home/phillipk/Downloads/samplecat-0.2.4/INSTALL", - "/home/phillipk/Downloads/Main.hs", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Autotool/15-1.hs", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Autotool/15-2.hs", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Fortgeschrittene Programmierung/Autotool/Interpretation.hs", - "/tmp/tmp.hs", - "/tmp/temp.hs", - "/home/phillipk/.config/sublime-text-3/Packages/BrowserIntegration/BrowserIntegration.sublime-settings", - "/home/phillipk/.config/sublime-text-3/Packages/User/Default (Linux).sublime-keymap", - "/home/phillipk/Downloads/dmesg", - "/home/phillipk/Dokumente/HTWK/Materialien/SoSe 18/Multimediale Webprogrammierung/mmwp_Sem01/Muster_minimal.html", - "/home/phillipk/Code/Softwareprojekt/Cityfix/code/cityfix_docker/cityfix_frontend/Dockerfile", - "/home/phillipk/Code/Softwareprojekt/Cityfix/code/cityfix_docker/cityfix_apache/Dockerfile", - "/home/phillipk/Code/Softwareprojekt/Cityfix/code/cityfix_api/composer.json", - "/home/phillipk/Code/Softwareprojekt/Cityfix/code/cityfix_docker/docker-compose.yml", - "/home/phillipk/Downloads/SuperEven.vcv", - "/home/phillipk/Downloads/dmesg-card-present-during-boot", - "/home/phillipk/.config/sublime-text-3/Packages/View In Browser/View In Browser.sublime-settings" - ], - "find": - { - "height": 26.0 - }, - "find_in_files": - { - "height": 101.0, - "where_history": - [ - ] - }, - "find_state": - { - "case_sensitive": false, - "find_history": - [ - "serial", - "ntfernung", - "(PIN_IN1, OUTPUT);\n pinMode (PIN_IN2, OUTPUT);\n pinMode (PIN_IN3, OUTPUT);\n pinMode ", - "50" - ], - "highlight": true, - "in_selection": false, - "preserve_case": false, - "regex": false, - "replace_history": - [ - ], - "reverse": false, - "show_context": true, - "use_buffer2": true, - "whole_word": false, - "wrap": true - }, - "groups": - [ - { - "selected": 1, - "sheets": - [ - { - "buffer": 0, - "file": "platformio.ini", - "semi_transient": false, - "settings": - { - "buffer_size": 444, - "regions": - { - }, - "selection": - [ - [ - 443, - 443 - ] - ], - "settings": - { - "SL.13.region_keys": - [ - ], - "SL.14.region_keys": - [ - ], - "bracket_highlighter.busy": false, - "bracket_highlighter.clone": -1, - "bracket_highlighter.clone_locations": - { - "close": - { - }, - "icon": - { - }, - "open": - { - }, - "unmatched": - { - } - }, - "bracket_highlighter.clone_regions": - [ - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content", - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content" - ], - "bracket_highlighter.locations": - { - "close": - { - }, - "icon": - { - }, - "open": - { - }, - "unmatched": - { - } - }, - "bracket_highlighter.regions": - [ - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content" - ], - "syntax": "Packages/Text/Plain text.tmLanguage" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 1, - "type": "text" - }, - { - "buffer": 1, - "file": "src/main.cpp", - "semi_transient": false, - "settings": - { - "buffer_size": 4700, - "regions": - { - }, - "selection": - [ - [ - 4476, - 4476 - ] - ], - "settings": - { - "SL.14.region_keys": - [ - ], - "SL.30.region_keys": - [ - ], - "bracket_highlighter.busy": false, - "bracket_highlighter.clone": -1, - "bracket_highlighter.clone_locations": - { - "close": - { - "1": - [ - 3802, - 3803 - ] - }, - "icon": - { - "1": - [ - "Packages/BracketHighlighter/icons/round_bracket.png", - "region.yellowish" - ] - }, - "open": - { - "1": - [ - 3796, - 3797 - ] - }, - "unmatched": - { - } - }, - "bracket_highlighter.clone_regions": - [ - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content" - ], - "bracket_highlighter.locations": - { - "close": - { - "1": - [ - 4477, - 4478 - ] - }, - "icon": - { - "1": - [ - "Packages/BracketHighlighter/icons/round_bracket.png", - "region.yellowish" - ] - }, - "open": - { - "1": - [ - 4470, - 4471 - ] - }, - "unmatched": - { - } - }, - "bracket_highlighter.regions": - [ - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content", - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content" - ], - "syntax": "Packages/C++/C++.sublime-syntax", - "tab_size": 2, - "translate_tabs_to_spaces": true - }, - "translation.x": 0.0, - "translation.y": 2358.0, - "zoom_level": 1.0 - }, - "stack_index": 0, - "type": "text" - }, - { - "buffer": 2, - "file": ".piolibdeps/Ultrasonic_ID1507/README.md", - "semi_transient": false, - "settings": - { - "buffer_size": 4822, - "regions": - { - }, - "selection": - [ - [ - 0, - 0 - ] - ], - "settings": - { - "SL.15.region_keys": - [ - ], - "bracket_highlighter.busy": false, - "bracket_highlighter.clone": -1, - "bracket_highlighter.clone_locations": - { - "close": - { - }, - "icon": - { - }, - "open": - { - }, - "unmatched": - { - "1": - [ - 118, - 119 - ] - } - }, - "bracket_highlighter.clone_regions": - [ - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content" - ], - "bracket_highlighter.locations": - { - "close": - { - }, - "icon": - { - }, - "open": - { - }, - "unmatched": - { - "1": - [ - 118, - 119 - ] - } - }, - "bracket_highlighter.regions": - [ - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content" - ], - "markdonw_live_preview_last_run": 1527691830.38, - "syntax": "Packages/Markdown/Markdown.sublime-syntax", - "tab_size": 4, - "translate_tabs_to_spaces": true - }, - "translation.x": 0.0, - "translation.y": 272.0, - "zoom_level": 1.0 - }, - "stack_index": 2, - "type": "text" - }, - { - "buffer": 3, - "file": ".piolibdeps/Ultrasonic_ID1507/src/Ultrasonic.h", - "semi_transient": false, - "settings": - { - "buffer_size": 1047, - "regions": - { - }, - "selection": - [ - [ - 965, - 965 - ] - ], - "settings": - { - "SL.16.region_keys": - [ - ], - "bracket_highlighter.busy": false, - "bracket_highlighter.clone": -1, - "bracket_highlighter.clone_locations": - { - "close": - { - }, - "icon": - { - }, - "open": - { - }, - "unmatched": - { - } - }, - "bracket_highlighter.clone_regions": - [ - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content" - ], - "bracket_highlighter.locations": - { - "close": - { - "1": - [ - 1020, - 1021 - ] - }, - "icon": - { - "1": - [ - "Packages/BracketHighlighter/icons/curly_bracket.png", - "region.purplish" - ] - }, - "open": - { - "1": - [ - 587, - 588 - ] - }, - "unmatched": - { - } - }, - "bracket_highlighter.regions": - [ - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content" - ], - "markdonw_live_preview_last_run": 1527691868.49, - "syntax": "Packages/C++/C++.sublime-syntax", - "tab_size": 4, - "translate_tabs_to_spaces": true - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 3, - "type": "text" - }, - { - "buffer": 4, - "file": ".piolibdeps/Adafruit SSD1306_ID135/Adafruit_SSD1306.h", - "semi_transient": false, - "settings": - { - "buffer_size": 5771, - "regions": - { - }, - "selection": - [ - [ - 2074, - 2074 - ] - ], - "settings": - { - "SL.17.region_keys": - [ - ], - "SL.18.region_keys": - [ - ], - "SL.58.region_keys": - [ - ], - "bracket_highlighter.busy": false, - "bracket_highlighter.clone": -1, - "bracket_highlighter.clone_locations": - { - "close": - { - }, - "icon": - { - }, - "open": - { - }, - "unmatched": - { - "1": - [ - 725, - 731 - ] - } - }, - "bracket_highlighter.clone_regions": - [ - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content" - ], - "bracket_highlighter.locations": - { - "close": - { - }, - "icon": - { - }, - "open": - { - }, - "unmatched": - { - "1": - [ - 725, - 731 - ] - } - }, - "bracket_highlighter.regions": - [ - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content" - ], - "markdonw_live_preview_last_run": 1527687111.77, - "syntax": "Packages/C++/C++.sublime-syntax", - "tab_size": 2, - "translate_tabs_to_spaces": true - }, - "translation.x": 0.0, - "translation.y": 1071.0, - "zoom_level": 1.0 - }, - "stack_index": 4, - "type": "text" - }, - { - "buffer": 5, - "file": ".piolibdeps/HCSR04_ID2968/README.md", - "semi_transient": false, - "settings": - { - "buffer_size": 1247, - "regions": - { - }, - "selection": - [ - [ - 0, - 0 - ] - ], - "settings": - { - "SL.18.region_keys": - [ - ], - "SL.19.region_keys": - [ - ], - "bracket_highlighter.busy": false, - "bracket_highlighter.clone": -1, - "bracket_highlighter.clone_locations": - { - "close": - { - }, - "icon": - { - }, - "open": - { - }, - "unmatched": - { - } - }, - "bracket_highlighter.clone_regions": - [ - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content" - ], - "bracket_highlighter.locations": - { - "close": - { - }, - "icon": - { - }, - "open": - { - }, - "unmatched": - { - } - }, - "bracket_highlighter.regions": - [ - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content" - ], - "markdonw_live_preview_last_run": 1527685993.81, - "syntax": "Packages/Markdown/Markdown.sublime-syntax" - }, - "translation.x": 0.0, - "translation.y": 204.0, - "zoom_level": 1.0 - }, - "stack_index": 5, - "type": "text" - } - ] - } - ], - "incremental_find": - { - "height": 26.0 - }, - "input": - { - "height": 40.0 - }, - "layout": - { - "cells": - [ - [ - 0, - 0, - 1, - 1 - ] - ], - "cols": - [ - 0.0, - 1.0 - ], - "rows": - [ - 0.0, - 1.0 - ] - }, - "menu_visible": true, - "output.SublimeLinter": - { - "height": 0.0 - }, - "output.find_results": - { - "height": 0.0 - }, - "output.mdpopups": - { - "height": 0.0 - }, - "pinned_build_system": "", - "project": "platformio.sublime-project", - "replace": - { - "height": 48.0 - }, - "save_all_on_build": true, - "select_file": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - ], - "width": 0.0 - }, - "select_project": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - ], - "width": 0.0 - }, - "select_symbol": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - ], - "width": 0.0 - }, - "selected_group": 0, - "settings": - { - }, - "show_minimap": true, - "show_open_files": false, - "show_tabs": true, - "side_bar_visible": true, - "side_bar_width": 237.0, - "status_bar_visible": true, - "template_settings": - { - } -} diff --git a/src/main.cpp b/src/main.cpp index 1ed37ce..c3e810a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,6 +29,7 @@ const int SERVO_PIN = 7; Ultrasonic ultrasonic(A2,A3); int distance = 21; +int motorPower = 255; // put your setup code here, to run once: @@ -58,6 +59,8 @@ void setup() { display.println("Leipzig"); display.display(); } + +#if __GNUC__ && __AVR__ /** * @param leftMotor -255 bis 255, Stärke * @param rightMotor -255 bis 255, Stärke @@ -96,6 +99,8 @@ void enableHigh() { digitalWrite(PIN_ENB,HIGH); } + + void setServo(int degrees) { int lenMicroSecondsOfPulse = (float) degrees/ 90.0 * 1000 + 300; int lenMicroSecondsOfPeriod = 20 * 1000; // 20 milliseconds (ms) @@ -115,6 +120,21 @@ void setServo(int degrees) { } +int scanDirection(int angle) { + setServo(angle); + delay(200); + return ultrasonic.distanceRead(); +} + +void setDisplaytext(String text, Adafruit_SSD1306 display) { + display.clearDisplay(); + display.setTextSize(2); + display.setTextColor(WHITE); + display.setCursor(0,0); + display.println(text); + display.display(); +} + int lookLeft(){ setServo(180); delay(1000); @@ -127,73 +147,52 @@ int lookRight(){ return ultrasonic.distanceRead(); } +#endif + +int getX(int b, int alpha) { + if (alpha<=90) + { + return cos(alpha)*b; + } else + { + return cos(alpha)*b; + } + +} + +int getY(int b, int alpha) { + return sin(alpha)*b; +} void loop() { - enableHigh(); - setServo(90); - distance = ultrasonic.distanceRead(); - display.clearDisplay(); - display.setTextSize(2); - display.setTextColor(WHITE); - display.setCursor(0,0); - display.println("Abstand: "); - display.setTextSize(3); - display.print(distance); - display.setTextSize(2); - display.println(" cm"); - display.display(); - Serial.println(distance); - if (distance<30 && distance>0) { - setMotors(0, 0); - if(lookLeft()>lookRight()){ - setServo(90); - while(distance<50) { - distance = ultrasonic.distanceRead(); - display.clearDisplay(); - display.setTextSize(2); - display.setTextColor(WHITE); - display.setCursor(0,0); - display.println("Abstand (turning left): "); - display.setTextSize(3); - display.print(distance); - display.setTextSize(2); - display.println(" cm"); - display.display(); - Serial.println("Turning left: "); - Serial.println(distance); - setMotors(-120,0); - delay(10); - } - delay(500); - } else { - setServo(90); - while(distance<50) { - distance = ultrasonic.distanceRead(); - display.clearDisplay(); - display.setTextSize(2); - display.setTextColor(WHITE); - display.setCursor(0,0); - display.println("Abstand (turning right): "); - display.setTextSize(3); - display.print(distance); - display.setTextSize(2); - display.println(" cm"); - display.display(); - Serial.println("Turning right: "); - Serial.println(distance); - setMotors(0,-120); - delay(10); - } - delay(500); - } - - } else { - if((distance>215)||(distance<=0)){ - setMotors(255, 255); - } else { - setMotors(distance+70, distance+70); - } + char s[50]; + for (int i = 0; i <= 180; i+=1) + { + int distance = scanDirection(i); + int x = getX(distance, i); + int y = getY(distance, i); + sprintf(s,"X: %d, Y: %d, b: %d, alpha: %d\n",x,y,distance,i); + Serial.println(s); + setDisplaytext(s, display); } - delay(10); - -} \ No newline at end of file +} + + + + +#ifndef __AVR__ + +int main() +{ + setup(); + while(1){loop();} +} + +int scanDirection(int angle) { + return 20; +} + +int setDisplaytext(String text, Adafruit_SSD1306 display) { + std::cout<