MODIF - Address definition to easily allow choosing the 3 address bit
	MODIF - DPOT_* definitions to DS1803_*
twiLCD:
	MODIF - Address definition to easily allow choosing the 3 address bit

git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@6 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b
master
mlalondesvn 17 years ago
parent d6932f2222
commit 835bc100b5

@ -21,9 +21,9 @@ DS1803 DPOT = DS1803();
void DS1803::setWiper(uint8_t value, uint8_t wiperAddr)
{
if (!Wire.checkAddress(DPOT_WADDR)) return;
if (!Wire.checkAddress(DS1803_WADDR)) return;
Wire.beginTransmission(DPOT_WADDR);
Wire.beginTransmission(DS1803_WADDR);
Wire.send(wiperAddr); // Send the wiper address
Wire.send(value);
@ -33,9 +33,9 @@ void DS1803::setWiper(uint8_t value, uint8_t wiperAddr)
/*
uint8_t DS1803::getValue()
{
if (!Wire.checkAddress(DPOT_WADDR)) return;
if (!Wire.checkAddress(DS1803_WADDR)) return;
Wire.requestFrom(DPOT_RADDR, 2);
Wire.requestFrom(DS1803_RADDR, 2);
while (Wire.available()) {
Serial.println((uint8_t)Wire.receive(), DEC);

@ -3,27 +3,36 @@
#include <inttypes.h>
#define DPOT_WADDR 0x28
#define DPOT_RADDR DPOT_WADDR | 0x01
/**
* Address byte selection
* Select 0 for low and 1 for high
**/
#define DS1803_A0 0
#define DS1803_A1 0
#define DS1803_A2 0
#define DS1803_BASE_ADDR B00101000
#define DS1803_WADDR DS1803_BASE_ADDR | (DS1803_A0 * B00000001) | (DS1803_A1 * B00000010) | (DS1803_A2 * B00000100)
#define DS1803_RADDR DS1803_WADDR | 0x01
/**
* The number of available potentiometer wipers
**/
#define DPOT_NBR_WIPERS 0x02
#define DS1803_NBR_WIPERS 0x02
/**
* Digital pot selection commands
**/
#define DPOT_WIPERS B10101111
#define DPOT_WIPER_0 B10101001
#define DPOT_WIPER_1 B10101010
#define DS1803_WIPERS B10101111
#define DS1803_WIPER_0 B10101001
#define DS1803_WIPER_1 B10101010
/**
* Macros
**/
#define setWiper1(value) setWiper(value, DPOT_WIPER_0)
#define setWiper2(value) setWiper(value, DPOT_WIPER_1)
#define setWipers(value) setWiper(value, DPOT_WIPERS)
#define setWiper1(value) setWiper(value, DS1803_WIPER_0)
#define setWiper2(value) setWiper(value, DS1803_WIPER_1)
#define setWipers(value) setWiper(value, DS1803_WIPERS)
/**
* DS1803 I2C Dual Digital Pot.

@ -5,7 +5,16 @@
#include "../configs/LCD/lcd.h"
#include "twiLCDConfig.h"
#define PCF8574_WADDR 0x20
/**
* Address byte selection
* Select 0 for low and 1 for high
**/
#define PCF8574_A0 0
#define PCF8574_A1 0
#define PCF8574_A2 0
#define PCF8574_BASE_ADDR B00100000
#define PCF8574_WADDR PCF8574_BASE_ADDR | (PCF8574_A0 * B00000001) | (PCF8574_A1 * B00000010) | (PCF8574_A2 * B00000100)
#define PCF8574_RADDR PCF8574_WADDR | 0x01
#define TWI_LCD_RS 0 /* RS pin */

Loading…
Cancel
Save