Quantcast
Jump to content

Use Tizen Web To Measure Heart Rate With Galaxy Watches


STF News
 Share

Recommended Posts

Health monitoring is a very popular feature in smart watches, and Tizen provides various APIs for this purpose. One API is HumanActivityMonitor, which allows users to monitor health by providing metrics such as heart rate, step count, and stress level.

This blog describes how to measure heart rate using this API. A sample web app combined with a widget is attached. This sample app measures heart rate and stores data by timestamp, and the widget shows the last measured heart rate. This blog focuses on how to measure heart rate using the device sensor, stored data, and communication between an app and a widget.

Create and run a Tizen project

1. Create a project in Tizen Studio. Because our target is an app that is combined with a widget, select the Widget template to create this project.

1.png

2. Add the Tizen Advanced UI (TAU) framework library to your project. You can create and manage various UI functionalities using the TAU library as an alternative to designing a UI with HTML and CSS components.

3. Link the tau.circle.min.css and tau.min.js in the app’s index.html file.

<link rel="stylesheet"
href="lib/tau/wearable/theme/default/tau.min.css"> 
<link rel="stylesheet" media="all and (-tizen-geometric-shape: circle)"
href="lib/tau/wearable/theme/default/tau.circle.min.css">
<script src="lib/tau/wearable/js/tau.min.js"> </script>

Measure heart rate and manage data

To measure heart rate using the HumanActivityMonitor API, add the following feature and privilege to the config.xml file:

<feature name="http://tizen.org/feature/humanactivitymonitor"/>
<tizen:privilege name="http://tizen.org/privilege/healthinfo"/>

Applications must request a user’s permission for privacy-related features. The tizen.ppm.requestPermission() method invokes the permission pop-up. When users give permission through the pop-up, they can then use the app features related to that privilege.

To measure heart rate, users must give permission to access the sensor using the following code snippet:

function onSuccess() {

    function onchangedCB(hrmInfo) {
        console.log(‘heart rate:’ + hrmInfo.heartRate);
        tizen.humanactivitymonitor.stop('HRM');
    }
    tizen.humanactivitymonitor.start('HRM', onchangedCB);
}

function onError(e) {
    console.log("error " + JSON.stringify(e));
}
tizen.ppm.requestPermission("http://tizen.org/privilege/healthinfo",onSuccess, onError);

Note that the HumanActivityMonitor API provides heart rate data directly in BPM (beats per minute). If you need the raw data of the sensor, you can use SensorHRMRawData.

The following screenshots show how to measure heart rate using the sample app:

2.png

The Web Storage API stores data in key-value format. This API offers two types of storage – Local and Session. In the sample, we use local storage, along with Date as key and heartRate as value. The Date key retrieves data according to date, week, and month. If you do not want to retrieve history according to date, you can use a different key, such as an integer value; just make sure there is no repetition in key value.

Create a Date object to get the current time stamp. localStorage.setItem() puts the key (Date)-value (heartRate) pair in local storage.

var date_key = new Date();
localStorage.setItem(date_key, hrmInfo.heartRate);

To retrieve data, filter according to the key. Date and month are retrieved from the Date object and filter data using localStorage.getItem(localStorage.key(i)).

var date = new Date();
var lastdate = new Date(localStorage.key(i));
if (lastdate.getDate() == date.getDate() 
&& lastdate.getMonth() == date.getMonth()) {
              console.log(localStorage.key(i)+ " :" + localStorage.getItem(localStorage.key(i)));

The following screenshots show how the history is categorized by day, week, and month:

31.png

Communication between the app and a widget

The sample widget shows the last measured heart rate value, and heart rate history is stored in the local storage of the web app. To establish communication between the app and widget, we’ll use the Preference API. The Preference API stores key-pair values, allowing web widgets to communicate with their parent apps.
In the app, data is stored with ‘KEY’:

tizen.preference.setValue('KEY', hrmInfo.heartRate);

In the widget, data is retrieved using the same ‘KEY’:

if (tizen.preference.exists('KEY')) {
    console.log(‘Last Measured: ‘ + tizen.preference.getValue('KEY'));
} 

The following screenshot of the sample widget shows the last measured heart rate:

4.png

Launch the app from a widget

To launch an app from widget, add the following privilege to config.xml:

<tizen:privilege 
name="http://tizen.org/privilege/application.launch"/>

To launch an app, provide your app ID in tizen.application.launch().

tizen.application.launch(YourAppID);

In the sample widget, the user taps Measure to launch the heart-rate measuring page or History to launch the heart-rate history page, and Preference can be used to determine which one is clicked. To implement, a different key-value pair is set for each page in the widget, and in the web app, key values are checked to detect which page is clicked.

5.png

For example, in the widget, the open_measure key is set to 1 to link to the Measure Page. The app then launches.

tizen.preference.setValue(‘open_measure’, 1);
tizen.application.launch(YourAppID);

The app checks for the open_measure key. If the key exists, the user is redirected to the Measure Page with tau.changePage().

window.onload = function() {
    if (tizen.preference.exists(' open_measure ')) {
        tau.changePage(YourPageID);
    }
}

You can also use the HumanActivityMonitor API to implement a step counter, stress level reading, GPS, and other features in your wearable device. Because enabling other features is similar to implementing the heart rate monitor, you can use this blog as a guide and the attached sampleHeartRateMonitor to enable a full range of health monitoring metrics to your Galaxy Watch.

View the full blog at its source

Link to comment
Share on other sites



  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Similar Topics

    • By BGR
      After the Galaxy S22 throttling disaster involving the Exynos 2200 chip earlier this year, we saw Samsung apologize to customers and investors. The company faced plenty of criticism and scrutiny, especially in its home market. Then, Samsung vowed to create a new set of flagship chips for its best phones. But the Galaxy S23 series that launches next year will probably run on Qualcomm’s latest Snapdragon processor.
      It’s all speculation at this point, but based on a significant announcement from Samsung and Qualcomm that claims the Korean giant will use more Snapdragon chips in its smartphones.
      Exynos is a major disappointment
      Samsung Exynos System-on-Chips (SoC) have never been able to match their Qualcomm counterparts, let alone outperform the iPhone. But Samsung kept using both Exynos and Snapdragon chips in its Galaxy S flagships for years. 
      The Exynos 2200 is the last such flagship Samsung-made chip, powering Galaxy S22 variants sold in certain markets. And the Exynos 2200 might be the final nail in the Exynos coffin. At least until Samsung reshuffles its chips teams and develops a new processor for high-end phones. The Galaxy S23 might come only in a Qualcomm Snapdragon variant as a result.

      As soon as the Galaxy S22 series came out, buyers discovered the Exynos 2200 processor would reduce performance to conserve battery life. This was more aggressive than on previous phones, implying the chip is prone to overheating when under heavy stress.
      The Exynos 2200 isn’t the first Samsung SoC to see criticism from buyers. Even Samsung mocked its previous Exynos variants last year while promoting the Exynos 2100. That was a chip that was supposed to fix all of the previous overheating and performance issues.
      Galaxy Z Fold 4 press image leak. Image source: 91mobiles/Evan Blass Galaxy S23 likely to be a Qualcomm-only affair
      During the Galaxy Z Fold 4 and Flip 4 rumors season, we learned the new foldables would come with Snapdragon chips inside. The phones would get the brand new Snapdragon 8 Plus Gen 1 SoC, leaks said. The 8 Plus Gen 1 is even more powerful and efficient than the 8 Gen 1 SoC that powers some Galaxy S22 variants.
      That meant the new Fold and Flip will not suffer the same throttling issues at the hand of the Exynos 2200. Or any version of it.
      Samsung, by the way, also mass-produced the 8 Gen 1 chip variant. But Qualcomm moved to TSMC for the 8 Plus Gen 1 SoC.
      Fast-forward to late July, and Qualcomm and Snapdragon issued a joint announcement. The two companies said they’ll extend their patent licensing agreement for seven years through 2030. More importantly, the announcement says that Snapdragon Platforms will power future Samsung Galaxy devices. The list includes “smartphones, PCs, tablets, extended reality, and more,” the press release says.
      Qualcomm didn’t list the Galaxy S23 as a beneficiary of the upcoming Snapdragon chips. But considering the context, it certainly seems like Snapdragon is a much better choice for Samsung’s future flagship. A report from an insider said earlier this month that Samsung would move to a Snapdragon-only strategy for the Galaxy S23 series.
      Also, we shouldn’t be surprised to see Samsung use only Snapdragon flagship SoCs in future flagships beyond the Galaxy S23. As much as Samsung might want to make a high-end chip of its own that can compete with Apple’s iPhone and Mac chips and Qualcomm’s Snapdragons, it won’t happen overnight.
      The post Galaxy S23 to feature Qualcomm’s newest Snapdragon processor appeared first on BGR.
      View the full article
    • By BGR
      The Galaxy S23 Ultra might feature a 200-megapixel primary camera, says an insider familiar with Samsung’s plans. Similar sensors are already in use or will come on other Android flagships. And it so happens that Samsung has a few Isocell sensors with 200 megapixels. But Ice Universe says it’s unclear which sensor will end up in the upcoming Galaxy S23 Ultra that will be released next year.
      Ice Universe often leaks details about unreleased Samsung devices on Twitter. While it might seem too early for Galaxy S23 Ultra rumors, the leaker already shared some camera specs on social media.
      He posted the image below, which reportedly comes from an upcoming Motorola flagship phone. The primary camera is a 200-megapixel sensor that the leaker identifies as HP1. That’s short for Isocell HP1, a 200-megapixel sensor that Samsung unveiled last year.
      In this context, Ice claimed that the Galaxy S23 Ultra will also feature a 200-megapixel sensor. However, it’s unclear which sensor Samsung will employ for its upcoming flagship. The HP1 isn’t the latest camera innovation from Samsung, as the company has an updated HP3 200-megapixel sensor in production.
      The leaker is also very vocal on Twitter when it comes to criticizing what he perceives as Samsung’s failures when it comes to mobile devices. He criticized the Galaxy S22 processor’s performance and One UI features in the past. More recently, he addressed issues with the Galaxy S22 camera’s performance.
      Samsung Isocell HP1 camera tech. Image source: Samsung Do phones need 200-megapixel sensors?
      Unlike its early days in the smartphone business, Samsung no longer increases the camera megapixel count on its smartphones just for the sake of bragging about specs. The Galaxy S20 Ultra came with a 108-megapixel sensor three years ago, but the upgrade was walked back with the Ultra’s larger camera setup. The Galaxy S22 Ultra also rocks a 108-megapixel wide-angle camera.
      If Ice’s claims are correct, the Galaxy S23 Ultra might be the first Galaxy S flagship to get a 200-megapixel camera.
      Samsung unveiled the Isocell HP1 sensor last year without specifying which smartphones would get the 200-megapixel camera. We now know Samsung never meant to use the camera on its 2022 flagships.
      A few weeks ago, Samsung unveiled the HP3 camera, which is also a 200-megapixel sensor. The video below explains the benefits of the sensor.
      In short, these cameras will improve resolution in well-lit environments. But they will automatically combine pixels and reduce the overall resolution to improve low-light and night photography.
      The HP3 sensor should deliver improved autofocus and better HDR algorithms. Moreover, Samsung also says the Isocell HP3 camera will support 8K video recording at up to 30fps.
      That said, the Isocell HP3 might not be the 200-megapixel camera that Samsung uses for the Galaxy S23 Ultra next year. Instead, Samsung might tweak it to create a custom version for the upcoming flagship. But that’s just speculation at this point.
      The Galaxy S23 series should launch in early 2023. By then, all of the camera specs will have leaked and we’ll know exactly what sort of camera experience Samsung plans to offer.
      The post Galaxy S23 Ultra to feature a 200-megapixel camera, insider claims appeared first on BGR.
      View the full article
    • By STF News
      View the full blog at its source
    • By BGR
      The Galaxy S22 might be the most exciting flagship series Samsung made, but it’s also marred by various controversies and issues. Chief among them is the throttling problem that impacted primarily Exynos 2200 versions of the Galaxy S22 in Korea and Europe. Samsung fixed the problem quickly, but the Galaxy S22 performance issues turned into a massive scandal in Korea, impacting sales. A new rumor now claims the Galaxy S22 FE will switch to MediaTek’s flagship System-on-Chip (SoC) offerings.
      Assuming the rumor is accurate, the Galaxy S22 might be the first Samsung flagship to pack a MediaTek processor. And the chip will likely replace Qualcomm or Exynos. The latter seems like the more likely victim considering the Galaxy S22 throttling issues.
      Don't Miss: Tuesday’s deals: $99 AirPods, $230 Apple Watch SE, Gillette sale, more Is there a Galaxy S22 FE phone?
      Several weeks before Samsung unveiled the Galaxy S22 series, the Galaxy S21 FE finally arrived. At the time, we told you that it might be better to hold off your purchase until the S22 rolled out.
      The cheaper Galaxy S21 FE delivered 2021 specs and a few compromises that let Samsung cut the phone’s price. The Galaxy S22 would offer better specs, with prices unchanged compared to its predecessor. Little did we know at the time that the Galaxy S22 would disappoint with the various issues Samsung had to deal with.
      Considering what has happened so far, it might make sense to see Samsung release a Galaxy S22 FE this year to “fix” the Galaxy S22 problems. Like last year, Samsung is yet to confirm the Galaxy S22’s Fan Edition. And in 2021, Samsung considered canceling the release, according to rumors. Samsung denied those reports, but it moved the Galaxy S21 FE release from summer 2021 to early 2022.
      Samsung Galaxy S22 Plus smartphone. Image source: Samsung The big MediaTek switch
      A new report from Business Korea name-checks the Galaxy S22 FE, claiming the phone will roll out in the second half of the year. Strangely enough, the blog also says the Galaxy S23 flagship will roll out in the second half of 2022, which must be a mistake in detailing Samsung’s purported plans for this year.
      Release dates aside, the blog notes that Samsung will use MediaTek’s System-on-Chip (SoC) for about half of the Galaxy S22 FE models and the Galaxy S23 phones sold in Asia. Samsung has only used MediaTek chips for its more affordable handsets in the past. This would be the first time Samsung goes for the top MediaTek SoC.
      Business Korea doesn’t say which SoC brand the MediaTek chip in the Galaxy S22 FE will replace. But the implication is that it’s the Exynos 2200 flagship. The report notes that Samsung is having a hard time promoting its SoC. And it so happens that the Galaxy S22 throttling issues have been spotted and fixed in Korea and Europe.
      The specs of MediaTek Dimensity 9000 flagship processor. Image source: MediaTek Will the Dimensity 9000 power the Galaxy S22 FE?
      MediaTek released the Dimenisity 9000 flagship SoC in mid-November 2019. At the time, we noted that MediaTek’s new chip achieved many “world firsts” in the industry and that it could be the kind of SoC that goes against the iPhone 13’s A15 Bionic.
      More interestingly, MediaTek mentioned Samsung among the Android vendors that will use the Dimenisity 9000 SoC. This was well before the Galaxy S21 FE and Galaxy S22 launch events. And it was several months before the Galaxy S22 throttling scandal.
      The Galaxy S22 performance issues were so significant in Korea that Samsung had to deal with them during its most recent shareholders meeting. Samsung apologized for the problem and said it hasn’t been cutting corners when designing the Galaxy S22.
      Pundits speculated that Samsung had to throttle performance to prevent the Galaxy S22 from overheating by running at peak capacity. Using the SoC at its max potential for a more extended period would also hurt the battery life. And they said Samsung did that so it could cut production costs.
      The Galaxy S22 phones will still throttle performance even after the fix is rolled out. But the user can at least have a say on when that throttling starts.
      Considering all that, the MediaTek high-end SoC might help Samsung deliver a better fix to its Galaxy S22 performance problem. After all, MediaTek teased that Samsung will use the Dimensity 9000 this year.
      The post Galaxy S22 FE might feature MediaTek’s flagship processor, rumor claims appeared first on BGR.
      View the full article
    • By SAMSUNG
      Enjoy an enhanced viewing experience with Neo QLED 8K. Its game-changing display technology brings you a step closer to reality through your TV screens. Greatness never ends, but evolves. #NeoQLED8K #SamsungTV



×
×
  • Create New...