Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
54e58bcf
Commit
54e58bcf
authored
Mar 24, 2022
by
Eric Duminil
Browse files
Avoid name conflict
parent
7e48d847
Changes
3
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
54e58bcf
...
...
@@ -18,7 +18,7 @@ namespace config {
}
#if defined(ESP8266)
# include "src/lib/Esp8266EdgeSoftwareSerial/SoftwareSerial.h"
# include "src/lib/Esp8266EdgeSoftwareSerial/
My
SoftwareSerial.h"
# define S8_RX_PIN 13 // GPIO13, a.k.a. D7, connected to S8 Tx pin.
# define S8_TX_PIN 15 // GPIO15, a.k.a. D8, connected to S8 Rx pin.
SoftwareSerial
S8_serial
(
S8_RX_PIN
,
S8_TX_PIN
);
...
...
ampel-firmware/src/lib/Esp8266EdgeSoftwareSerial/SoftwareSerial.cpp
→
ampel-firmware/src/lib/Esp8266EdgeSoftwareSerial/
My
SoftwareSerial.cpp
View file @
54e58bcf
/*
SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
My
SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
Copyright (c) 2015-2016 Peter Lerup. All rights reserved.
This library is free software; you can redistribute it and/or
...
...
@@ -27,13 +27,13 @@ extern "C" {
#include
"gpio.h"
}
#include
"SoftwareSerial.h"
#include
"
My
SoftwareSerial.h"
#define MAX_PIN 15
// As the Arduino attachInterrupt has no parameter, lists of objects
// and callbacks corresponding to each possible GPIO pins have to be defined
SoftwareSerial
*
ObjList
[
MAX_PIN
+
1
];
My
SoftwareSerial
*
ObjList
[
MAX_PIN
+
1
];
void
ICACHE_RAM_ATTR
sws_isr_0
()
{
ObjList
[
0
]
->
rxRead
();
};
void
ICACHE_RAM_ATTR
sws_isr_1
()
{
ObjList
[
1
]
->
rxRead
();
};
...
...
@@ -68,7 +68,7 @@ static void(*ISRList[MAX_PIN + 1])() = {
sws_isr_15
};
SoftwareSerial
::
SoftwareSerial
(
int
receivePin
,
int
transmitPin
,
bool
inverse_logic
,
unsigned
int
buffSize
,
bool
edge_triggered
)
{
My
SoftwareSerial
::
My
SoftwareSerial
(
int
receivePin
,
int
transmitPin
,
bool
inverse_logic
,
unsigned
int
buffSize
,
bool
edge_triggered
)
{
m_oneWire
=
(
receivePin
==
transmitPin
);
m_rxValid
=
m_txValid
=
m_txEnableValid
=
false
;
m_buffer
=
NULL
;
...
...
@@ -99,7 +99,7 @@ SoftwareSerial::SoftwareSerial(int receivePin, int transmitPin, bool inverse_log
begin
(
9600
);
}
SoftwareSerial
::~
SoftwareSerial
()
{
My
SoftwareSerial
::~
My
SoftwareSerial
()
{
enableRx
(
false
);
if
(
m_rxValid
)
ObjList
[
m_rxPin
]
=
NULL
;
...
...
@@ -107,11 +107,11 @@ SoftwareSerial::~SoftwareSerial() {
free
(
m_buffer
);
}
bool
SoftwareSerial
::
isValidGPIOpin
(
int
pin
)
{
bool
My
SoftwareSerial
::
isValidGPIOpin
(
int
pin
)
{
return
(
pin
>=
0
&&
pin
<=
5
)
||
(
pin
>=
12
&&
pin
<=
MAX_PIN
);
}
void
SoftwareSerial
::
begin
(
long
speed
)
{
void
My
SoftwareSerial
::
begin
(
long
speed
)
{
// Use getCycleCount() loop to get as exact timing as possible
m_bitTime
=
F_CPU
/
speed
;
// By default enable interrupt during tx only for low speed
...
...
@@ -121,11 +121,11 @@ void SoftwareSerial::begin(long speed) {
enableRx
(
true
);
}
long
SoftwareSerial
::
baudRate
()
{
long
My
SoftwareSerial
::
baudRate
()
{
return
F_CPU
/
m_bitTime
;
}
void
SoftwareSerial
::
setTransmitEnablePin
(
int
transmitEnablePin
)
{
void
My
SoftwareSerial
::
setTransmitEnablePin
(
int
transmitEnablePin
)
{
if
(
isValidGPIOpin
(
transmitEnablePin
))
{
m_txEnableValid
=
true
;
m_txEnablePin
=
transmitEnablePin
;
...
...
@@ -137,11 +137,11 @@ void SoftwareSerial::setTransmitEnablePin(int transmitEnablePin) {
}
}
void
SoftwareSerial
::
enableIntTx
(
bool
on
)
{
void
My
SoftwareSerial
::
enableIntTx
(
bool
on
)
{
m_intTxEnabled
=
on
;
}
void
SoftwareSerial
::
enableTx
(
bool
on
)
{
void
My
SoftwareSerial
::
enableTx
(
bool
on
)
{
if
(
m_oneWire
&&
m_txValid
)
{
if
(
on
)
{
enableRx
(
false
);
...
...
@@ -157,7 +157,7 @@ void SoftwareSerial::enableTx(bool on) {
}
}
void
SoftwareSerial
::
enableRx
(
bool
on
)
{
void
My
SoftwareSerial
::
enableRx
(
bool
on
)
{
if
(
m_rxValid
)
{
if
(
on
)
{
if
(
m_edge
)
...
...
@@ -171,14 +171,14 @@ void SoftwareSerial::enableRx(bool on) {
}
}
int
SoftwareSerial
::
read
()
{
int
My
SoftwareSerial
::
read
()
{
if
(
!
m_rxValid
||
(
m_inPos
==
m_outPos
))
return
-
1
;
uint8_t
ch
=
m_buffer
[
m_outPos
];
m_outPos
=
(
m_outPos
+
1
)
%
m_buffSize
;
return
ch
;
}
int
SoftwareSerial
::
available
()
{
int
My
SoftwareSerial
::
available
()
{
if
(
!
m_rxValid
)
return
0
;
int
avail
=
m_inPos
-
m_outPos
;
if
(
avail
<
0
)
avail
+=
m_buffSize
;
...
...
@@ -187,7 +187,7 @@ int SoftwareSerial::available() {
#define WAIT { while (ESP.getCycleCount()-start < wait) if (m_intTxEnabled) optimistic_yield(1); wait += m_bitTime; }
size_t
SoftwareSerial
::
write
(
uint8_t
b
)
{
size_t
My
SoftwareSerial
::
write
(
uint8_t
b
)
{
if
(
!
m_txValid
)
return
0
;
if
(
m_invert
)
b
=
~
b
;
...
...
@@ -215,22 +215,22 @@ size_t SoftwareSerial::write(uint8_t b) {
return
1
;
}
void
SoftwareSerial
::
flush
()
{
void
My
SoftwareSerial
::
flush
()
{
m_inPos
=
m_outPos
=
0
;
}
bool
SoftwareSerial
::
overflow
()
{
bool
My
SoftwareSerial
::
overflow
()
{
bool
res
=
m_overflow
;
m_overflow
=
false
;
return
res
;
}
int
SoftwareSerial
::
peek
()
{
int
My
SoftwareSerial
::
peek
()
{
if
(
!
m_rxValid
||
(
m_inPos
==
m_outPos
))
return
-
1
;
return
m_buffer
[
m_outPos
];
}
inline
bool
SoftwareSerial
::
propgateBits
(
bool
level
,
int
pulseBitLength
)
inline
bool
My
SoftwareSerial
::
propgateBits
(
bool
level
,
int
pulseBitLength
)
{
for
(
int
i
=
0
;
i
<
pulseBitLength
;
i
++
)
{
...
...
@@ -247,12 +247,12 @@ inline bool SoftwareSerial::propgateBits(bool level, int pulseBitLength)
return
false
;
}
inline
void
SoftwareSerial
::
setWaitingForStart
()
inline
void
My
SoftwareSerial
::
setWaitingForStart
()
{
m_getByteState
=
awaitingStart
;
}
inline
void
SoftwareSerial
::
setStartBit
(
unsigned
long
start
)
inline
void
My
SoftwareSerial
::
setStartBit
(
unsigned
long
start
)
{
// mark - the start of a pulse
// set the timers and wait for the next pulse
...
...
@@ -263,7 +263,7 @@ inline void SoftwareSerial::setStartBit(unsigned long start)
m_getByteState
=
gotStart
;
}
void
ICACHE_RAM_ATTR
SoftwareSerial
::
rxRead
()
{
void
ICACHE_RAM_ATTR
My
SoftwareSerial
::
rxRead
()
{
// Advance the starting point for the samples but compensate for the
// initial delay which occurs before the interrupt is delivered
unsigned
long
wait
=
m_bitTime
+
m_bitTime
/
3
-
500
;
...
...
ampel-firmware/src/lib/Esp8266EdgeSoftwareSerial/SoftwareSerial.h
→
ampel-firmware/src/lib/Esp8266EdgeSoftwareSerial/
My
SoftwareSerial.h
View file @
54e58bcf
/*
SoftwareSerial.h
My
SoftwareSerial.h
SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
My
SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
Copyright (c) 2015-2016 Peter Lerup. All rights reserved.
This library is free software; you can redistribute it and/or
...
...
@@ -20,8 +20,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SoftwareSerial_h
#define SoftwareSerial_h
#ifndef
My
SoftwareSerial_h
#define
My
SoftwareSerial_h
#include
<inttypes.h>
#include
<Stream.h>
...
...
@@ -32,10 +32,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// Speed up to 115200 can be used.
class
SoftwareSerial
:
public
Stream
{
class
My
SoftwareSerial
:
public
Stream
{
public:
SoftwareSerial
(
int
receivePin
,
int
transmitPin
,
bool
inverse_logic
=
false
,
unsigned
int
buffSize
=
64
,
bool
edge_triggered
=
false
);
virtual
~
SoftwareSerial
();
My
SoftwareSerial
(
int
receivePin
,
int
transmitPin
,
bool
inverse_logic
=
false
,
unsigned
int
buffSize
=
64
,
bool
edge_triggered
=
false
);
virtual
~
My
SoftwareSerial
();
void
begin
(
long
speed
);
long
baudRate
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment