Skip to content

Commit

Permalink
add TC74A5 example
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Sep 19, 2023
1 parent daa9a33 commit 8099503
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/autoexecExamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,15 @@ setButtonColor 2 "#56b08f"
```


Advanced I2C driver for multiple devices on single bus - TC74 example
<br>
```// 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
```


7 changes: 7 additions & 0 deletions docs/autoexecs/soft_i2c_tc74.bat
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/commands-extended.md
Original file line number Diff line number Diff line change
Expand Up @@ -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').<br/><br/>See also [AB_Map on forum](https://www.elektroda.com/rtvforum/find.php?q=AB_Map). | File: drv/drv_adcButton.c<br/>Function: Cmd_ADCButtonMap |
| ADCSmoother | Cmd_SetupADCSmoother | .<br/><br/>See also [ADCSmoother on forum](https://www.elektroda.com/rtvforum/find.php?q=ADCSmoother). | File: driver/drv_adcSmoother.c<br/>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'.<br/><br/>See also [AddChangeHandler on forum](https://www.elektroda.com/rtvforum/find.php?q=AddChangeHandler). | File: cmnds/cmd_eventHandlers.c<br/>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.<br/><br/>See also [AddChannel on forum](https://www.elektroda.com/rtvforum/find.php?q=AddChannel). | File: cmnds/cmd_channels.c<br/>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.<br/><br/>See also [addClockEvent on forum](https://www.elektroda.com/rtvforum/find.php?q=addClockEvent). | File: driver/drv_ntp_events.c<br/>Function: CMD_NTP_AddClockEvent |
Expand Down
1 change: 1 addition & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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').<br/><br/>See also [AB_Map on forum](https://www.elektroda.com/rtvforum/find.php?q=AB_Map). |
| ADCSmoother | Cmd_SetupADCSmoother | .<br/><br/>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'.<br/><br/>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.<br/><br/>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.<br/><br/>See also [addClockEvent on forum](https://www.elektroda.com/rtvforum/find.php?q=addClockEvent). |
Expand Down
1 change: 1 addition & 0 deletions docs/drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br/>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.<br/>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.<br/>See also [TM1638 on forum](https://www.elektroda.com/rtvforum/find.php?q=TM1638). |
| ADCSmoother | Qq.<br/>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).<br/>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).<br/>See also [SHT3X on forum](https://www.elektroda.com/rtvforum/find.php?q=SHT3X). |
| SGP | SGP Air Quality sensor with I2C interface.<br/>See also [SGP on forum](https://www.elektroda.com/rtvforum/find.php?q=SGP). |
Expand Down
4 changes: 4 additions & 0 deletions docs/json/autoexecExamples.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
9 changes: 9 additions & 0 deletions docs/json/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down
6 changes: 6 additions & 0 deletions docs/json/drivers.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/driver/drv_adcSmoother.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions src/win_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 8099503

Please sign in to comment.