From 8099503124bb417f8067ef03b54084fb1193540b Mon Sep 17 00:00:00 2001 From: Tester23 Date: Tue, 19 Sep 2023 13:30:14 +0200 Subject: [PATCH] add TC74A5 example --- docs/autoexecExamples.md | 12 ++++++++++++ docs/autoexecs/soft_i2c_tc74.bat | 7 +++++++ docs/commands-extended.md | 1 + docs/commands.md | 1 + docs/drivers.md | 1 + docs/json/autoexecExamples.json | 4 ++++ docs/json/commands.json | 9 +++++++++ docs/json/drivers.json | 6 ++++++ src/driver/drv_adcSmoother.c | 5 +++++ src/win_main.c | 4 ++++ 10 files changed, 50 insertions(+) create mode 100644 docs/autoexecs/soft_i2c_tc74.bat diff --git a/docs/autoexecExamples.md b/docs/autoexecExamples.md index 9f83a2c5e..0f05b9764 100644 --- a/docs/autoexecExamples.md +++ b/docs/autoexecExamples.md @@ -490,3 +490,15 @@ setButtonColor 2 "#56b08f" ``` +Advanced I2C driver for multiple devices on single bus - TC74 example +
+```// TC74A5 (check address in datasheet! is on SoftSDA and SoftSCL with 10k pull up resistors) +startDriver I2C +setChannelType 6 temperature +// Options are: I2C1 (BK port), I2C2 (BK port), Soft (pins set in configure module) +// 0x4D is device address +// 6 is target channel +addI2CDevice_TC74 Soft 0x4D 6 +``` + + diff --git a/docs/autoexecs/soft_i2c_tc74.bat b/docs/autoexecs/soft_i2c_tc74.bat new file mode 100644 index 000000000..443843358 --- /dev/null +++ b/docs/autoexecs/soft_i2c_tc74.bat @@ -0,0 +1,7 @@ +// TC74A5 (check address in datasheet! is on SoftSDA and SoftSCL with 10k pull up resistors) +startDriver I2C +setChannelType 6 temperature +// Options are: I2C1 (BK port), I2C2 (BK port), Soft (pins set in configure module) +// 0x4D is device address +// 6 is target channel +addI2CDevice_TC74 Soft 0x4D 6 \ No newline at end of file diff --git a/docs/commands-extended.md b/docs/commands-extended.md index 328d6051c..917c1cde6 100644 --- a/docs/commands-extended.md +++ b/docs/commands-extended.md @@ -6,6 +6,7 @@ Do not add anything here, as it will overwritten with next rebuild. | Command | Arguments | Description | Location | |:------------- |:-------------:|:----- | ------:| | AB_Map | [int] | Sets margines for ADC button codes. For given N margins, there are N+1 possible ADC button values (one should be reserved for 'no button').

See also [AB_Map on forum](https://www.elektroda.com/rtvforum/find.php?q=AB_Map). | File: drv/drv_adcButton.c
Function: Cmd_ADCButtonMap | +| ADCSmoother | Cmd_SetupADCSmoother | .

See also [ADCSmoother on forum](https://www.elektroda.com/rtvforum/find.php?q=ADCSmoother). | File: driver/drv_adcSmoother.c
Function: NULL); | | AddChangeHandler | [Variable][Relation][Constant][Command] | This can listen to change in channel value (for example channel 0 becoming 100), or for a voltage/current/power change for BL0942/BL0937. This supports multiple relations, like ==, !=, >=, < etc. The Variable name for channel is Channel0, Channel2, etc, for BL0XXX it can be 'Power', or 'Current' or 'Voltage'.

See also [AddChangeHandler on forum](https://www.elektroda.com/rtvforum/find.php?q=AddChangeHandler). | File: cmnds/cmd_eventHandlers.c
Function: CMD_AddChangeHandler | | AddChannel | [ChannelIndex][ValueToAdd][ClampMin][ClampMax][bWrapInsteadOfClamp] | Adds a given value to the channel. Can be used to change PWM brightness. Clamp min and max arguments are optional.

See also [AddChannel on forum](https://www.elektroda.com/rtvforum/find.php?q=AddChannel). | File: cmnds/cmd_channels.c
Function: CMD_AddChannel | | addClockEvent | [Time] [WeekDayFlags] [UniqueIDForRemoval][Command] | Schedule command to run on given time in given day of week. NTP must be running. Time is a time like HH:mm or HH:mm:ss, WeekDayFlag is a bitflag on which day to run, 0xff mean all days, 0x01 means sunday, 0x02 monday, 0x03 sunday and monday, etc, id is an unique id so event can be removede later.

See also [addClockEvent on forum](https://www.elektroda.com/rtvforum/find.php?q=addClockEvent). | File: driver/drv_ntp_events.c
Function: CMD_NTP_AddClockEvent | diff --git a/docs/commands.md b/docs/commands.md index 49229d25c..b7b969ba1 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -9,6 +9,7 @@ Do not add anything here, as it will overwritten with next rebuild. | Command | Arguments | Description | |:------------- |:------------- | -----:| | AB_Map | [int] | Sets margines for ADC button codes. For given N margins, there are N+1 possible ADC button values (one should be reserved for 'no button').

See also [AB_Map on forum](https://www.elektroda.com/rtvforum/find.php?q=AB_Map). | +| ADCSmoother | Cmd_SetupADCSmoother | .

See also [ADCSmoother on forum](https://www.elektroda.com/rtvforum/find.php?q=ADCSmoother). | | AddChangeHandler | [Variable][Relation][Constant][Command] | This can listen to change in channel value (for example channel 0 becoming 100), or for a voltage/current/power change for BL0942/BL0937. This supports multiple relations, like ==, !=, >=, < etc. The Variable name for channel is Channel0, Channel2, etc, for BL0XXX it can be 'Power', or 'Current' or 'Voltage'.

See also [AddChangeHandler on forum](https://www.elektroda.com/rtvforum/find.php?q=AddChangeHandler). | | AddChannel | [ChannelIndex][ValueToAdd][ClampMin][ClampMax][bWrapInsteadOfClamp] | Adds a given value to the channel. Can be used to change PWM brightness. Clamp min and max arguments are optional.

See also [AddChannel on forum](https://www.elektroda.com/rtvforum/find.php?q=AddChannel). | | addClockEvent | [Time] [WeekDayFlags] [UniqueIDForRemoval][Command] | Schedule command to run on given time in given day of week. NTP must be running. Time is a time like HH:mm or HH:mm:ss, WeekDayFlag is a bitflag on which day to run, 0xff mean all days, 0x01 means sunday, 0x02 monday, 0x03 sunday and monday, etc, id is an unique id so event can be removede later.

See also [addClockEvent on forum](https://www.elektroda.com/rtvforum/find.php?q=addClockEvent). | diff --git a/docs/drivers.md b/docs/drivers.md index 97fa904f1..4c9e6fc9a 100644 --- a/docs/drivers.md +++ b/docs/drivers.md @@ -41,6 +41,7 @@ Do not add anything here, as it will overwritten with next rebuild. | TM1637 | Driver for 7-segment LED display with DIO/CLK interface.
See also [TM1637 on forum](https://www.elektroda.com/rtvforum/find.php?q=TM1637). | | GN6932 | Driver for 7-segment LED display with DIO/CLK/STB interface. See [this topic](https://www.elektroda.com/rtvforum/topic3971252.html) for details.
See also [GN6932 on forum](https://www.elektroda.com/rtvforum/find.php?q=GN6932). | | TM1638 | Driver for 7-segment LED display with DIO/CLK/STB interface. TM1638 is very similiar to GN6932 and TM1637. See [this topic](https://www.elektroda.com/rtvforum/viewtopic.php?p=20553628#20553628) for details.
See also [TM1638 on forum](https://www.elektroda.com/rtvforum/find.php?q=TM1638). | +| ADCSmoother | Qq.
See also [ADCSmoother on forum](https://www.elektroda.com/rtvforum/find.php?q=ADCSmoother). | | HT16K33 | Driver for 16-segment LED display with I2C. See [protocol explanation](https://www.elektroda.pl/rtvforum/topic3984616.html).
See also [HT16K33 on forum](https://www.elektroda.com/rtvforum/find.php?q=HT16K33). | | SHT3X | Humidity/temperature sensor. See [SHT Sensor tutorial topic here](https://www.elektroda.com/rtvforum/topic3958369.html), also see [this sensor teardown](https://www.elektroda.com/rtvforum/topic3945688.html).
See also [SHT3X on forum](https://www.elektroda.com/rtvforum/find.php?q=SHT3X). | | SGP | SGP Air Quality sensor with I2C interface.
See also [SGP on forum](https://www.elektroda.com/rtvforum/find.php?q=SGP). | diff --git a/docs/json/autoexecExamples.json b/docs/json/autoexecExamples.json index 18560a2d3..1ddc25593 100644 --- a/docs/json/autoexecExamples.json +++ b/docs/json/autoexecExamples.json @@ -66,5 +66,9 @@ { "title": "Advanced config for TuyaMCU power meter and electric car charging limit driver", "file": "autoexecs/TAC2121C_tuyaMCU_and_car_chargerLimit.bat" +}, +{ +"title": "Advanced I2C driver for multiple devices on single bus - TC74 example", +"file": "autoexecs/soft_i2c_tc74.bat" } ] diff --git a/docs/json/commands.json b/docs/json/commands.json index 8941b8e2d..da0c1ce78 100644 --- a/docs/json/commands.json +++ b/docs/json/commands.json @@ -8,6 +8,15 @@ "requires": "", "examples": "" }, + { + "name": "ADCSmoother", + "args": "Cmd_SetupADCSmoother", + "descr": "", + "fn": "NULL);", + "file": "driver/drv_adcSmoother.c", + "requires": "", + "examples": "" + }, { "name": "AddChangeHandler", "args": "[Variable][Relation][Constant][Command]", diff --git a/docs/json/drivers.json b/docs/json/drivers.json index 30ecb6e38..e6dbb98b6 100644 --- a/docs/json/drivers.json +++ b/docs/json/drivers.json @@ -203,6 +203,12 @@ "descr": "Driver for 7-segment LED display with DIO/CLK/STB interface. TM1638 is very similiar to GN6932 and TM1637. See [this topic](https://www.elektroda.com/rtvforum/viewtopic.php?p=20553628#20553628) for details.", "requires": "" }, + { + "name": "ADCSmoother", + "title": "TODO", + "descr": "qq", + "requires": "" + }, { "name": "HT16K33", "title": "TODO", diff --git a/src/driver/drv_adcSmoother.c b/src/driver/drv_adcSmoother.c index 2c963e7eb..cd71f72fe 100644 --- a/src/driver/drv_adcSmoother.c +++ b/src/driver/drv_adcSmoother.c @@ -50,6 +50,7 @@ float ADCSmoother_Sample() { // MarginValue is a value that used to tell which smoothed adc values are considered high and which are low // TargetChannel0or1 will be set depending on MarginValue to either 0 or 1 // something like: +// StartDriver ADCSmoother // ADCSmoother 27 10 50 10 2048 11 // commandResult_t Cmd_SetupADCSmoother(const void* context, const char* cmd, const char* args, int cmdFlags) { @@ -77,6 +78,10 @@ commandResult_t Cmd_SetupADCSmoother(const void* context, const char* cmd, const void DRV_ADCSmoother_Init() { + //cmddetail:{"name":"ADCSmoother","args":"Cmd_SetupADCSmoother", + //cmddetail:"descr":"", + //cmddetail:"fn":"NULL);","file":"driver/drv_adcSmoother.c","requires":"", + //cmddetail:"examples":""} CMD_RegisterCommand("ADCSmoother", Cmd_SetupADCSmoother, NULL); } void DRV_ADCSmootherDoSmooth() { diff --git a/src/win_main.c b/src/win_main.c index 04e4ce7d6..942c09213 100644 --- a/src/win_main.c +++ b/src/win_main.c @@ -302,6 +302,10 @@ int __cdecl main(int argc, char **argv) printf("sizeof(mainConfig_t) != MAGIC_CONFIG_SIZE!: %i\n", sizeof(mainConfig_t)); system("pause"); } + if (OFFSETOF(mainConfig_t, staticIP) != 0x00000527) { + printf("OFFSETOF(mainConfig_t, staticIP) != 0x00000527z: %i\n", OFFSETOF(mainConfig_t, staticIP)); + system("pause"); + } if (OFFSETOF(mainConfig_t, wifi_ssid) != 0x00000014) { printf("OFFSETOF(mainConfig_t, wifi_ssid) != 0x00000014: %i\n", OFFSETOF(mainConfig_t, wifi_ssid)); system("pause");