mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #17569 from chrysn-pull-requests/unit-tesla
phydat: Add Tesla unit
This commit is contained in:
commit
07a4756242
@ -97,6 +97,7 @@ enum {
|
||||
UNIT_V, /**< Volts */
|
||||
UNIT_W, /**< Watt */
|
||||
UNIT_GS, /**< gauss */
|
||||
UNIT_T, /**< Tesla */
|
||||
UNIT_DBM, /**< decibel-milliwatts */
|
||||
UNIT_COULOMB, /**< coulomb */
|
||||
UNIT_F, /**< Farad */
|
||||
|
@ -114,6 +114,7 @@ const char *phydat_unit_to_str(uint8_t unit)
|
||||
case UNIT_W: return "W";
|
||||
case UNIT_DBM: return "dBm";
|
||||
case UNIT_GS: return "Gs";
|
||||
case UNIT_T: return "T";
|
||||
case UNIT_BAR: return "Bar";
|
||||
case UNIT_PA: return "Pa";
|
||||
case UNIT_PERMILL: return "permille";
|
||||
|
@ -45,6 +45,7 @@ _phydat_test_t _test_vector[] =
|
||||
{ .dim = 1, .dat = { .val = { 12345 }, .unit = UNIT_V, .scale = 6 } },
|
||||
{ .dim = 1, .dat = { .val = { 12345 }, .unit = UNIT_W, .scale = 7 } },
|
||||
{ .dim = 1, .dat = { .val = { 12345 }, .unit = UNIT_GS, .scale = -1 } },
|
||||
{ .dim = 3, .dat = { .val = { 123, 456, 789 }, .unit = UNIT_T, .scale = -9 } },
|
||||
{ .dim = 1, .dat = { .val = { 12345 }, .unit = UNIT_DBM, .scale = -3 } },
|
||||
{ .dim = 1, .dat = { .val = { 12345 }, .unit = UNIT_COULOMB, .scale = 0 } },
|
||||
{ .dim = 1, .dat = { .val = { 12345 }, .unit = UNIT_F, .scale = -6 } },
|
||||
|
@ -44,6 +44,9 @@ def testfunc(child):
|
||||
child.expect(r'Data:\t 12345 MV\r\n')
|
||||
child.expect(r'Data:\t 12345e7 W\r\n')
|
||||
child.expect(r'Data:\t 1234.5 Gs\r\n')
|
||||
child.expect(r'Data:\t\[0\] 123 nT\r\n')
|
||||
child.expect(r'\t\[1\] 456 nT\r\n')
|
||||
child.expect(r'\t\[2\] 789 nT\r\n')
|
||||
child.expect(r'Data:\t 12.345 dBm\r\n')
|
||||
child.expect(r'Data:\t 12345 C\r\n')
|
||||
child.expect(r'Data:\t 12345 uF\r\n')
|
||||
|
@ -212,6 +212,7 @@ static void test_unitstr__success(void)
|
||||
TEST_ASSERT_EQUAL_STRING("W", phydat_unit_to_str_verbose(UNIT_W));
|
||||
TEST_ASSERT_EQUAL_STRING("dBm", phydat_unit_to_str_verbose(UNIT_DBM));
|
||||
TEST_ASSERT_EQUAL_STRING("Gs", phydat_unit_to_str_verbose(UNIT_GS));
|
||||
TEST_ASSERT_EQUAL_STRING("T", phydat_unit_to_str_verbose(UNIT_T));
|
||||
TEST_ASSERT_EQUAL_STRING("Bar", phydat_unit_to_str_verbose(UNIT_BAR));
|
||||
TEST_ASSERT_EQUAL_STRING("Pa", phydat_unit_to_str_verbose(UNIT_PA));
|
||||
TEST_ASSERT_EQUAL_STRING("permille", phydat_unit_to_str_verbose(UNIT_PERMILL));
|
||||
|
Loading…
Reference in New Issue
Block a user