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
037bc2dc
Commit
037bc2dc
authored
1 year ago
by
Benjamin Koch
Browse files
Options
Downloads
Patches
Plain Diff
test ADC
parent
1967d5ff
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
firmware/test1/heizung-test1/src/main.cpp
+69
-2
69 additions, 2 deletions
firmware/test1/heizung-test1/src/main.cpp
with
69 additions
and
2 deletions
firmware/test1/heizung-test1/src/main.cpp
+
69
−
2
View file @
037bc2dc
...
...
@@ -246,13 +246,15 @@ void loop() {
int
displayModePrev
=
displayMode
;
static
bool
prevButton4
=
0
;
if
(
!
prevButton4
&&
buttons
[
3
])
{
displayMode
=
(
displayMode
+
1
)
%
5
;
displayMode
=
(
displayMode
+
1
)
%
6
;
}
prevButton4
=
buttons
[
3
];
if
(
rp2040
.
getCycleCount64
()
>
2
*
133
*
1000
*
1000
&&
displayMode
==
0
)
{
if
(
displayModePrev
!=
0
)
if
(
displayModePrev
!=
0
)
{
display
.
fillRect
(
67
,
0
,
128
-
67
,
64
,
SSD1306_BLACK
);
display
.
drawBitmap
(
0
,
0
,
logo_data
,
logo_width
,
logo_height
,
SSD1306_WHITE
);
}
display
.
fillRect
(
0
,
0
,
67
,
64
,
SSD1306_BLACK
);
display
.
setTextSize
(
1
);
...
...
@@ -356,6 +358,71 @@ void loop() {
display
.
drawFastHLine
(
0
,
y
++
,
b
/
16
,
SSD1306_WHITE
);
display
.
drawFastHLine
(
0
,
y
++
,
v
/
16
,
SSD1306_WHITE
);
}
display
.
display
();
}
else
if
(
displayMode
==
5
)
{
display
.
fillRect
(
0
,
0
,
128
,
64
,
SSD1306_BLACK
);
display
.
setTextSize
(
1
);
display
.
setTextColor
(
SSD1306_WHITE
);
display
.
setCursor
(
0
,
1
);
display
.
println
(
F
(
"ADC:"
));
analogReadResolution
(
12
);
auto
v1
=
analogRead
(
ANALOG_IN1
);
display
.
print
(
F
(
"AIN1: "
));
display
.
print
(
v1
);
auto
ain1
=
3.05
*
v1
/
4096
*
(
10
+
2
*
5.1
)
/
5.1
;
display
.
print
(
F
(
" -> "
));
display
.
println
(
ain1
,
2
);
auto
v2
=
analogRead
(
CURRENT2
);
display
.
print
(
F
(
"CUR2: "
));
display
.
print
(
v2
);
static
int32_t
avgCurrent2
=
0
;
if
(
!
buttons
[
1
]
&&
!
buttons
[
2
])
{
//avgCurrent2 = (avgCurrent2*31 + v2)/32;
avgCurrent2
=
avgCurrent2
*
31
/
32
+
v2
;
display
.
print
(
", "
);
display
.
println
(
avgCurrent2
/
32
);
}
else
{
display
.
print
(
F
(
" -> "
));
float
current2
=
max
(
0
,
v2
-
avgCurrent2
/
32
)
*
3.05
/
4096
/
0.1
*
1
/
56.0
;
display
.
println
(
current2
,
3
);
Serial
.
print
(
F
(
"Current2: "
));
Serial
.
print
(
v2
);
Serial
.
print
(
" - "
);
Serial
.
print
(
avgCurrent2
);
Serial
.
print
(
"/32 -> "
);
Serial
.
println
(
current2
,
5
);
}
auto
v3
=
analogRead
(
CURRENT1
);
display
.
print
(
F
(
"CUR1: "
));
display
.
print
(
v3
);
static
int32_t
avgCurrent1
=
0
;
if
(
!
buttons
[
0
]
&&
!
buttons
[
2
])
{
//avgCurrent1 = (avgCurrent1*31 + v3)/32;
avgCurrent1
=
avgCurrent1
*
31
/
32
+
v3
;
display
.
print
(
", "
);
display
.
println
(
avgCurrent1
/
32
);
}
else
{
display
.
print
(
F
(
" -> "
));
float
current1
=
max
(
0
,
v3
-
avgCurrent1
/
32
)
*
3.05
/
4096
/
0.1
*
1
/
56.0
;
display
.
println
(
current1
,
3
);
}
auto
v4
=
analogRead
(
MEASURE_VCC
);
display
.
print
(
F
(
"VCC: "
));
display
.
print
(
v4
);
auto
vcc
=
3.05
*
v4
/
4096
*
(
100
+
10
)
/
10
;
display
.
print
(
F
(
" -> "
));
display
.
println
(
vcc
,
2
);
auto
v5
=
analogReadTemp
(
3.0
);
display
.
print
(
F
(
"TEMP: "
));
display
.
println
(
v5
);
display
.
display
();
}
...
...
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