Skip to content

Commit c72bc1e

Browse files
committed
Merge branch 'master' into ImproveDocumentation
2 parents b435afe + dbf3b14 commit c72bc1e

File tree

4 files changed

+43
-7
lines changed

4 files changed

+43
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ For more information and documentation, see the [DCS-BIOS FlightPanels Project](
88

99
DCS-BIOS was originally developed here, [DCS-BIOS project.](https://github.com/dcs-bios/dcs-bios) DCS-BIOS Flightpanels forked all of DCS-BIOS in order to initially provide support for Saitek Flight Panels. As of Nov, 2020, the original project has received limited support (despite a major update for HUB), and FlightPanels is gaining in popularity due to it's support. Late in 2020, this fork of the arduino-only portion was created to become the "official" branch associated with the FlightPanels DCS-BIOS side.
1010

11-
## Support
11+
## Support & Documentation
1212

13-
This is a community maintained plugin. Support is best found at the DCS-Flightpanels discord channel.
13+
This is a community maintained plugin. Support is best found at the DCS-Flightpanels discord channel. The wiki is very much a work in progress, and can be found here: https://github.com/talbotmcinnis/dcs-bios-arduino-library/wiki
1414

1515
## Releasing
1616

examples/OneOfEverything/OneOfEverything.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ DcsBios::InvertedPotentiometer invertedPotentiometerExample("MSG_0", 1);
5050
// Outputs
5151
///////////
5252
// A single LED
53+
DcsBios::Dimmer defaultDimmerExample(0x1012, 5);
5354
DcsBios::LED masterCaution(0x1012, 0x0800, 13);
5455
// An analog output with a value that comes from a DCS address
5556
DcsBios::Dimmer(0x1012, 13);
57+
DcsBios::Dimmer invertedDimmerExample(0x1012, 5, 200,0);
58+
unsigned int myValueMapper(unsigned int dcsValue)
59+
{
60+
return dcsValue % 10;
61+
}
62+
DcsBios::Dimmer mappedDimmerExample(0x1012, 5, myValueMapper);
5663
// A servo motor controlleed from DCS, i.e. a guage.
5764
DcsBios::ServoOutput(0x1012, 13, 544, 2400);
5865

src/internal/Buttons.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ namespace DcsBios {
114114
}
115115
}
116116

117+
void resetState() {
118+
lastState_ = (lastState_==0)?-1:0;
119+
}
120+
117121
public:
118122
//init now expects a message (the identifier you are trying to control), an argument ("TOGGLE") and an address to a storage variable
119123
MatActionButtonT(const char* msg, const char* arg, volatile unsigned char* argAddress) :
@@ -148,6 +152,10 @@ namespace DcsBios {
148152
}
149153
}
150154

155+
void resetState() {
156+
lastState_ = (lastState_==0)?-1:0;
157+
}
158+
151159
public:
152160
//init now expects a message (the identifier you are trying to control), an argument ("TOGGLE") and an address to a storage variable
153161
MatActionButtonToggleT(const char* msg, const char* arg, volatile unsigned char* argAddress) :
@@ -186,6 +194,10 @@ namespace DcsBios {
186194
}
187195
}
188196

197+
void resetState() {
198+
lastState_ = (lastState_==0)?-1:0;
199+
}
200+
189201
public:
190202
//init now expects row and column, as well as an array pointer, instead of a pin
191203
MatActionButtonSetT(const char* msg, volatile unsigned char* argAddress, char onLvlArg) :
@@ -197,7 +209,7 @@ namespace DcsBios {
197209
lastState_ = *address;
198210
}
199211
};
200-
typedef MatActionButtonToggleT<> MatActionButtonToggle;
212+
typedef MatActionButtonSetT<> MatActionButtonSet;
201213
}
202214

203215
#endif

src/internal/Dimmer.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,33 @@ namespace DcsBios {
1111
void onDcsBiosFrameSync();
1212
char pin_;
1313
const char* msg_;
14+
int minOutput_;
15+
int maxOutput_;
16+
unsigned int (*map_function_)(unsigned int newValue);
17+
1418
public:
15-
Dimmer(unsigned int address, char pin) : Int16Buffer(address){
19+
Dimmer(unsigned int address, char pin, int minOutput=0, int maxOutput=255) : Int16Buffer(address){
20+
pin_ = pin;
21+
minOutput_ = minOutput;
22+
maxOutput_ = maxOutput;
23+
map_function_ = NULL;
24+
}
25+
Dimmer(unsigned int address, char pin, unsigned int (*map_function)(unsigned int newValue)) : Int16Buffer(address){
1626
pin_ = pin;
27+
map_function_ = map_function;
1728
}
1829
virtual void loop() {
1930
if (hasUpdatedData()) {
20-
analogWrite(pin_, getData()/255);
21-
}
31+
analogWrite(pin_, mapValue(getData()));
32+
}
33+
}
34+
unsigned int mapValue(unsigned int value) {
35+
if (map_function_) {
36+
return map_function_(value);
37+
} else {
38+
return map(value, 0, 65535, minOutput_, maxOutput_);
39+
}
2240
}
23-
2441
void SetControl( const char* msg )
2542
{
2643
msg_ = msg;

0 commit comments

Comments
 (0)