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, see <http://www.gnu.org/licenses/>.
20 import sigrok
.core
as sr
26 sr
.Unit
.OHM
: u
'\u03A9',
29 sr
.Unit
.CELSIUS
: u
'\u00B0C',
30 sr
.Unit
.FAHRENHEIT
: u
'\u00B0F',
32 sr
.Unit
.PERCENTAGE
: '%',
36 sr
.Unit
.DECIBEL_MW
: 'dBm',
37 sr
.Unit
.DECIBEL_VOLT
: 'dBV',
39 sr
.Unit
.DECIBEL_SPL
: 'dB',
40 # sr.Unit.CONCENTRATION
41 sr
.Unit
.REVOLUTIONS_PER_MINUTE
: 'rpm',
42 sr
.Unit
.VOLT_AMPERE
: 'VA',
44 sr
.Unit
.WATT_HOUR
: 'Wh',
45 sr
.Unit
.METER_SECOND
: 'm/s',
46 sr
.Unit
.HECTOPASCAL
: 'hPa',
47 sr
.Unit
.HUMIDITY_293K
: '%rF',
48 sr
.Unit
.DEGREE
: u
'\u00B0',
52 return units
.get(u
, '')
54 def quantity_from_unit(u
):
56 sr
.Unit
.VOLT
: 'Voltage',
57 sr
.Unit
.AMPERE
: 'Current',
58 sr
.Unit
.OHM
: 'Resistance',
59 sr
.Unit
.FARAD
: 'Capacity',
60 sr
.Unit
.KELVIN
: 'Temperature',
61 sr
.Unit
.CELSIUS
: 'Temperature',
62 sr
.Unit
.FAHRENHEIT
: 'Temperature',
63 sr
.Unit
.HERTZ
: 'Frequency',
64 sr
.Unit
.PERCENTAGE
: 'Duty Cycle',
65 sr
.Unit
.BOOLEAN
: 'Continuity',
66 sr
.Unit
.SECOND
: 'Time',
67 sr
.Unit
.SIEMENS
: 'Conductance',
68 sr
.Unit
.DECIBEL_MW
: 'Power Ratio',
69 sr
.Unit
.DECIBEL_VOLT
: 'Voltage Ratio',
70 sr
.Unit
.UNITLESS
: 'Unitless Quantity',
71 sr
.Unit
.DECIBEL_SPL
: 'Sound Pressure',
72 sr
.Unit
.CONCENTRATION
: 'Concentration',
73 sr
.Unit
.REVOLUTIONS_PER_MINUTE
: 'Revolutions',
74 sr
.Unit
.VOLT_AMPERE
: 'Apparent Power',
75 sr
.Unit
.WATT
: 'Power',
76 sr
.Unit
.WATT_HOUR
: 'Energy',
77 sr
.Unit
.METER_SECOND
: 'Velocity',
78 sr
.Unit
.HECTOPASCAL
: 'Pressure',
79 sr
.Unit
.HUMIDITY_293K
: 'Humidity',
80 sr
.Unit
.DEGREE
: 'Angle',
81 sr
.Unit
.HENRY
: 'Inductance'
84 return quantities
.get(u
, '')