Skip to content

Commit 325ee9c

Browse files
committed
Init commit
1 parent 95edb07 commit 325ee9c

File tree

7 files changed

+72
-1
lines changed

7 files changed

+72
-1
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = true
2+
3+
[*.{c,cpp,h,hpp,ino,ino.cpp,ino.h,txt,md}]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = tab
8+
indent_size = 4
9+
tab_width = 4
10+
trim_trailing_whitespace = true
11+
12+
[*.{json,yml,yaml,xml}]
13+
indent_style = space
14+
indent_size = 2
15+
tab_width = 2
16+
17+
[Makefile]
18+
indent_style = tab
19+
indent_size = 4
20+
tab_width = 4

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"files.eol": "\n",
3+
"files.trimTrailingWhitespace": true,
4+
"editor.insertSpaces": false,
5+
"editor.tabSize": 4,
6+
"editor.detectIndentation": false,
7+
"files.associations": {
8+
"bitset": "cpp"
9+
}
10+
}

examples/Example1-3leadECGstream-arduino-plotter/Example1-3leadECGstream-arduino-plotter.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ void loop()
109109
// Print all three channels as CSV so the Arduino plotter or a host
110110
// application can parse them easily: ch1,ch2,ch3
111111
Serial.print(samples.ch1);
112-
Serial.print(',');
112+
ADS1293.configureAFEShutdown(AFEShutdownMode::AFE_On);
113+
// Set PGA gain=8 for all channels
114+
ADS1293.setChannelGain(1, Ads1293::PgaGain::G8);
115+
ADS1293.setChannelGain(2, Ads1293::PgaGain::G8);
116+
ADS1293.setChannelGain(3, Ads1293::PgaGain::G8);
113117
Serial.print(samples.ch2);
114118
Serial.print(',');
115119
Serial.println(samples.ch3);

examples/Example2-5leadECGstream-arduino-plotter/Example2-5leadECGstream-arduino-plotter.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ void setup() {
7272
ADS1293.configureRLD(RLDMode::Default);
7373
ADS1293.configureRef(RefMode::Default);
7474
ADS1293.configureAFEShutdown(AFEShutdownMode::AFE_On);
75+
// Set PGA gain=8 for all channels
76+
ADS1293.setChannelGain(1, Ads1293::PgaGain::G8);
77+
ADS1293.setChannelGain(2, Ads1293::PgaGain::G8);
78+
ADS1293.setChannelGain(3, Ads1293::PgaGain::G8);
7579
// Ensure example runs at 100 SPS using the DRATE-based API
7680
ADS1293.setSamplingRate(Ads1293::SamplingRate::SPS_100);
7781
ADS1293.configureDRDYSource(DRDYSource::Default);

examples/Example3-5leadECGstream-openview/Example3-5leadECGstream-openview.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ void setup() {
121121
ADS1293.configureRLD(RLDMode::Default);
122122
ADS1293.configureRef(RefMode::Default);
123123
ADS1293.configureAFEShutdown(AFEShutdownMode::AFE_On);
124+
// Set PGA gain=8 for all channels
125+
ADS1293.setChannelGain(1, Ads1293::PgaGain::G8);
126+
ADS1293.setChannelGain(2, Ads1293::PgaGain::G8);
127+
ADS1293.setChannelGain(3, Ads1293::PgaGain::G8);
124128
// Ensure example runs at 100 SPS using the DRATE-based API
125129
ADS1293.setSamplingRate(Ads1293::SamplingRate::SPS_25);
126130
ADS1293.configureDRDYSource(DRDYSource::Default);

src/protocentral_ads1293.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,21 @@ bool Ads1293::enableTestSignalAll(TestSignal sig)
400400
return ok;
401401
}
402402

403+
bool Ads1293::setChannelGainRaw(uint8_t channel, uint8_t regValue)
404+
{
405+
if (channel < 1 || channel > 3) return false;
406+
// CH1SET @ 0x0A, CH2SET @ 0x0B, CH3SET @ 0x0C
407+
Register reg = static_cast<Register>(0x0A + (channel - 1));
408+
bool ok = writeRegister(reg, regValue);
409+
delay(1);
410+
return ok;
411+
}
412+
413+
bool Ads1293::setChannelGain(uint8_t channel, Ads1293::PgaGain gain)
414+
{
415+
return setChannelGainRaw(channel, static_cast<uint8_t>(gain));
416+
}
417+
403418
bool Ads1293::setSamplingRate(Ads1293::SamplingRate s)
404419
{
405420
// Implement ODR configuration by programming the decimation stages

src/protocentral_ads1293.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,20 @@ class Ads1293 {
189189
// Returns true if all channel routes were configured successfully.
190190
bool enableTestSignalAll(TestSignal sig);
191191

192+
// PGA gain helpers
193+
// Raw write to CHnSET register (addresses 0x0A,0x0B,0x0C for channels 1..3).
194+
bool setChannelGainRaw(uint8_t channel, uint8_t regValue);
195+
196+
// Convenience enum and wrapper for common gain presets.
197+
enum class PgaGain : uint8_t {
198+
G1 = 0x00,
199+
G4 = 0x08, // example mapping from datasheet/example
200+
G6 = 0x10,
201+
G12 = 0x18,
202+
G8 = 0x0C
203+
};
204+
bool setChannelGain(uint8_t channel, PgaGain gain);
205+
192206
// Sampling rate presets (output data rate, ODR) supported by setSamplingRate().
193207
// These mappings assume the sigma-delta modulator clock fS = 102.4 kHz and
194208
// R1 = 4 (default). The function programs R2 and R3 registers for all three

0 commit comments

Comments
 (0)