0.2.2 M62429

This commit is contained in:
rob tillaart 2021-05-28 13:36:28 +02:00
parent 7ec18f1fec
commit 806402e1c7
4 changed files with 20 additions and 6 deletions

View File

@ -2,7 +2,7 @@
// FILE: M62429.cpp
// AUTHOR: Rob Tillaart
// PURPOSE: Arduino library for M62429 volume control IC
// VERSION: 0.2.1
// VERSION: 0.2.2
// HISTORY: See M62429.cpp2
// URL: https://github.com/RobTillaart/M62429
@ -10,6 +10,8 @@
// 0.1.0 2019-01-17 initial version
// 0.2.0 2020-08-02 refactor
// 0.2.1 2020-12-30 add arduino-ci + unit test
// 0.2.2 2021-05-27 fix library.properties
#include "M62429.h"
@ -27,12 +29,14 @@ void M62429::begin(uint8_t dataPin, uint8_t clockPin)
setVolume(2, 0);
}
int M62429::getVolume(uint8_t channel)
{
if (channel > 2) return M62429_CHANNEL_ERROR;
return _vol[channel & 1];
}
int M62429::setVolume(uint8_t channel, uint8_t volume)
{
if (channel > 2) return M62429_CHANNEL_ERROR;
@ -49,6 +53,7 @@ int M62429::setVolume(uint8_t channel, uint8_t volume)
return 0;
}
void M62429::incr()
{
if (_vol[0] < 255) _vol[0]++;
@ -57,6 +62,7 @@ void M62429::incr()
setVolume(1, _vol[1]);
}
void M62429::decr()
{
if (_vol[0] > 0) _vol[0]--;
@ -65,6 +71,7 @@ void M62429::decr()
setVolume(1, _vol[1]);
}
void M62429::average()
{
uint8_t v = (((int)_vol[0]) + _vol[1]) / 2;
@ -72,12 +79,14 @@ void M62429::average()
setVolume(1, v);
}
void M62429::muteOn()
{
_muted = true;
setVolume(2, 0);
}
void M62429::muteOff()
{
_muted = false;

View File

@ -3,14 +3,17 @@
// FILE: M62429.h
// AUTHOR: Rob Tillaart
// PURPOSE: Arduino library for M62429 volume control IC
// VERSION: 0.2.1
// VERSION: 0.2.2
//
// HISTORY: See M62429.cpp
// URL: https://github.com/RobTillaart/M62429
#include "Arduino.h"
#define M62429_VERSION "0.2.1"
#define M62429_VERSION (F("0.2.2"))
// minimum pulswidth CLOCK = 1.6 us (datasheet);
// digitalWrite takes enough time on UNO / AVR so clock_delay == 0
@ -23,6 +26,7 @@
#endif
#endif
// ERROR CODES
#define M62429_MUTED -1
#define M62429_CHANNEL_ERROR -10

View File

@ -15,7 +15,8 @@
"type": "git",
"url": "https://github.com/RobTillaart/M62429.git"
},
"version":"0.2.1",
"version": "0.2.2",
"license": "MIT",
"frameworks": "*",
"platforms": "*"
}

View File

@ -1,10 +1,10 @@
name=M62429
version=0.2.1
version=0.2.2
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for M62429 volume control IC
paragraph=M62429 == FM62429
category=Uncategorized
category=Data Processing
url=https://github.com/RobTillaart/M62429
architectures=*
includes=M62429.h