open-degu / USER_COMMUNITY

Deguの使い方に関する疑問を投稿、回答するためのIssueを提供しています。
4 stars 2 forks source link

BMP280 & BME280 Example Code Use of Strings as Output Format #34

Closed alanp-sporelab closed 4 years ago

alanp-sporelab commented 4 years ago

BMP280 example code produces text as opposed to numbers for the temperature and barometric pressure, which just requires additional downstream manipulation to be able to be used in graphing packages (like Kibana).

Unless there’s a compelling reason not to, would make it a bit easier for new users to just convert into human readable numbers in the first place instead of splitting into integer and decimal placings.

Seems that most other example codes just use numbers.

BME 280:

   @property
    def values(self):
        """ human readable values """

        t, p, h = self.read_compensated_data()

        p = p // 256
        pi = p // 100
        pd = p - pi * 100

        hi = h // 1024
        hd = h * 100 // 1024 - hi * 100
        return ("{}".format(t / 100), "{}.{:02d}".format(pi, pd),
                "{}.{:02d}".format(hi, hd))

BMP 280:

    @property
    def values(self):
        """ human readable values """

        t, p, h = self.read_compensated_data()

        p = p // 256
        pi = p // 100
        pd = p - pi * 100

        hi = h // 1024
        hd = h * 100 // 1024 - hi * 100
        return ("{}".format(t / 100), "{}.{:02d}".format(pi, pd),
                "{}.{:02d}".format(hi, hd))
yoshidam-at commented 4 years ago

This issue fixed on pull request #41. Please check and close this issue.

How to update from v0.9.x to v1.0.0-rc1, see Degu v0.9.xからv1.0.0-rc1移行ガイド.