2 ## This file is part of the sigrok-meter project.
4 ## Copyright (C) 2015 Jens Steinhauser <jens.steinhauser@gmail.com>
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2 of the License, or
9 ## (at your option) any later version.
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, write to the Free Software
18 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 import sigrok
.core
as sr
27 sr
.Unit
.OHM
: u
'\u03A9',
30 sr
.Unit
.CELSIUS
: u
'\u00B0C',
31 sr
.Unit
.FAHRENHEIT
: u
'\u00B0F',
33 sr
.Unit
.PERCENTAGE
: '%',
37 sr
.Unit
.DECIBEL_MW
: 'dBm',
38 sr
.Unit
.DECIBEL_VOLT
: 'dBV',
40 sr
.Unit
.DECIBEL_SPL
: 'dB',
41 # sr.Unit.CONCENTRATION
42 sr
.Unit
.REVOLUTIONS_PER_MINUTE
: 'rpm',
43 sr
.Unit
.VOLT_AMPERE
: 'VA',
45 sr
.Unit
.WATT_HOUR
: 'Wh',
46 sr
.Unit
.METER_SECOND
: 'm/s',
47 sr
.Unit
.HECTOPASCAL
: 'hPa',
48 sr
.Unit
.HUMIDITY_293K
: '%rF',
49 sr
.Unit
.DEGREE
: u
'\u00B0',
53 return units
.get(u
, '')
55 def quantity_from_unit(u
):
57 sr
.Unit
.VOLT
: 'Voltage',
58 sr
.Unit
.AMPERE
: 'Current',
59 sr
.Unit
.OHM
: 'Resistance',
60 sr
.Unit
.FARAD
: 'Capacity',
61 sr
.Unit
.KELVIN
: 'Temperature',
62 sr
.Unit
.CELSIUS
: 'Temperature',
63 sr
.Unit
.FAHRENHEIT
: 'Temperature',
64 sr
.Unit
.HERTZ
: 'Frequency',
65 sr
.Unit
.PERCENTAGE
: 'Duty Cycle',
66 sr
.Unit
.BOOLEAN
: 'Continuity',
67 sr
.Unit
.SECOND
: 'Time',
68 sr
.Unit
.SIEMENS
: 'Conductance',
69 sr
.Unit
.DECIBEL_MW
: 'Power Ratio',
70 sr
.Unit
.DECIBEL_VOLT
: 'Voltage Ratio',
71 sr
.Unit
.UNITLESS
: 'Unitless Quantity',
72 sr
.Unit
.DECIBEL_SPL
: 'Sound Pressure',
73 sr
.Unit
.CONCENTRATION
: 'Concentration',
74 sr
.Unit
.REVOLUTIONS_PER_MINUTE
: 'Revolutions',
75 sr
.Unit
.VOLT_AMPERE
: 'Apparent Power',
76 sr
.Unit
.WATT
: 'Power',
77 sr
.Unit
.WATT_HOUR
: 'Energy',
78 sr
.Unit
.METER_SECOND
: 'Velocity',
79 sr
.Unit
.HECTOPASCAL
: 'Pressure',
80 sr
.Unit
.HUMIDITY_293K
: 'Humidity',
81 sr
.Unit
.DEGREE
: 'Angle',
82 sr
.Unit
.HENRY
: 'Inductance'
85 return quantities
.get(u
, '')