Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CyanLight
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
fxk8y
CyanLight
Commits
b0e571d8
Commit
b0e571d8
authored
2 years ago
by
fxk8y
Browse files
Options
Downloads
Patches
Plain Diff
ST: Service implementation
parent
068f773b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CLC-qthing/SiliconTorch/Service/FxCyanF.cpp
+60
-5
60 additions, 5 deletions
CLC-qthing/SiliconTorch/Service/FxCyanF.cpp
CLC-qthing/SiliconTorch/Service/FxCyanF.hpp
+5
-1
5 additions, 1 deletion
CLC-qthing/SiliconTorch/Service/FxCyanF.hpp
with
65 additions
and
6 deletions
CLC-qthing/SiliconTorch/Service/FxCyanF.cpp
+
60
−
5
View file @
b0e571d8
#include
"FxCyanF.hpp"
// C++ system level
#include
<cmath>
// #include <cstring> // memset, strncmp
// #include <cstdlib> // TODO: is this for memcpy?
// #include <functional>
...
...
@@ -10,6 +11,7 @@
// project specific
#include
<Types.hpp>
#include
"SiliconTorch/FxCyanF.hpp"
#include
"SiliconTorch/NVSExplorer.hpp"
// qthing stuff
...
...
@@ -26,16 +28,69 @@ namespace SiliconTorch {
setNameSpace
(
"fxCyan"
);
// TODO: "FxCyanF"
}
void
FxCyanF
::
start
()
{
ESP_LOGW
(
getName
().
c_str
(),
"Starting service[ %s ] with order[ %d ] *WHOOP* *WHOOP*"
,
getName
().
c_str
(),
getStartOrder
());
const
char
*
TAG
=
getName
().
c_str
();
if
(
fxCyan
!=
NULL
)
{
ESP_LOGW
(
TAG
,
"Service already running!"
);
return
;
}
fxCyan
=
new
SiliconTorch
::
FxCyanF
::
FxCyanF
();
u32
frq
=
SiliconTorch
::
FxCyanF
::
DefaultFrequency
;
u8
res
=
SiliconTorch
::
FxCyanF
::
DefaultResolution
;
frq
=
NVSExplorer
::
NVSExplorer
::
instance
().
getUnsignedInt
(
getNameSpace
(),
"frequency"
,
frq
);
res
=
NVSExplorer
::
NVSExplorer
::
instance
().
getUnsignedInt
(
getNameSpace
(),
"resolution"
,
res
);
ESP_LOGI
(
TAG
,
"Configuring: FxCyanF{ frequency[ %d Hz ] resolution[ %d Bit ] }"
,
frq
,
res
);
fxCyan
->
setFrqRes
(
frq
,
res
);
for
(
u8
ch
=
0
;
ch
<
SiliconTorch
::
FxCyanF
::
MAX_CHANNELS
;
ch
++
)
{
char
buffer
[
32
];
snprintf
(
buffer
,
32
,
"ch%d_gpio"
,
ch
);
u8
gpio
=
NVSExplorer
::
NVSExplorer
::
instance
().
getUnsignedInt
(
getNameSpace
(),
buffer
,
0xFF
)
&
0xFF
;
snprintf
(
buffer
,
32
,
"ch%d_pwm"
,
ch
);
f32
pwm
=
NVSExplorer
::
NVSExplorer
::
instance
().
getFloat
(
getNameSpace
(),
buffer
);
// NaN == "no value stored" or any other reading error
if
(
std
::
isnan
(
pwm
))
pwm
=
0.0
f
;
if
(
gpio
!=
0xFF
)
{
// key exists
if
(
fxCyan
->
addChannel
(
gpio
,
pwm
)
)
{
// channel creation successful
ESP_LOGI
(
TAG
,
"Configuring: FxCyanF{ channel[ %d ] gpio[ %d ] pwm[ %f ] }"
,
ch
,
gpio
,
pwm
);
fxCyan
->
setPWM
(
ch
,
pwm
);
}
else
{
ESP_LOGW
(
TAG
,
"Configuring: FxCyanF{ channel[ %d ] gpio[ %d ] } FAILED[❌]"
,
ch
,
gpio
);
break
;
}
}
else
{
break
;
}
}
}
void
FxCyanF
::
stop
()
{
ESP_LOGW
(
getName
().
c_str
(),
"Stopping service[ %s ] *sad service noises*"
,
getName
().
c_str
());
SiliconTorch
::
FxCyanF
::
FxCyanF
*
FxCyanF
::
getFxCyanF
()
const
{
return
fxCyan
;
}
// str name() { return "FxCyanF"; }
// str nameSpace() { return "fxCyan"; } // TODO: "FxCyanF"
}
...
...
This diff is collapsed.
Click to expand it.
CLC-qthing/SiliconTorch/Service/FxCyanF.hpp
+
5
−
1
View file @
b0e571d8
...
...
@@ -11,6 +11,7 @@
// project specific
#include
<Types.hpp>
#include
"Service.hpp"
#include
"SiliconTorch/FxCyanF.hpp"
// qthing stuff
// #include <qthing>
...
...
@@ -20,6 +21,7 @@ namespace SiliconTorch {
namespace
Service
{
class
FxCyanF
:
public
ServiceManager
::
Service
{
public:
...
...
@@ -29,10 +31,12 @@ namespace SiliconTorch {
void
start
();
SiliconTorch
::
FxCyanF
::
FxCyanF
*
getFxCyanF
()
const
;
private:
SiliconTorch
::
FxCyanF
::
FxCyanF
*
fxCyan
=
NULL
;
};
...
...
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