From 9cc48840872f81e23e82ac30f9eb2e8fe0176991 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Fri, 24 Dec 2021 15:01:25 +0100 Subject: [PATCH] update library.json, license, minor edits (#10) --- LICENSE | 2 +- PulsePattern.cpp | 8 +++--- PulsePattern.h | 26 +++++++++---------- README.md | 2 +- examples/SOS_demo2/SOS_demo2.ino | 3 +-- .../pattern_recorder/pattern_recorder.ino | 1 - examples/pulse_measure/pulse_measure.ino | 13 +++++----- examples/pulse_sender/pulse_sender.ino | 2 -- examples/random_pattern/random_pattern.ino | 2 -- examples/siren_pattern/siren_pattern.ino | 2 -- library.json | 2 +- library.properties | 2 +- test/unit_test_001.cpp_to_avr_specific | 24 ++++++++++++++--- 13 files changed, 48 insertions(+), 41 deletions(-) diff --git a/LICENSE b/LICENSE index b4d74e3..afbcf59 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2012-2021 Rob Tillaart +Copyright (c) 2012-2022 Rob Tillaart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/PulsePattern.cpp b/PulsePattern.cpp index 2a37f71..593e57c 100644 --- a/PulsePattern.cpp +++ b/PulsePattern.cpp @@ -1,7 +1,7 @@ // // FILE: PulsePattern.cpp // AUTHOR: Rob dot Tillaart at gmail dot com -// VERSION: 0.1.3 +// VERSION: 0.1.4 // DATE: 2012-11-23 // PURPOSE: Arduino Library to generate repeating pulse patterns // @@ -10,15 +10,15 @@ // 0.0.2 2012-11-23 adapted a static PPO // 0.0.3 2012-12-27 renamed to PulsePattern // 0.0.4 2012-12-27 code stable(?) enough to publish -// 0.0.5 2012-12-27 code cleanup+comment +// 0.0.5 2012-12-27 code clean up + comment // 0.0.6 2015-04-18 completed the state machine // 0.0.7 2017-07-16 refactor & review // 0.0.8 2018-12-13 refactor -> remove some warnings // 0.1.0 2020-06-19 #pragma once; remove pre 1.0 support; refactor // 0.1.1 2020-07-04 add continue function, fix spaces. // 0.1.2 2020-08-07 speed up toggle pin + get/setFactor() -// 0.1.3 2021-01-06 arduino-ci (no unit test) - +// 0.1.3 2021-01-06 Arduino-CI (no unit test) +// 0.1.4 2021-12-24 update library.json, license, minor edits #include "PulsePattern.h" diff --git a/PulsePattern.h b/PulsePattern.h index bea0f04..4fca43e 100644 --- a/PulsePattern.h +++ b/PulsePattern.h @@ -2,7 +2,7 @@ // // FILE: PulsePattern.h // AUTHOR: Rob dot Tillaart at gmail dot com -// VERSION: 0.1.3 +// VERSION: 0.1.4 // DATE: 2012-11-23 // PURPOSE: Arduino Library to generate repeating pulse patterns // sends a pulse pattern to a digital pin (continuously) @@ -17,22 +17,22 @@ #include "Arduino.h" -#define PULSEPATTERN_LIB_VERSION (F("0.1.3")) +#define PULSEPATTERN_LIB_VERSION (F("0.1.4")) -#define NOTINIT -1 -#define STOPPED 0 -#define RUNNING 1 +#define NOTINIT -1 +#define STOPPED 0 +#define RUNNING 1 -#define NO_CLOCK 0 // timer off -#define PRESCALE_1 1 -#define PRESCALE_8 2 -#define PRESCALE_64 3 -#define PRESCALE_256 4 -#define PRESCALE_1024 5 -#define EXT_T1_FALLING 6 // external clock -#define EXT_T2_RISING 7 // external clock +#define NO_CLOCK 0 // timer off +#define PRESCALE_1 1 +#define PRESCALE_8 2 +#define PRESCALE_64 3 +#define PRESCALE_256 4 +#define PRESCALE_1024 5 +#define EXT_T1_FALLING 6 // external clock +#define EXT_T2_RISING 7 // external clock class PulsePattern diff --git a/README.md b/README.md index 6ea1f7c..3f17a76 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ or other non-AVR processors. The library uses timer1 for the timing of the pulses. Therefore the class is implemented with a static instance called PPO. Still by calling **init()** one can change all parameters of the process. -One should note that calling init() forces the timer to stop. +One should note that calling **init()** forces the timer to stop. The timer code is based upon the website of Nick Gammon which holds quite a lot of good solid material (Thanks Nick!). diff --git a/examples/SOS_demo2/SOS_demo2.ino b/examples/SOS_demo2/SOS_demo2.ino index aac3d4d..d7eb6c0 100644 --- a/examples/SOS_demo2/SOS_demo2.ino +++ b/examples/SOS_demo2/SOS_demo2.ino @@ -2,7 +2,6 @@ // FILE: SOS_demo2.ino // AUTHOR: Rob Tillaart // DATE: 2012-11-23 -// // PURPOSE: demo of the PulsePattern Library // uses timer1 @@ -13,7 +12,7 @@ // a pattern consists of durations of LOW and HIGH periods // so the first line of the SOSpattern is // 500 units LOW, 500 units HIGH etc -// for a dutycycle of 50% LOW and HIGH should have equal periods +// for a duty cycle of 50% LOW and HIGH should have equal periods // NOTE max period = 4095. // min period = about 12 uint16_t SOSpattern[] = diff --git a/examples/pattern_recorder/pattern_recorder.ino b/examples/pattern_recorder/pattern_recorder.ino index 9a11536..1bdb42a 100644 --- a/examples/pattern_recorder/pattern_recorder.ino +++ b/examples/pattern_recorder/pattern_recorder.ino @@ -1,7 +1,6 @@ // // FILE: pattern_recorder.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 // PURPOSE: records and writes a pattern to serial // DATE: 2020-07-25 diff --git a/examples/pulse_measure/pulse_measure.ino b/examples/pulse_measure/pulse_measure.ino index ef8fe77..8b7b3ab 100644 --- a/examples/pulse_measure/pulse_measure.ino +++ b/examples/pulse_measure/pulse_measure.ino @@ -1,29 +1,28 @@ // // FILE: pulse_measure.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 // PURPOSE: measure pulselength // DATE: 2020-08-07 - +// // TEST -// - generate with one Arduino a pulse of 1000 ms -// - measure it with this sketch to determine the correction percentage +// generate with one Arduino a pulse of 1000 ms +// measure it with this sketch to determine the correction percentage #include "Arduino.h" // measure pin = A5 on UNO -uint8_t pin = 19; +uint8_t pin = 19; -// record pulses in units of 10 milliseconds +// record pulses in units of 10 milliseconds // an a minimum duration of 20 miiliseconds. uint16_t minDuration = 20; uint16_t units = 10; // to calc the average -uint32_t count = 0; +uint32_t count = 0; uint32_t sum = 0; diff --git a/examples/pulse_sender/pulse_sender.ino b/examples/pulse_sender/pulse_sender.ino index 04085a9..4ca24f4 100644 --- a/examples/pulse_sender/pulse_sender.ino +++ b/examples/pulse_sender/pulse_sender.ino @@ -2,11 +2,9 @@ // FILE: pulse_sender.ino // AUTHOR: Rob Tillaart // DATE: 2020-08-08 -// // PURPOSE: for calibrating the pulse length // uses timer1 // - // This sketch sends a test pattern of 1000 ms LOW and 1000 ms HIGH ==> Duty Cycle = 50% // From measuring the duration of the pulses one can derive the correction factor to adjust the timing. // diff --git a/examples/random_pattern/random_pattern.ino b/examples/random_pattern/random_pattern.ino index 37b71e7..5b9aebe 100644 --- a/examples/random_pattern/random_pattern.ino +++ b/examples/random_pattern/random_pattern.ino @@ -2,10 +2,8 @@ // FILE: random_pattern.ino // AUTHOR: Rob Tillaart // DATE: 2020-07-04 -// // PURPOSE: demo of the PulsePattern Library // uses timer1 -// #include "PulsePattern.h" diff --git a/examples/siren_pattern/siren_pattern.ino b/examples/siren_pattern/siren_pattern.ino index cdc02bc..b299403 100644 --- a/examples/siren_pattern/siren_pattern.ino +++ b/examples/siren_pattern/siren_pattern.ino @@ -2,10 +2,8 @@ // FILE: siren_pattern.ino // AUTHOR: Rob Tillaart // DATE: 2012-11-23 -// // PURPOSE: demo of the PulsePattern Library // uses timer1 -// #include "PulsePattern.h" diff --git a/library.json b/library.json index f0d5acb..42ea8bb 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/PulsePattern.git" }, - "version": "0.1.3", + "version": "0.1.4", "license": "MIT", "frameworks": "arduino", "platforms": "avr", diff --git a/library.properties b/library.properties index 94804a8..9058702 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=PulsePattern -version=0.1.3 +version=0.1.4 author=Rob Tillaart maintainer=Rob Tillaart sentence=Library to generate repeating pulse patterns. (AVR only) diff --git a/test/unit_test_001.cpp_to_avr_specific b/test/unit_test_001.cpp_to_avr_specific index eb211bc..b643e95 100644 --- a/test/unit_test_001.cpp_to_avr_specific +++ b/test/unit_test_001.cpp_to_avr_specific @@ -47,6 +47,7 @@ uint8_t startLevel = LOW; unittest_setup() { + fprintf(stderr, "PULSEPATTERN_LIB_VERSION: %s\n", (char *) PULSEPATTERN_LIB_VERSION); } unittest_teardown() @@ -54,10 +55,27 @@ unittest_teardown() } -unittest(test_constructor) +unittest(test_constants) { - fprintf(stderr, "VERSION: %s\n", PULSEPATTERN_LIB_VERSION); + fprintf(stderr, "status\n"); + assertEqual(NOTINIT, -1); + assertEqual(STOPPED, 0); + assertEqual(RUNNING, 1); + + fprintf(stderr, "\nprescaler\n"); + assertEqual(NO_CLOCK , 0); + assertEqual(PRESCALE_1 , 1); + assertEqual(PRESCALE_8 , 2); + assertEqual(PRESCALE_64 , 3); + assertEqual(PRESCALE_256 , 4); + assertEqual(PRESCALE_1024 , 5); + assertEqual(EXT_T1_FALLING, 6); + assertEqual(EXT_T2_RISING , 7); +} + +unittest(test_constructor) +{ PPGenerator.init(13, pattern, patternSize, startLevel, PRESCALE_1024); assertFalse(PPGenerator.isRunning()); @@ -79,8 +97,6 @@ unittest(test_constructor) unittest(test_setFactor) { - fprintf(stderr, "VERSION: %s\n", PULSEPATTERN_LIB_VERSION); - PPGenerator.init(13, pattern, patternSize, startLevel, PRESCALE_1024); PPGenerator.setFactor(42.42);