GY-63_MS5611/libraries/M62429/README.md

70 lines
3.0 KiB
Markdown
Raw Normal View History

2021-01-29 06:31:58 -05:00
[![Arduino CI](https://github.com/RobTillaart/M62429/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
2021-12-21 06:50:11 -05:00
[![Arduino-lint](https://github.com/RobTillaart/M62429/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/M62429/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/M62429/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/M62429/actions/workflows/jsoncheck.yml)
2021-01-29 06:31:58 -05:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/M62429/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/M62429.svg?maxAge=3600)](https://github.com/RobTillaart/M62429/releases)
2021-12-21 06:50:11 -05:00
2021-01-29 06:31:58 -05:00
# M62429
2021-12-21 06:50:11 -05:00
Arduino library for M62429 volume control IC.
2021-01-29 06:31:58 -05:00
## Description
This library is used to set the attenuation (volume) of the
M62429 IC a.k.a. FM62429.
The communication needs a minimum delay of 1.6 microseconds.
This is defined in the library in **M62429_CLOCK_DELAY** == 2
For AVR (UNO, slow device) it is defined as 0, as the digitalWrite
takes time enough.
For faster processors this define can be overruled runtime by setting it
2021-12-21 06:50:11 -05:00
before including "M62429.h" or by defining it as command line parameter.
2021-01-29 06:31:58 -05:00
## Interface
The interface is straightforward
2021-12-21 06:50:11 -05:00
- **void begin(uint8_t dataPin, uint8_t clockPin)** defines the clock and data pin.
2021-01-29 06:31:58 -05:00
One has to create one object per IC.
2021-12-21 06:50:11 -05:00
- **int getVolume(uint8_t channel)** channel is 0 or 1 or 2 (both). In the latter
2021-01-29 06:31:58 -05:00
case the volume of channel 0 is used as volume of both channels.
2021-12-21 06:50:11 -05:00
- **int setVolume(uint8_t channel, uint8_t volume)**
2021-01-29 06:31:58 -05:00
channel = { 0, 1, 2 = both; volume = {0 .. 255 }
2021-12-21 06:50:11 -05:00
- **void incr()** increment volume of both channels until max is reached.
2021-01-29 06:31:58 -05:00
This is another way to set volume that is better suited for a rotary
encoder or a \[+\] button
2021-12-21 06:50:11 -05:00
- **void decr()** decrement volume of both channels until 0 is reached. See **incr()**.
- **void average()** averages the 2 channels to same = average level.
2021-01-29 06:31:58 -05:00
Sort of set balance in the middle functionality.
2021-12-21 06:50:11 -05:00
- **void muteOn()** silences both channels but remembers the volume..
2021-01-29 06:31:58 -05:00
GetVolume() will return the 'saved' volume value.
2021-12-21 06:50:11 -05:00
- **void muteOff()** resets the volume per channel again.
- **bool isMuted()** returns the muted state.
## Operation
See examples
2021-01-29 06:31:58 -05:00
## Future
- Control multiple M62429 IC's with one class. This could work with one
2021-12-21 06:50:11 -05:00
shared dataPin and one clockPin per IC. An idea might be to use one PCF8575
to have 1 dataPin and 15 clockPins. That would allow for 15 stereo channels
2021-01-29 06:31:58 -05:00
or 30 mono channels. Runtime configuration mono / stereo would be cool.
- model with one **volume(0..100%)** and one **balance(-100..100)**.
Also a **left()** and **right()** incremental balance might be added.
This could work better than 2 separate volume channels.
- change **getVolume(both)** to return max of the two channels?
- **muteOff()** should increase gradually.
- **Mute()** could be per channel, default = both / all.
2021-12-21 06:50:11 -05:00
- **mute50()** reduces levels with 50% (rounded down?).
2021-01-29 06:31:58 -05:00
- find a big can filled with time ...