diff --git a/Firmware/platformio/.vscode/extensions.json b/Firmware/platformio/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/Firmware/platformio/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/Firmware/platformio/include/README b/Firmware/platformio/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/Firmware/platformio/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/Firmware/platformio/lib/README b/Firmware/platformio/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/Firmware/platformio/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/Firmware/platformio/platformio.ini b/Firmware/platformio/platformio.ini index 1f6356e..258ac1b 100644 --- a/Firmware/platformio/platformio.ini +++ b/Firmware/platformio/platformio.ini @@ -8,6 +8,10 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html +; PlatformIO uses [framework-arduino-avr-attiny](https://github.com/SpenceKonde/ATTinyCore) +; More development info to be found on https://github.com/SpenceKonde/ATTinyCore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_x5.md + + [env:attiny45] platform = atmelavr board = attiny45 diff --git a/Firmware/platformio/src/pins.h b/Firmware/platformio/src/pins.h new file mode 100644 index 0000000..3531bd4 --- /dev/null +++ b/Firmware/platformio/src/pins.h @@ -0,0 +1,6 @@ +#pragma once + +#include "Arduino.h" + +const int PIN_DTMF_OUT = 0; // ATtiny45.pin5 +const int PIN_MODE_SELECT = 2; // ATtiny45.pin7 \ No newline at end of file diff --git a/Firmware/platformio/src/pulse-dtmf-converter.ino b/Firmware/platformio/src/pulse-dtmf-converter.ino index 6f62ff8..23cf0b0 100644 --- a/Firmware/platformio/src/pulse-dtmf-converter.ino +++ b/Firmware/platformio/src/pulse-dtmf-converter.ino @@ -1,28 +1,57 @@ -#include "dtmfgenerator.h" -#include "rotarydialer.h" +/* +pulse-dtmf-converter: application to converted pulse-dialing to DTMF-tones +Copyright (C) 2018 Christoph Tack + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +/* + * By pulling pin 7 of the ATtiny45, you can select to send a dtmf tone after each digit, or send them all at once after the last digit has been dialed. + * 0: (pin 7 = LOW) - tone after each digit + * 1: (pin 7 HIGH, default) gather all digits then send tones + */ + +/* +2023-02-20 Christoph Tack : + * Correcting buffer size of pulseBuffer. It overflowed the amount of RAM + * Turn the amount of time between last dialed digit and start of DTMF-sequence into a configurable constant. + * Migrate toolchain to PlatformIO. (build succeeds, but not tested onto the target). The header files have been left in the src folder for ease of use for people using the Arduino IDE. +*/ + #include #include +#include "dtmfgenerator.h" +#include "rotarydialer.h" +#include "pins.h" DtmfGenerator dtmf; -RotaryDialer rd(0); // pin5 +RotaryDialer rd(PIN_DTMF_OUT); -const int modePin = 2; // pin7 - -int mode = 1; // 0: (modePin LOW) original - tone after each digit - // 1: (modePin HIGH) gather all digits then send tones -const bool REVERSE_DIAL_MODE = false; // set to true for reverse dial systems (e.g. in use on New-Zealand) +const bool REVERSE_DIAL_MODE = false; // set to true for reverse dial systems (e.g. in use on New-Zealand) +const int DTMF_DELAY_AFTER_LAST_DIALED_DIGIT_ms = 1200; //wait this after last dialed digit before sending DTMF sequence. +const int MAX_NR_OF_DIALED_DIGITS = 15; //your longest phone number should be shorter than this value. unsigned long lastUpdate = 0; byte pulsesCtr = 0; -byte pulsesBuffer[200]; +byte pulsesBuffer[MAX_NR_OF_DIALED_DIGITS]; +int mode = 0; // select when to send DTMF tones (see explanation above) + void setup() { - pinMode(modePin, INPUT_PULLUP); - if (digitalRead(modePin) == LOW) - { - mode = 0; - } + pinMode(PIN_MODE_SELECT, INPUT_PULLUP); + mode = digitalRead(PIN_MODE_SELECT) == LOW ? 0 : 1; reducePower(); dtmf.init(); @@ -61,10 +90,10 @@ void loop() } else { - if (rd.available()) + if (rd.available() && pulsesCtr < MAX_NR_OF_DIALED_DIGITS) { pulsesBuffer[pulsesCtr++] = rd.readPulses(); - lastUpdate = millis() + 3000; + lastUpdate = millis() + DTMF_DELAY_AFTER_LAST_DIALED_DIGIT_ms; } if ((pulsesCtr > 0) && (millis() > lastUpdate)) { diff --git a/Firmware/platformio/test/README b/Firmware/platformio/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/Firmware/platformio/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/Hardware/Gerber_BRD170127R1.zip b/Hardware/Gerber_BRD170127R1.zip new file mode 100644 index 0000000..00d8c49 Binary files /dev/null and b/Hardware/Gerber_BRD170127R1.zip differ diff --git a/Hardware/Schematic_BRD170127R1.pdf b/Hardware/Schematic_BRD170127R1.pdf new file mode 100644 index 0000000..5609364 Binary files /dev/null and b/Hardware/Schematic_BRD170127R1.pdf differ