Skip to content

Commit

Permalink
widen component list and fix analogWrite component
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-8 committed Jan 4, 2025
1 parent f629503 commit d541950
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion RCMv3/rcmv3.h
Original file line number Diff line number Diff line change
Expand Up @@ -1149,13 +1149,15 @@ class RCMv3ComponentAnalogWrite : public RCMv3Component {
byte pin;
float val;
boolean enabled;
float setVal;

public:
RCMv3ComponentAnalogWrite(byte _pin)
: RCMv3Component(RC_TYPE_AnalogWrite)
{
pin = _pin;
val = 0;
setVal = -1;
enabled = false;
}
void write(int index, float value)
Expand All @@ -1171,6 +1173,8 @@ class RCMv3ComponentAnalogWrite : public RCMv3Component {
if (!enabled) {
pinMode(pin, OUTPUT);
enabled = true;
setVal = val;
analogWrite(pin, constrain(val, 0, 1) * 255);
}
}
void disable()
Expand All @@ -1183,7 +1187,10 @@ class RCMv3ComponentAnalogWrite : public RCMv3Component {
void run()
{
if (enabled) {
analogWrite(pin, constrain(val, 0, 1) * 255);
if (val != setVal) {
setVal = val;
analogWrite(pin, constrain(val, 0, 1) * 255);
}
}
}
~RCMv3ComponentAnalogWrite()
Expand Down
2 changes: 1 addition & 1 deletion docs/ds/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
.potential-components {
height: 400px;
max-height: 400px;
width: 200px;
width: 300px;
overflow-y: auto;
padding: 5px 5px;
}
Expand Down

0 comments on commit d541950

Please sign in to comment.