Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Heizung
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
c3pb
Heizung
Commits
e6bde50b
Commit
e6bde50b
authored
1 year ago
by
Benjamin Koch
Browse files
Options
Downloads
Patches
Plain Diff
test WS2812
parent
037bc2dc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
firmware/test1/heizung-test1/platformio.ini
+1
-0
1 addition, 0 deletions
firmware/test1/heizung-test1/platformio.ini
firmware/test1/heizung-test1/src/main.cpp
+70
-6
70 additions, 6 deletions
firmware/test1/heizung-test1/src/main.cpp
with
71 additions
and
6 deletions
firmware/test1/heizung-test1/platformio.ini
+
1
−
0
View file @
e6bde50b
...
...
@@ -17,3 +17,4 @@ lib_deps =
adafruit/Adafruit SSD1306@^2.5.7
sparkfun/SparkFun
TMP102
Breakout@^1.1.2
adafruit/Adafruit
MPR121@^1.1.1
adafruit/Adafruit
NeoPixel@^1.11.0
This diff is collapsed.
Click to expand it.
firmware/test1/heizung-test1/src/main.cpp
+
70
−
6
View file @
e6bde50b
...
...
@@ -4,11 +4,13 @@
#include
<Adafruit_SSD1306.h>
#include
<SparkFunTMP102.h>
#include
<Adafruit_MPR121.h>
#include
<Adafruit_NeoPixel.h>
enum
Pinout
{
DRIVE1
=
0
,
DRIVE2
=
1
,
LED_W
=
2
,
WS2812_DISPLAY
=
2
,
LED_Y
=
3
,
EN_MEASURE_CURRENT
=
3
,
LED_B
=
4
,
...
...
@@ -50,12 +52,15 @@ TMP102 sensor0, sensor1;
Adafruit_MPR121
cap0
,
cap1
;
bool
capAvailable
[
2
];
Adafruit_NeoPixel
pixelsDisplay
(
60
,
WS2812_DISPLAY
,
NEO_GRB
+
NEO_KHZ800
);
Adafruit_NeoPixel
pixelsDigout1
(
2
,
DIGOUT1
,
NEO_GRB
+
NEO_KHZ800
);
void
setup
()
{
rp2040
.
enableDoubleResetBootloader
();
pinMode
(
DRIVE1
,
OUTPUT
);
digitalWrite
(
DRIVE1
,
LOW
);
pinMode
(
DRIVE2
,
OUTPUT
);
digitalWrite
(
DRIVE2
,
LOW
);
pinMode
(
2
,
OUTPUT
);
pinMode
(
WS2812_DISPLAY
,
OUTPUT
);
pinMode
(
3
,
OUTPUT
);
digitalWrite
(
EN_MEASURE_CURRENT
,
LOW
);
pinMode
(
4
,
OUTPUT
);
pinMode
(
5
,
OUTPUT
);
...
...
@@ -123,8 +128,15 @@ void setup() {
// enable X electrodes and start MPR121
// enable virtual proximity electrode, as well
cap
.
writeRegister
(
MPR121_ECR
,
0x8c
|
0x30
);
}
pixelsDisplay
.
begin
();
pixelsDisplay
.
clear
();
pixelsDisplay
.
show
();
pixelsDigout1
.
begin
();
pixelsDigout1
.
clear
();
pixelsDigout1
.
show
();
}
void
i2c_scan
()
{
...
...
@@ -177,9 +189,9 @@ void loop() {
led_state
++
;
if
(
led_state
==
8
)
led_state
=
2
;
if
(
led_state
>
2
&&
led_state
-
1
!=
EN_MEASURE_CURRENT
)
if
(
led_state
>
2
&&
led_state
-
1
!=
EN_MEASURE_CURRENT
&&
led_state
-
1
!=
WS2812_DISPLAY
)
digitalWrite
(
led_state
-
1
,
0
);
if
(
led_state
<=
6
&&
led_state
!=
EN_MEASURE_CURRENT
)
if
(
led_state
<=
6
&&
led_state
!=
EN_MEASURE_CURRENT
&&
led_state
!=
WS2812_DISPLAY
)
digitalWrite
(
led_state
,
1
);
}
...
...
@@ -246,7 +258,7 @@ void loop() {
int
displayModePrev
=
displayMode
;
static
bool
prevButton4
=
0
;
if
(
!
prevButton4
&&
buttons
[
3
])
{
displayMode
=
(
displayMode
+
1
)
%
6
;
displayMode
=
(
displayMode
+
1
)
%
7
;
}
prevButton4
=
buttons
[
3
];
...
...
@@ -261,7 +273,9 @@ void loop() {
display
.
setTextColor
(
SSD1306_WHITE
);
display
.
setCursor
(
0
,
1
);
display
.
print
(
F
(
"ADDR: "
));
display
.
println
(
!
digitalRead
(
BOOT2
)
?
'X'
:
'_'
);
display
.
print
(
!
digitalRead
(
BOOT2
)
?
'X'
:
'_'
);
display
.
print
(
" "
);
display
.
println
(
digitalRead
(
WS2811
)
?
"WS^"
:
"ws "
);
display
.
print
(
F
(
"SW: "
));
for
(
auto
pressed
:
buttons
)
...
...
@@ -424,6 +438,56 @@ void loop() {
display
.
println
(
v5
);
display
.
display
();
}
else
if
(
displayMode
==
6
)
{
if
(
displayModePrev
!=
6
)
{
display
.
fillRect
(
0
,
0
,
128
,
64
,
SSD1306_BLACK
);
display
.
drawBitmap
(
0
,
0
,
logo_data
,
logo_width
,
logo_height
,
SSD1306_WHITE
);
display
.
display
();
}
}
static
int
digout1_timer
=
0
;
static
int
digout1_state
=
2
;
if
(
digout1_timer
<
300
||
!
pixelsDigout1
.
canShow
())
digout1_timer
++
;
else
{
digout1_timer
=
0
;
digout1_state
++
;
for
(
int
i
=
0
;
i
<
pixelsDigout1
.
numPixels
();
i
++
)
{
switch
((
digout1_state
-
3
*
i
)
%
8
)
{
case
0
:
pixelsDigout1
.
setPixelColor
(
i
,
pixelsDigout1
.
Color
(
255
,
0
,
0
));
break
;
case
1
:
pixelsDigout1
.
setPixelColor
(
i
,
pixelsDigout1
.
Color
(
0
,
255
,
0
));
break
;
case
2
:
pixelsDigout1
.
setPixelColor
(
i
,
pixelsDigout1
.
Color
(
0
,
0
,
255
));
break
;
default:
pixelsDigout1
.
setPixelColor
(
i
,
pixelsDigout1
.
Color
(
0
,
0
,
0
));
break
;
}
}
pixelsDigout1
.
show
();
}
static
int
ledring_timer
=
0
;
static
int
ledring_state
=
0
;
if
((
ledring_timer
<
10
||
!
pixelsDisplay
.
canShow
())
&&
0
)
{
ledring_timer
++
;
}
else
{
ledring_timer
=
0
;
ledring_state
+=
1
;
for
(
int
i
=
0
;
i
<
pixelsDisplay
.
numPixels
();
i
++
)
{
int
h
=
((
ledring_state
+
4
*
i
)
%
(
256
*
4
))
*
(
256
/
4
);
int
y
=
((
uint32_t
)(
i
-
ledring_state
/
3
))
%
64
-
(
int32_t
)
32
;
int
v
=
y
>=
-
10
&&
y
<=
10
?
50
:
y
>=
-
20
&&
y
<
-
10
?
(
y
+
20
)
*
5
:
y
<=
20
&&
y
>
10
?
(
20
-
y
)
*
5
:
0
;
pixelsDisplay
.
setPixelColor
(
i
,
pixelsDisplay
.
ColorHSV
(
h
,
255
,
y
<=
1
&&
y
>=
-
1
&&
0
?
255
:
v
/
16
));
}
pixelsDisplay
.
show
();
}
delay
(
1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment