Skip to content

Commit 3e49477

Browse files
committed
v1.1
1 parent 02bd15b commit 3e49477

File tree

5 files changed

+27
-28
lines changed

5 files changed

+27
-28
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ void loop() {
9494
<a id="versions"></a>
9595
## Версии
9696
- v1.0
97+
- v1.1 - переделан FastIO
9798

9899
<a id="feedback"></a>
99100
## Баги и обратная связь

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SoftServo
2-
version=1.0
2+
version=1.1
33
author=AlexGyver <[email protected]>
44
maintainer=AlexGyver <[email protected]>
55
sentence=Library for software servo motor control (by system timer)

src/FastIO.h renamed to src/FastIO_v2.cpp

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
// Быстрый IO для AVR (для остальных будет digitalxxxxx)
2-
// v1.0
1+
#include "FastIO_v2.h"
32

4-
#ifndef FastIO_h
5-
#define FastIO_h
6-
#include <Arduino.h>
7-
8-
bool fastRead(const uint8_t pin); // быстрое чтение пина
9-
void fastWrite(const uint8_t pin, bool val); // быстрая запись
10-
uint8_t fastShiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); // быстрый shiftIn
11-
void fastShiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t data); // быстрый shiftOut
12-
13-
// ================================================================
14-
bool fastRead(const uint8_t pin) {
3+
bool F_fastRead(const uint8_t pin) {
154
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
165
if (pin < 8) return bitRead(PIND, pin);
176
else if (pin < 14) return bitRead(PINB, pin - 8);
@@ -32,8 +21,7 @@ bool fastRead(const uint8_t pin) {
3221
return 0;
3322
}
3423

35-
36-
void fastWrite(const uint8_t pin, bool val) {
24+
void F_fastWrite(const uint8_t pin, bool val) {
3725
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
3826
if (pin < 8) bitWrite(PORTD, pin, val);
3927
else if (pin < 14) bitWrite(PORTB, (pin - 8), val);
@@ -56,8 +44,7 @@ void fastWrite(const uint8_t pin, bool val) {
5644
#endif
5745
}
5846

59-
60-
uint8_t fastShiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
47+
uint8_t F_fastShiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
6148
#if defined(AVR)
6249
volatile uint8_t *_clk_port = portOutputRegister(digitalPinToPort(clockPin));
6350
volatile uint8_t *_dat_port = portInputRegister(digitalPinToPort(dataPin));
@@ -81,8 +68,7 @@ uint8_t fastShiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
8168
#endif
8269
}
8370

84-
85-
void fastShiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t data) {
71+
void F_fastShiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t data) {
8672
#if defined(AVR)
8773
volatile uint8_t *_clk_port = portOutputRegister(digitalPinToPort(clockPin));
8874
volatile uint8_t *_dat_port = portOutputRegister(digitalPinToPort(dataPin));
@@ -104,6 +90,4 @@ void fastShiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t d
10490
#else
10591
shiftOut(dataPin, clockPin, bitOrder, data);
10692
#endif
107-
}
108-
109-
#endif
93+
}

src/FastIO_v2.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Быстрый IO для AVR (для остальных будет digitalxxxxx)
2+
// v1.0
3+
4+
#ifndef _FastIO_v2_h
5+
#define _FastIO_v2_h
6+
#include <Arduino.h>
7+
8+
bool F_fastRead(const uint8_t pin); // быстрое чтение пина
9+
void F_fastWrite(const uint8_t pin, bool val); // быстрая запись
10+
uint8_t F_fastShiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); // быстрый shiftIn
11+
void F_fastShiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t data); // быстрый shiftOut
12+
13+
#endif

src/SoftServo.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
1616
Версии:
1717
v1.0 - релиз
18+
v1.1 - переделан FastIO
1819
*/
1920

2021
#ifndef SoftServo_h
2122
#define SoftServo_h
2223
#include <Arduino.h>
23-
#include "FastIO.h"
24+
#include "FastIO_v2.h"
2425

2526
class SoftServo {
2627
public:
@@ -56,19 +57,19 @@ class SoftServo {
5657
if (!_flag) {
5758
_tmrUs = micros();
5859
_flag = 1;
59-
fastWrite(_pin, 1);
60+
F_fastWrite(_pin, 1);
6061
} else {
6162
if (micros() - _tmrUs >= _us) {
62-
fastWrite(_pin, 0);
63+
F_fastWrite(_pin, 0);
6364
_flag = 0;
6465
_tmr50 = millis();
6566
} else return true;
6667
}
6768
} else {
6869
_tmr50 = millis();
69-
fastWrite(_pin, 1);
70+
F_fastWrite(_pin, 1);
7071
delayMicroseconds(_us);
71-
fastWrite(_pin, 0);
72+
F_fastWrite(_pin, 0);
7273
}
7374
}
7475
return false;

0 commit comments

Comments
 (0)