]> sigrok.org Git - libsigrok.git/commitdiff
radioshack-dmm: Implement support for "LOGIC" mode
authorAlexandru Gagniuc <redacted>
Sat, 20 Oct 2012 01:40:50 +0000 (20:40 -0500)
committerBert Vermeulen <redacted>
Sat, 20 Oct 2012 21:03:51 +0000 (23:03 +0200)
LOGIC mode sends the following data:
     V < 0 : actual voltage
0 <= V < 1 : LOW
1 <= V < 2 : actual voltage
2 <= V     : HIGH

We follow the same idea, and set our unit to BOOLEAN for the crazy
case (HIGH or LOW).

Signed-off-by: Alexandru Gagniuc <redacted>
hardware/radioshack-dmm/radioshack-dmm.h
hardware/radioshack-dmm/radioshack.c

index d206d0fb8f0bca1a17294934935cdd868a1691a6..57bf62fb3994a333532e98608ab652db562823ee 100644 (file)
@@ -71,7 +71,7 @@
 #define RS_22_812_LCD_E
 #define RS_22_812_LCD_F
 #define RS_22_812_LCD_h 0x66
-#define RS_22_812_LCD_H
+#define RS_22_812_LCD_H 0x76
 #define RS_22_812_LCD_I
 #define RS_22_812_LCD_n
 #define RS_22_812_LCD_P 0x37
index 9e05bef794f56b487767e9ed53446e7ff60f6eff..e4fc43cf0fb1b146bf1e05e03c58c2cfd513c6ca 100644 (file)
@@ -215,6 +215,12 @@ static gboolean rs_22_812_is_shortcirc(rs_22_812_packet *rs_packet)
        return((rs_packet->digit2 & ~RS_22_812_DP_MASK) == RS_22_812_LCD_h);
 }
 
+static gboolean rs_22_812_is_logic_high(rs_22_812_packet *rs_packet)
+{
+       sr_spew("digit 2: %x", rs_packet->digit2 & ~RS_22_812_DP_MASK);
+       return((rs_packet->digit2 & ~RS_22_812_DP_MASK) == RS_22_812_LCD_H);
+}
+
 static void rs_22_812_handle_packet(rs_22_812_packet *rs_packet,
                                    rs_dev_ctx *devc)
 {
@@ -281,12 +287,17 @@ static void rs_22_812_handle_packet(rs_22_812_packet *rs_packet,
                analog->unit = SR_UNIT_HERTZ;
                break;
        case RS_22_812_MODE_LOGIC:
-               analog->mq = 0; /* FIXME */
-               analog->unit = SR_UNIT_BOOLEAN;
-               sr_warn("radioshack-dmm: LOGIC mode not supported yet");
-               g_free(analog->data);
-               g_free(analog);
-               return;
+               /* No matter whether or not we have an actual voltage reading,
+                * we are measuring voltage, so we set our MQ as VOLTAGE */
+               analog->mq = SR_MQ_VOLTAGE;
+               if(!isnan(rawval)) {
+                       /* We have an actual voltage */
+                       analog->unit = SR_UNIT_VOLT;
+               } else {
+                       /* We have either HI or LOW */
+                       analog->unit = SR_UNIT_BOOLEAN;
+                       *analog->data = rs_22_812_is_logic_high(rs_packet);
+               }
                break;
        case RS_22_812_MODE_HFE:
                analog->mq = SR_MQ_GAIN;