From: Alexandru Gagniuc Date: Sat, 20 Oct 2012 01:40:50 +0000 (-0500) Subject: radioshack-dmm: Implement support for "LOGIC" mode X-Git-Tag: dsupstream~655 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7c41dc477402c09141c5d478dff493f8efb81264;p=libsigrok.git radioshack-dmm: Implement support for "LOGIC" mode 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 --- diff --git a/hardware/radioshack-dmm/radioshack-dmm.h b/hardware/radioshack-dmm/radioshack-dmm.h index d206d0fb..57bf62fb 100644 --- a/hardware/radioshack-dmm/radioshack-dmm.h +++ b/hardware/radioshack-dmm/radioshack-dmm.h @@ -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 diff --git a/hardware/radioshack-dmm/radioshack.c b/hardware/radioshack-dmm/radioshack.c index 9e05bef7..e4fc43cf 100644 --- a/hardware/radioshack-dmm/radioshack.c +++ b/hardware/radioshack-dmm/radioshack.c @@ -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;