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 <mr.nuke.me@gmail.com>
This commit is contained in:
Alexandru Gagniuc 2012-10-19 20:40:50 -05:00 committed by Bert Vermeulen
parent dfd8f56ef4
commit 7c41dc4774
2 changed files with 18 additions and 7 deletions

View 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

View 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 */
/* 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;
sr_warn("radioshack-dmm: LOGIC mode not supported yet");
g_free(analog->data);
g_free(analog);
return;
*analog->data = rs_22_812_is_logic_high(rs_packet);
}
break;
case RS_22_812_MODE_HFE:
analog->mq = SR_MQ_GAIN;