diff --git a/README.md b/README.md index ae42143..9ffd950 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ -This playbook will prep a computer to be a road trip car computer +This playbook preps a computer to be a road trip car computer -It will capture snapshots from an attached camera, and it will display the feed on the screen +It capture snapshots from an attached camera to local storage, and it displays the feed on the screen -It will also host a site for the remote end that searches a working directory for the newest file and displays it and it does so every second +It also hosts a site for the remote end that searches a working directory for the newest file and displays it and it does so every second -It will also have a site to press a button to start and stop the timelapse +It also has a site to press a button to start and stop the timelapse service -A lot of this doesn't exist yet or needs to be tested +It was designed to run on the GOLE Handheld from Amazon -I want to write most of it first and then push it out to test \ No newline at end of file +https://www.amazon.com/HIGOLEPC-PC-PRO-Computer-Ethernet/dp/B0BCVXLD5W + +Also, a USB GPS dongle is $15 + +https://www.amazon.com/dp/B07GJGSZB9 \ No newline at end of file diff --git a/templates/gps_service.service-python.j2 b/archive/gps_service.service-python.j2 similarity index 100% rename from templates/gps_service.service-python.j2 rename to archive/gps_service.service-python.j2 diff --git a/files/python_gps/app.py b/archive/python_gps/app.py similarity index 100% rename from files/python_gps/app.py rename to archive/python_gps/app.py diff --git a/defaults/main.yaml b/defaults/main.yaml index 0e7bc0b..6bf5604 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -39,13 +39,13 @@ kiosk_service_templates: user_data_dir: "/opt/chrome/one" extra_chrome_configs: | --user-data-dir=/opt/chrome/one \ - - chrome_resolution: "720,550" + - chrome_resolution: "720,600" chrome_website: "http://127.0.0.1:8081" service_name: chrome_timelapse_control extra_service_configs: "" user_data_dir: "/opt/chrome/two" extra_chrome_configs: | - --window-position="0,410" \ + --window-position="0,450" \ --user-data-dir="/opt/chrome/two" \ create_data_dir: true diff --git a/tasks/main.yaml b/tasks/main.yaml index 2224f53..df5373d 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -14,30 +14,30 @@ ### Bottom Service Control Panel -- name: Install Packages - apt: - name: "{{ item }}" - state: present - loop: "{{ main_packages }}" - -- name: Install ustreamer - include_tasks: ustreamer.yaml - -- name: Install gps_service - include_tasks: gps_service.yaml - -- name: install timelapse service - include_tasks: timelapse.yaml - -- name: Install photo refresh site - include_tasks: photo_refresh.yaml - -- name: Install timelapse service control - include_tasks: service_control.yaml - -- name: Install cosmos autologin user - include_tasks: cosmos_autologin.yaml - +#- name: Install Packages +# apt: +# name: "{{ item }}" +# state: present +# loop: "{{ main_packages }}" +# +#- name: Install ustreamer +# include_tasks: ustreamer.yaml +# +#- name: Install gps_service +# include_tasks: gps_service.yaml +# +#- name: install timelapse service +# include_tasks: timelapse.yaml +# +#- name: Install photo refresh site +# include_tasks: photo_refresh.yaml +# +#- name: Install timelapse service control +# include_tasks: service_control.yaml +# +#- name: Install cosmos autologin user +# include_tasks: cosmos_autologin.yaml +# - name: Set up Chrome Kiosk Services include_tasks: chrome.yaml diff --git a/tasks/service_control.yaml b/tasks/service_control.yaml index 8a7d92c..ea57b0c 100644 --- a/tasks/service_control.yaml +++ b/tasks/service_control.yaml @@ -104,6 +104,12 @@ owner: root group: root + - name: service_control_website - template index.php + template: + src: index-service_control.php.j2 + dest: "{{ service_control_web_folder }}/html/index.php" + mode: 0644 + ############################################### # Start photo_refresh ############################################### diff --git a/files/service_control_api/website/index.php b/templates/index-service_control.php.j2 similarity index 86% rename from files/service_control_api/website/index.php rename to templates/index-service_control.php.j2 index c1bd76d..03b9598 100644 --- a/files/service_control_api/website/index.php +++ b/templates/index-service_control.php.j2 @@ -52,6 +52,30 @@ function runAPI($submitted_status) { return isset($data['Status']) ? $data['Status'] : 'unknown'; } + +function getGPS(){ + if (!file_exists("{{ gps_service_directory }}/gps_data")) { + return "No GPS data available."; + } + try { + $LAT = shell_exec("cat {{ gps_service_directory }}/gps_data | grep lat | cut -d ':' -f 2 | awk '{printf(\"%.5f\n\", $1)}')"); + $LON = shell_exec("cat {{ gps_service_directory }}/gps_data | grep lon | cut -d ':' -f 2 | awk '{printf(\"%.5f\n\", $1)}')"); + $SPEED = floatval(trim(shell_exec("cat {{ gps_service_directory }}/gps_data | grep speed | cut -d ':' -f 2)"))) * 0.62; + } catch (Exception $e) { + return "Failed to parse gps_data: ".$e; + } + + if (is_null($LAT)) { + return "No GPS data available."; + } + if (is_null($LON)) { + return "No GPS data available."; + } + + return $LAT.", ".$LON.", ".$SPEED."mph"; +} + + // Check if the button was clicked via AJAX request // if ($_SERVER['REQUEST_METHOD'] === 'POST') { // $button_recent = true; @@ -166,7 +190,9 @@ if($button_recent){
".htmlspecialchars($message)."

Current Date:
".date("F j, Y, g:i:s a")."

"; + echo "Full Message:
".htmlspecialchars($message)."

"; + echo "Current Date:
".date("F j, Y, g:i:s a")."

"; + echo "Current GPS Data:
".getGPS(); ?>