0.1.3 MT8870

This commit is contained in:
rob tillaart 2021-11-09 21:08:49 +01:00
parent cf49df0683
commit 05473b1755
8 changed files with 66 additions and 52 deletions

View File

@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
- leonardo
- due
- zero
# - due
# - zero
# - leonardo
- m4
- esp32
# - esp8266
# - mega2560

View File

@ -4,10 +4,14 @@ name: Arduino CI
on: [push, pull_request]
jobs:
arduino_ci:
runTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Arduino-CI/action@master
# Arduino-CI/action@v0.1.1
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb

View File

@ -1,13 +1,14 @@
//
// FILE: MT8870.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// VERSION: 0.1.3
// DATE: 2019-02-11
// PURPOSE: Arduino library for MT8870 DTMF decoder (breakout)
// URL: https://github.com/RobTillaart/MT8870
// https://www.tinytronics.nl/shop/nl/sensoren/geluid/mt8870-dtmf-module
//
#include "MT8870.h"
@ -20,16 +21,18 @@ void MT8870::begin(uint8_t STQ, uint8_t Q1, uint8_t Q2, uint8_t Q3, uint8_t Q4)
_q[3] = Q4;
for (uint8_t p = 0; p < 4; p++)
{
pinMode(_q[p], INPUT);
pinMode(_q[p], INPUT); // PULLUP ?
}
pinMode(_STQ, INPUT);
}
bool MT8870::available()
{
return (digitalRead(_STQ) == HIGH);
}
char MT8870::read()
{
uint8_t n = readRaw();
@ -37,6 +40,7 @@ char MT8870::read()
return 255;
}
uint8_t MT8870::readRaw()
{
_val = 255;
@ -48,14 +52,10 @@ uint8_t MT8870::readRaw()
if (digitalRead(_q[2]) == HIGH) _val += 0x04;
if (digitalRead(_q[3]) == HIGH) _val += 0x08;
}
_lastTimeRead = millis();
return _val;
}
uint8_t MT8870::lastRaw()
{
return _val;
}
// -- END OF FILE --

View File

@ -2,33 +2,37 @@
//
// FILE: MT8870.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// VERSION: 0.1.3
// DATE: 2019-02-11
// PURPOSE: Arduino library for MT8870 DTMF decoder (breakout)
// URL: https://github.com/RobTillaart/MT8870
// https://www.tinytronics.nl/shop/nl/sensoren/geluid/mt8870-dtmf-module
//
#include "Arduino.h"
#define MT8870_LIB_VERSION "0.1.2"
#define MT8870_LIB_VERSION (F("0.1.3"))
class MT8870
{
public:
// STQ - pin to see if new data arrived
// Q1 - Q4 data pins.
void begin(uint8_t STQ, uint8_t Q1, uint8_t Q2, uint8_t Q3, uint8_t Q4);
void begin(uint8_t STQ, uint8_t Q1, uint8_t Q2, uint8_t Q3, uint8_t Q4);
bool available();
char read();
uint8_t readRaw();
uint8_t lastRaw();
bool available();
char read();
uint8_t readRaw();
uint8_t lastRaw() { return _val; };
uint32_t lastTimeRead() { return _lastTimeRead; };
private:
uint8_t _val = 255;
uint8_t _STQ;
uint8_t _q[4];
uint8_t _val = 255;
uint8_t _STQ;
uint8_t _q[4];
uint32_t _lastTimeRead;
};

View File

@ -1,11 +1,15 @@
[![Arduino CI](https://github.com/RobTillaart/MT8870/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/MT8870/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/MT8870/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/MT8870/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/MT8870/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MT8870/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/MT8870.svg?maxAge=3600)](https://github.com/RobTillaart/MT8870/releases)
# MT8870
Arduino library for MT8870 DTMF decoder (breakout)
Arduino library for MT8870 DTMF decoder (breakout).
## Description
@ -15,29 +19,35 @@ If data is available one can read it raw or as text.
DTMF = Dual Tones Multiple Frequency, it are the tones you
hear when you press buttons on your phone.
A=697 Hz
B=770 Hz
C=852 Hz
D=941 Hz
E=1209 Hz
F=1336 Hz
G=1477 Hz
H=1633 Hz
DTMF tones, uses one from A..D one from E..H.
| Name | Frequency |
|:----:|----------:|
| A | 697 Hz |
| B | 770 Hz |
| C | 852 Hz |
| D | 941 Hz |
| E | 1209 Hz |
| F | 1336 Hz |
| G | 1477 Hz |
| H | 1633 Hz |
## Interface
- **MT8870()** constructor
- **void begin(STQ, Q1, Q2, Q3, Q4)** defines which pins to use.
- **void begin(uint8_t STQ, uint8_t Q1, uint8_t Q2, uint8_t Q3, uint8_t Q4)** defines which pins to use.
Technically it is possible to have readout multiple decoders
with one MT8870 object by calling **begin()** with other pins.
- **STQ** = data available signal
- **Q1..Q4** = datapins
- **Q1..Q4** = data pins.
- Calling begin resets the **lastRead** char
- **bool available()** returns true if there is a DMTF signal
- **char read()** reads the character available. returns 255 if no signal available.
- **uint8_t readRaw()** returns 0 .. 15 or 255 if no signal is available.
- **uint8_t lastRaw()** returns the last code read 0 .. 15 or 255.
- **uint8_t lastRaw()** returns the last code read 0 .. 15 or 255 if no signal available.
Note this is a cached value from a readRaw / read call.
- **uint32_t lastTimeRead()** returns the timestamp of last **read()** or **readRaw()**.
## Future / ideas / improvements
@ -46,18 +56,6 @@ Note this is a cached value from a readRaw / read call.
- DMTF tone generation?
- more examples!
DTMF tones, uses one from A..D one from E..H.
| Name | Frequency |
|:----:|----:|
| A | 697 Hz |
| B | 770 Hz |
| C | 852 Hz |
| D | 941 Hz |
| E | 1209 Hz |
| F | 1336 Hz |
| G | 1477 Hz |
| H | 1633 Hz |
## Operations

View File

@ -1,15 +1,19 @@
# Syntax Coloring Map For MT8870
# Syntax Colouring Map For MT8870
# Datatypes (KEYWORD1)
# Data types (KEYWORD1)
MT8870 KEYWORD1
# Methods and Functions (KEYWORD2)
begin KEYWORD2
available KEYWORD2
read KEYWORD2
readRaw KEYWORD2
lastRead KEYWORD2
lastTime KEYWORD2
# Constants (LITERAL1)
MT8870_LIB_VERSION LITERAL1

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/MT8870.git"
},
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"frameworks": "*",
"platforms": "*"

View File

@ -1,5 +1,5 @@
name=MT8870
version=0.1.2
version=0.1.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for MT8870 DTMF decoder