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
78d66790
Commit
78d66790
authored
Dec 29, 2020
by
Eric Duminil
Browse files
No more circular dependency
parent
f510d621
Changes
8
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
78d66790
...
...
@@ -113,7 +113,7 @@ namespace sensor {
scd30
.
setForcedRecalibrationFactor
(
config
::
co2_calibration_level
);
Serial
.
println
(
F
(
" Done!"
));
Serial
.
println
(
F
(
"Sensor calibrated."
));
resetAmpel
();
ESP
.
restart
();
// softer than ESP.reset
}
void
logToSerial
()
{
...
...
ampel-firmware/csv_writer.h
View file @
78d66790
...
...
@@ -11,8 +11,10 @@
# error Board should be either ESP8266 or ESP832
#endif
#include
"led_effects.h"
#include
"config.h"
#include
"util.h"
#include
"led_effects.h"
namespace
config
{
extern
uint16_t
csv_interval
;
// [s]
}
...
...
ampel-firmware/led_effects.cpp
View file @
78d66790
...
...
@@ -139,14 +139,14 @@ namespace led_effects {
pixels
.
show
();
}
void
showRainbowWheel
(
int
duration_s
,
uint16_t
hue_increment
)
{
void
showRainbowWheel
(
int
duration_
m
s
,
uint16_t
hue_increment
)
{
if
(
config
::
night_mode
)
{
return
;
}
static
uint16_t
wheel_offset
=
0
;
unsigned
long
t0
=
second
s
();
unsigned
long
t0
=
milli
s
();
pixels
.
setBrightness
(
config
::
max_brightness
);
while
(
second
s
()
<
t0
+
duration_s
)
{
while
(
milli
s
()
<
t0
+
duration_
m
s
)
{
for
(
int
i
=
0
;
i
<
NUMPIXELS
;
i
++
)
{
pixels
.
setPixelColor
(
i
,
pixels
.
ColorHSV
(
i
*
65535
/
NUMPIXELS
+
wheel_offset
));
wheel_offset
+=
hue_increment
;
...
...
ampel-firmware/led_effects.h
View file @
78d66790
#ifndef LED_EFFECTS_H_INCLUDED
#define LED_EFFECTS_H_INCLUDED
#include
<Arduino.h>
#include
"util.h"
#include
"config.h"
// Adafruit NeoPixel (Arduino library for controlling single-wire-based LED pixels and strip)
...
...
@@ -30,7 +29,7 @@ namespace led_effects {
int
countdownToZero
();
void
showWaitingLED
(
uint32_t
color
);
void
showKITTWheel
(
uint32_t
color
,
uint16_t
duration_s
=
2
);
void
showRainbowWheel
(
int
duration_s
=
1
,
uint16_t
hue_increment
=
50
);
void
showRainbowWheel
(
int
duration_
m
s
=
1
000
,
uint16_t
hue_increment
=
50
);
void
displayCO2color
(
uint16_t
co2
);
}
#endif
ampel-firmware/mqtt.cpp
View file @
78d66790
...
...
@@ -167,7 +167,7 @@ namespace mqtt {
}
else
if
(
messageString
==
"local_ip"
)
{
sendInfoAboutLocalNetwork
();
}
else
if
(
messageString
==
"reset"
)
{
reset
Ampel
()
;
ESP
.
restart
();
// softer than ESP.
reset()
}
else
{
led_effects
::
showKITTWheel
(
color
::
red
,
1
);
Serial
.
println
(
F
(
"Message not supported. Doing nothing."
));
...
...
ampel-firmware/util.cpp
View file @
78d66790
...
...
@@ -38,16 +38,6 @@ namespace ntp {
}
}
void
resetAmpel
()
{
Serial
.
print
(
F
(
"Resetting"
));
#ifdef AMPEL_CSV
FS_LIB
.
end
();
#endif
led_effects
::
LEDsOff
();
delay
(
1000
);
ESP
.
restart
();
}
uint32_t
max_loop_duration
=
0
;
//FIXME: Remove every instance of Strings, to avoid heap fragmentation problems. (Start: "Free heap space : 17104 bytes")
...
...
ampel-firmware/util.h
View file @
78d66790
...
...
@@ -2,20 +2,17 @@
#define AMPEL_UTIL_H_INCLUDED
#include
<Arduino.h>
#include
"config.h"
#ifdef AMPEL_CSV
# include "csv_writer.h" // To close filesystem before reset
#endif
#include
<WiFiUdp.h>
//required for NTP
#include
<WiFiUdp.h>
//
required for NTP
#include
"src/lib/NTPClient-master/NTPClient.h"
// NTP
#if defined(ESP8266)
# define BOARD "ESP8266"
# include <ESP8266WiFi.h>
# include <ESP8266WiFi.h>
// required to get MAC address
# define get_free_heap_size() system_get_free_heap_size()
#elif defined(ESP32)
# define BOARD "ESP32"
# include <WiFi.h>
# include <WiFi.h>
// required to get MAC address
# define get_free_heap_size() esp_get_free_heap_size()
#else
# define BOARD "Unknown"
...
...
@@ -43,6 +40,4 @@ namespace util {
extern
uint32_t
max_loop_duration
;
const
extern
String
SENSOR_ID
;
void
resetAmpel
();
#endif
ampel-firmware/wifi_util.h
View file @
78d66790
#ifndef WIFI_UTIL_H_INCLUDED
#define WIFI_UTIL_H_INCLUDED
#include
"led_effects.h"
#include
"config.h"
#include
"util.h"
#include
"led_effects.h"
void
WiFiConnect
(
const
String
&
hostname
);
#endif
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