{"action":"created","comment":{"url":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/comments/22834199","id":22834199,"diff_hunk":"@@ -2,52 +2,75 @@\n \n #include \"platform.h\"\n #include \"watchdog.h\"\n-#include \"sensor_defines.h\"\n #include \"port.h\"\n #include \"sample.h\"\n #include \"mib12_api.h\"\n #include \"log.h\"\n #include \"digital_amp.h\"\n #include \"watchdog.h\"\n+#include \"ioc.h\"\n #include \"state.h\"\n #include \"pulse.h\" \n #include \"alarm_repeat_times.h\"\n \n MultiSensorState state;\n+\n extern unsigned int adc_result;\n+extern uint16_t counter;\n+extern uint16_t periods;\n \n void task(void)\n {\n-\twhile (state.acquire_pulse)\n-\t{\n+\twdt_disable();\n+\n+\t//If we slept for an increment, sample the number of pulses\n+\tif (nTO==0)\n \t\tpulse_sample();\n-\t\tstate.acquire_pulse = 0;\n \n-\t\tif ( state.push_pending )\n-\t\t{\n-\t\t\tstate.push_pending = 0;\n+\tif (state.push_pending)\n+\t{\n+\t\tuint16_t correction_factor = 1;\n+\t\tstate.push_pending = 0;\n+\n+\t\t/*\n+\t\t * We report data every minute, and we sample for 0.1 seconds\n+\t\t * per time.  So we need to correct our sampled counter for the\n+\t\t * ratio between the period of time that we are covering (60 seconds)\n+\t\t * and the amount of time we were sampling for (periods*0.1 seconds)\n+\t\t */\n+\n+\t\tif (periods > 0)\n+\t\t\tcorrection_factor = 600/periods;\n+\n+\t\tcounter *= correction_factor;\n \n-\t\t\tbus_master_begin_rpc();\n-\t\t\tmib_buffer[0] = mib_address;\n-\t\t\tmib_buffer[1] = 0;\n+\t\tbus_master_begin_rpc();\n+\t\tmib_buffer[0] = mib_address;\n+\t\tmib_buffer[1] = 0;\n \n-\t\t\tmib_buffer[2] = 0;\n-\t\t\tmib_buffer[3] = 0; //metadata\n+\t\tmib_buffer[2] = 0;\n+\t\tmib_buffer[3] = 0; //metadata\n \n-\t\t\tmib_buffer[4] = pulse_count() & 0xFF;\n-\t\t\tmib_buffer[5] = (pulse_count() >> 8) & 0xFF;\n-\t\t\tmib_buffer[6] = 0;\n-\t\t\tmib_buffer[7] = 0;\n+\t\tmib_buffer[4] = counter & 0xFF;\n+\t\tmib_buffer[5] = counter & 0xFF;\n+\t\tmib_buffer[6] = 0;","path":"momo_modules/multi_sensor_module/src/app_main.c","position":71,"original_position":71,"commit_id":"97f766589e535fa6316de1e768f0e43ddf1fad5e","original_commit_id":"97f766589e535fa6316de1e768f0e43ddf1fad5e","user":{"login":"amcgee","id":947888,"avatar_url":"https://avatars.githubusercontent.com/u/947888?v=3","gravatar_id":"","url":"https://api.github.com/users/amcgee","html_url":"https://github.com/amcgee","followers_url":"https://api.github.com/users/amcgee/followers","following_url":"https://api.github.com/users/amcgee/following{/other_user}","gists_url":"https://api.github.com/users/amcgee/gists{/gist_id}","starred_url":"https://api.github.com/users/amcgee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amcgee/subscriptions","organizations_url":"https://api.github.com/users/amcgee/orgs","repos_url":"https://api.github.com/users/amcgee/repos","events_url":"https://api.github.com/users/amcgee/events{/privacy}","received_events_url":"https://api.github.com/users/amcgee/received_events","type":"User","site_admin":false},"body":"(future enhancement) Eventually the sensor event log API should be intelligent enough to accept a time interval for particular readings from a sensor module.","created_at":"2015-01-13T00:06:51Z","updated_at":"2015-01-13T00:06:51Z","html_url":"https://github.com/WellDone/MoMo-Firmware/pull/158#discussion_r22834199","pull_request_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/158","_links":{"self":{"href":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/comments/22834199"},"html":{"href":"https://github.com/WellDone/MoMo-Firmware/pull/158#discussion_r22834199"},"pull_request":{"href":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/158"}}},"pull_request":{"url":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/158","id":27175465,"html_url":"https://github.com/WellDone/MoMo-Firmware/pull/158","diff_url":"https://github.com/WellDone/MoMo-Firmware/pull/158.diff","patch_url":"https://github.com/WellDone/MoMo-Firmware/pull/158.patch","issue_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/issues/158","number":158,"state":"open","locked":false,"title":"Multisensor Code Ready for Testing","user":{"login":"timburke","id":2424759,"avatar_url":"https://avatars.githubusercontent.com/u/2424759?v=3","gravatar_id":"","url":"https://api.github.com/users/timburke","html_url":"https://github.com/timburke","followers_url":"https://api.github.com/users/timburke/followers","following_url":"https://api.github.com/users/timburke/following{/other_user}","gists_url":"https://api.github.com/users/timburke/gists{/gist_id}","starred_url":"https://api.github.com/users/timburke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timburke/subscriptions","organizations_url":"https://api.github.com/users/timburke/orgs","repos_url":"https://api.github.com/users/timburke/repos","events_url":"https://api.github.com/users/timburke/events{/privacy}","received_events_url":"https://api.github.com/users/timburke/received_events","type":"User","site_admin":false},"body":"I revised and updated the multisensor code.  The current version has changes to make it more robust.  It differs from the previous version in the following ways:\r\n\r\n- It counts the total amount of water that has passed through the flow meter (i.e. it functions as an accumulator).  It does this by sampling the flow rate for 0.1 seconds every 4 seconds.\r\n- It sets up a callback currently every 1 minute to report the accumulated flow in the past minute.  It corrects the flow rate for the fact that it is only sampling 1/40th of the time so it multiplies the count of pulses that it has by the ratio of the total time it's reporting for / its on time.\r\n- It has verified sleep power consumption of 30 uA and run consumption of 4.6 mA.  This is detailed in Issue #112.  The average consumption is ~150 uA, which would translate to almost 300 day runtime (without counting GSM transmission consumption).\r\n\r\nThis is for review, comments and testing.  It needs to be squashed for merging. ","created_at":"2015-01-12T05:12:38Z","updated_at":"2015-01-13T00:06:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0f08eba7ffe24b613054418a2a07e6a15d2d0c4b","assignee":{"login":"amcgee","id":947888,"avatar_url":"https://avatars.githubusercontent.com/u/947888?v=3","gravatar_id":"","url":"https://api.github.com/users/amcgee","html_url":"https://github.com/amcgee","followers_url":"https://api.github.com/users/amcgee/followers","following_url":"https://api.github.com/users/amcgee/following{/other_user}","gists_url":"https://api.github.com/users/amcgee/gists{/gist_id}","starred_url":"https://api.github.com/users/amcgee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amcgee/subscriptions","organizations_url":"https://api.github.com/users/amcgee/orgs","repos_url":"https://api.github.com/users/amcgee/repos","events_url":"https://api.github.com/users/amcgee/events{/privacy}","received_events_url":"https://api.github.com/users/amcgee/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/158/commits","review_comments_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/158/comments","review_comment_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/comments/{number}","comments_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/issues/158/comments","statuses_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/statuses/97f766589e535fa6316de1e768f0e43ddf1fad5e","head":{"label":"timburke:feature-update-multisensor","ref":"feature-update-multisensor","sha":"97f766589e535fa6316de1e768f0e43ddf1fad5e","user":{"login":"timburke","id":2424759,"avatar_url":"https://avatars.githubusercontent.com/u/2424759?v=3","gravatar_id":"","url":"https://api.github.com/users/timburke","html_url":"https://github.com/timburke","followers_url":"https://api.github.com/users/timburke/followers","following_url":"https://api.github.com/users/timburke/following{/other_user}","gists_url":"https://api.github.com/users/timburke/gists{/gist_id}","starred_url":"https://api.github.com/users/timburke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timburke/subscriptions","organizations_url":"https://api.github.com/users/timburke/orgs","repos_url":"https://api.github.com/users/timburke/repos","events_url":"https://api.github.com/users/timburke/events{/privacy}","received_events_url":"https://api.github.com/users/timburke/received_events","type":"User","site_admin":false},"repo":{"id":13351259,"name":"MoMo-Firmware","full_name":"timburke/MoMo-Firmware","owner":{"login":"timburke","id":2424759,"avatar_url":"https://avatars.githubusercontent.com/u/2424759?v=3","gravatar_id":"","url":"https://api.github.com/users/timburke","html_url":"https://github.com/timburke","followers_url":"https://api.github.com/users/timburke/followers","following_url":"https://api.github.com/users/timburke/following{/other_user}","gists_url":"https://api.github.com/users/timburke/gists{/gist_id}","starred_url":"https://api.github.com/users/timburke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timburke/subscriptions","organizations_url":"https://api.github.com/users/timburke/orgs","repos_url":"https://api.github.com/users/timburke/repos","events_url":"https://api.github.com/users/timburke/events{/privacy}","received_events_url":"https://api.github.com/users/timburke/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/timburke/MoMo-Firmware","description":"Embedded PIC Firmware for WellDone Data Logging Well Nozzle.","fork":true,"url":"https://api.github.com/repos/timburke/MoMo-Firmware","forks_url":"https://api.github.com/repos/timburke/MoMo-Firmware/forks","keys_url":"https://api.github.com/repos/timburke/MoMo-Firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/timburke/MoMo-Firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/timburke/MoMo-Firmware/teams","hooks_url":"https://api.github.com/repos/timburke/MoMo-Firmware/hooks","issue_events_url":"https://api.github.com/repos/timburke/MoMo-Firmware/issues/events{/number}","events_url":"https://api.github.com/repos/timburke/MoMo-Firmware/events","assignees_url":"https://api.github.com/repos/timburke/MoMo-Firmware/assignees{/user}","branches_url":"https://api.github.com/repos/timburke/MoMo-Firmware/branches{/branch}","tags_url":"https://api.github.com/repos/timburke/MoMo-Firmware/tags","blobs_url":"https://api.github.com/repos/timburke/MoMo-Firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/timburke/MoMo-Firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/timburke/MoMo-Firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/timburke/MoMo-Firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/timburke/MoMo-Firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/timburke/MoMo-Firmware/languages","stargazers_url":"https://api.github.com/repos/timburke/MoMo-Firmware/stargazers","contributors_url":"https://api.github.com/repos/timburke/MoMo-Firmware/contributors","subscribers_url":"https://api.github.com/repos/timburke/MoMo-Firmware/subscribers","subscription_url":"https://api.github.com/repos/timburke/MoMo-Firmware/subscription","commits_url":"https://api.github.com/repos/timburke/MoMo-Firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/timburke/MoMo-Firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/timburke/MoMo-Firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/timburke/MoMo-Firmware/issues/comments/{number}","contents_url":"https://api.github.com/repos/timburke/MoMo-Firmware/contents/{+path}","compare_url":"https://api.github.com/repos/timburke/MoMo-Firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/timburke/MoMo-Firmware/merges","archive_url":"https://api.github.com/repos/timburke/MoMo-Firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/timburke/MoMo-Firmware/downloads","issues_url":"https://api.github.com/repos/timburke/MoMo-Firmware/issues{/number}","pulls_url":"https://api.github.com/repos/timburke/MoMo-Firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/timburke/MoMo-Firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/timburke/MoMo-Firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/timburke/MoMo-Firmware/labels{/name}","releases_url":"https://api.github.com/repos/timburke/MoMo-Firmware/releases{/id}","created_at":"2013-10-05T19:43:16Z","updated_at":"2014-06-23T16:18:51Z","pushed_at":"2015-01-12T05:06:43Z","git_url":"git://github.com/timburke/MoMo-Firmware.git","ssh_url":"git@github.com:timburke/MoMo-Firmware.git","clone_url":"https://github.com/timburke/MoMo-Firmware.git","svn_url":"https://github.com/timburke/MoMo-Firmware","homepage":null,"size":21981,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"WellDone:dev","ref":"dev","sha":"7ffba890c3073cce820a407226473d7964100a5f","user":{"login":"WellDone","id":1280475,"avatar_url":"https://avatars.githubusercontent.com/u/1280475?v=3","gravatar_id":"","url":"https://api.github.com/users/WellDone","html_url":"https://github.com/WellDone","followers_url":"https://api.github.com/users/WellDone/followers","following_url":"https://api.github.com/users/WellDone/following{/other_user}","gists_url":"https://api.github.com/users/WellDone/gists{/gist_id}","starred_url":"https://api.github.com/users/WellDone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WellDone/subscriptions","organizations_url":"https://api.github.com/users/WellDone/orgs","repos_url":"https://api.github.com/users/WellDone/repos","events_url":"https://api.github.com/users/WellDone/events{/privacy}","received_events_url":"https://api.github.com/users/WellDone/received_events","type":"Organization","site_admin":false},"repo":{"id":5959364,"name":"MoMo-Firmware","full_name":"WellDone/MoMo-Firmware","owner":{"login":"WellDone","id":1280475,"avatar_url":"https://avatars.githubusercontent.com/u/1280475?v=3","gravatar_id":"","url":"https://api.github.com/users/WellDone","html_url":"https://github.com/WellDone","followers_url":"https://api.github.com/users/WellDone/followers","following_url":"https://api.github.com/users/WellDone/following{/other_user}","gists_url":"https://api.github.com/users/WellDone/gists{/gist_id}","starred_url":"https://api.github.com/users/WellDone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WellDone/subscriptions","organizations_url":"https://api.github.com/users/WellDone/orgs","repos_url":"https://api.github.com/users/WellDone/repos","events_url":"https://api.github.com/users/WellDone/events{/privacy}","received_events_url":"https://api.github.com/users/WellDone/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WellDone/MoMo-Firmware","description":"Embedded PIC Firmware and hardware designs for the WellDone Mobile Monitor (MoMo).","fork":false,"url":"https://api.github.com/repos/WellDone/MoMo-Firmware","forks_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/forks","keys_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/teams","hooks_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/hooks","issue_events_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/issues/events{/number}","events_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/events","assignees_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/assignees{/user}","branches_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/branches{/branch}","tags_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/tags","blobs_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/languages","stargazers_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/stargazers","contributors_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/contributors","subscribers_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/subscribers","subscription_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/subscription","commits_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/issues/comments/{number}","contents_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/contents/{+path}","compare_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/merges","archive_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/downloads","issues_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/issues{/number}","pulls_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/labels{/name}","releases_url":"https://api.github.com/repos/WellDone/MoMo-Firmware/releases{/id}","created_at":"2012-09-26T01:44:51Z","updated_at":"2015-01-10T19:48:47Z","pushed_at":"2015-01-10T19:48:47Z","git_url":"git://github.com/WellDone/MoMo-Firmware.git","ssh_url":"git@github.com:WellDone/MoMo-Firmware.git","clone_url":"https://github.com/WellDone/MoMo-Firmware.git","svn_url":"https://github.com/WellDone/MoMo-Firmware","homepage":"welldone.org","size":25740,"stargazers_count":3,"watchers_count":3,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5,"mirror_url":null,"open_issues_count":38,"forks":5,"open_issues":38,"watchers":3,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/158"},"html":{"href":"https://github.com/WellDone/MoMo-Firmware/pull/158"},"issue":{"href":"https://api.github.com/repos/WellDone/MoMo-Firmware/issues/158"},"comments":{"href":"https://api.github.com/repos/WellDone/MoMo-Firmware/issues/158/comments"},"review_comments":{"href":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/158/comments"},"review_comment":{"href":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/WellDone/MoMo-Firmware/pulls/158/commits"},"statuses":{"href":"https://api.github.com/repos/WellDone/MoMo-Firmware/statuses/97f766589e535fa6316de1e768f0e43ddf1fad5e"}}}}