Skip to content

Commit

Permalink
Tokenizer_GetPin
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Jan 11, 2025
1 parent 88993bc commit 8aad217
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/cmnds/cmd_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ int Tokenizer_GetArgsCount();
bool Tokenizer_CheckArgsCountAndPrintWarning(const char* cmdStr, int reqCount);
const char* Tokenizer_GetArg(int i);
const char* Tokenizer_GetArgFrom(int i);
int Tokenizer_GetArgInteger(int i);
int Tokenizer_GetArgInteger(int i);
int Tokenizer_GetPin(int i, int def);
int Tokenizer_GetArgIntegerDefault(int i, int def);
float Tokenizer_GetArgFloatDefault(int i, float def);
bool Tokenizer_IsArgInteger(int i);
Expand Down
9 changes: 9 additions & 0 deletions src/cmnds/cmd_tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../new_pins.h"
#include "../new_cfg.h"
#include "../logging/logging.h"
#include "../hal/hal_pins.h"

#define MAX_CMD_LEN 512
#define MAX_ARGS 32
Expand Down Expand Up @@ -209,6 +210,14 @@ int Tokenizer_GetArgIntegerRange(int i, int rangeMin, int rangeMax) {
}
return ret;
}
int Tokenizer_GetPin(int i, int def) {
int r;

if (g_numArgs <= i) {
return def;
}
return HAL_PIN_Find(g_args[i]);
}
int Tokenizer_GetArgIntegerDefault(int i, int def) {
int r;

Expand Down
4 changes: 2 additions & 2 deletions src/driver/drv_bmp280.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void BMP280_Stop(void) { //manufacturer ID
// Adr8bit 236 for 0x76, 238 for 0x77
void BMP280_Init() {

g_softI2C.pin_clk = Tokenizer_GetArgIntegerDefault(1, 8);
g_softI2C.pin_data = Tokenizer_GetArgIntegerDefault(2, 14);
g_softI2C.pin_clk = Tokenizer_GetPin(1, 8);
g_softI2C.pin_data = Tokenizer_GetPin(2, 14);
g_targetChannelTemperature = Tokenizer_GetArgIntegerDefault(3, -1);
g_targetChannelPressure = Tokenizer_GetArgIntegerDefault(4, -1);
g_targetChannelHumidity = Tokenizer_GetArgIntegerDefault(5, -1);
Expand Down

0 comments on commit 8aad217

Please sign in to comment.