]> sigrok.org Git - libsigrok.git/blobdiff - hardware/common/dmm/fs9721.c
Centralise duplicated logging helper defines.
[libsigrok.git] / hardware / common / dmm / fs9721.c
index ccf16a3250b80192726b915ff4b4af94b5c4411b..9b195d0bc5d479702bef37875bf0d79bc4c19afb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * This file is part of the sigrok project.
+ * This file is part of the libsigrok project.
  *
  * Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de>
  * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
 #include "libsigrok.h"
 #include "libsigrok-internal.h"
 
-/* Message logging helpers with driver-specific prefix string. */
-#define DRIVER_LOG_DOMAIN "fs9721: "
-#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
-#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
+#define LOG_PREFIX "fs9721"
 
 static int parse_digit(uint8_t b)
 {
@@ -306,6 +299,8 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
                analog->mqflags |= SR_MQFLAG_DC;
        if (info->is_auto)
                analog->mqflags |= SR_MQFLAG_AUTORANGE;
+       if (info->is_diode)
+               analog->mqflags |= SR_MQFLAG_DIODE;
        if (info->is_hold)
                analog->mqflags |= SR_MQFLAG_HOLD;
        if (info->is_rel)
@@ -326,11 +321,6 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
                sr_spew("User-defined LCD symbol 3 is active.");
 }
 
-SR_PRIV gboolean sr_fs9721_is_packet_start(uint8_t b)
-{
-       return (((b >> 4) & 0x0f) == 0x01);
-}
-
 SR_PRIV gboolean sr_fs9721_packet_valid(const uint8_t *buf)
 {
        struct fs9721_info info;
@@ -373,3 +363,61 @@ SR_PRIV int sr_fs9721_parse(const uint8_t *buf, float *floatval,
 
        return SR_OK;
 }
+
+SR_PRIV void sr_fs9721_00_temp_c(struct sr_datafeed_analog *analog, void *info)
+{
+       struct fs9721_info *info_local;
+
+       info_local = (struct fs9721_info *)info;
+
+       /* User-defined FS9721_LP3 flag 'c2c1_00' means temperature (C). */
+       if (info_local->is_c2c1_00) {
+               analog->mq = SR_MQ_TEMPERATURE;
+               analog->unit = SR_UNIT_CELSIUS;
+       }
+}
+
+SR_PRIV void sr_fs9721_01_temp_c(struct sr_datafeed_analog *analog, void *info)
+{
+       struct fs9721_info *info_local;
+
+       info_local = (struct fs9721_info *)info;
+
+       /* User-defined FS9721_LP3 flag 'c2c1_01' means temperature (C). */
+       if (info_local->is_c2c1_01) {
+               analog->mq = SR_MQ_TEMPERATURE;
+               analog->unit = SR_UNIT_CELSIUS;
+       }
+}
+
+SR_PRIV void sr_fs9721_10_temp_c(struct sr_datafeed_analog *analog, void *info)
+{
+       struct fs9721_info *info_local;
+
+       info_local = (struct fs9721_info *)info;
+
+       /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature (C). */
+       if (info_local->is_c2c1_10) {
+               analog->mq = SR_MQ_TEMPERATURE;
+               analog->unit = SR_UNIT_CELSIUS;
+       }
+}
+
+SR_PRIV void sr_fs9721_01_10_temp_f_c(struct sr_datafeed_analog *analog, void *info)
+{
+       struct fs9721_info *info_local;
+
+       info_local = (struct fs9721_info *)info;
+
+       /* User-defined FS9721_LP3 flag 'c2c1_01' means temperature (F). */
+       if (info_local->is_c2c1_01) {
+               analog->mq = SR_MQ_TEMPERATURE;
+               analog->unit = SR_UNIT_FAHRENHEIT;
+       }
+
+       /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature (C). */
+       if (info_local->is_c2c1_10) {
+               analog->mq = SR_MQ_TEMPERATURE;
+               analog->unit = SR_UNIT_CELSIUS;
+       }
+}