Skip to content

Commit 1ea3519

Browse files
script pwm
1 parent 80111be commit 1ea3519

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

src/httpserver/new_http.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ const char* htmlPinRoleNames[] = {
539539
"KP18058_CLK",
540540
"KP18058_DAT",
541541
"DS1820_IO",
542-
"error",
542+
"PWM_ScriptOnly",
543543
"error",
544544
"error",
545545
};

src/new_pins.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ void CHANNEL_SetAll(int iVal, int iFlags) {
717717
CHANNEL_Set(g_cfg.pins.channels[i], iVal, iFlags);
718718
break;
719719
case IOR_PWM:
720+
case IOR_PWM_ScriptOnly:
720721
case IOR_PWM_n:
721722
CHANNEL_Set(g_cfg.pins.channels[i], iVal, iFlags);
722723
break;
@@ -832,6 +833,7 @@ void PIN_SetPinRoleForPinIndex(int index, int role) {
832833
break;
833834
// Disable PWM for previous pin role
834835
case IOR_PWM_n:
836+
case IOR_PWM_ScriptOnly:
835837
case IOR_PWM:
836838
{
837839
HAL_PIN_PWM_Stop(index);
@@ -1028,6 +1030,7 @@ void PIN_SetPinRoleForPinIndex(int index, int role) {
10281030
HAL_ADC_Init(index);
10291031
break;
10301032
case IOR_PWM_n:
1033+
case IOR_PWM_ScriptOnly:
10311034
case IOR_PWM:
10321035
{
10331036
int channelIndex;
@@ -1111,7 +1114,7 @@ static void Channel_OnChanged(int ch, int prevValue, int iFlags) {
11111114
else if (g_cfg.pins.roles[i] == IOR_Relay_n || g_cfg.pins.roles[i] == IOR_LED_n || g_cfg.pins.roles[i] == IOR_BAT_Relay_n) {
11121115
RAW_SetPinValue(i, !bOn);
11131116
}
1114-
else if (g_cfg.pins.roles[i] == IOR_PWM) {
1117+
else if (g_cfg.pins.roles[i] == IOR_PWM || g_cfg.pins.roles[i] == IOR_PWM_ScriptOnly) {
11151118
HAL_PIN_PWM_Update(i, iVal);
11161119
}
11171120
else if (g_cfg.pins.roles[i] == IOR_PWM_n) {
@@ -1362,7 +1365,7 @@ void CHANNEL_Set_FloatPWM(int ch, float fVal, int iFlags) {
13621365

13631366
for (i = 0; i < PLATFORM_GPIO_MAX; i++) {
13641367
if (g_cfg.pins.channels[i] == ch) {
1365-
if (g_cfg.pins.roles[i] == IOR_PWM) {
1368+
if (g_cfg.pins.roles[i] == IOR_PWM || g_cfg.pins.roles[i] == IOR_PWM_ScriptOnly) {
13661369
HAL_PIN_PWM_Update(i, fVal);
13671370
}
13681371
else if (g_cfg.pins.roles[i] == IOR_PWM_n) {
@@ -1507,7 +1510,7 @@ int CHANNEL_FindMaxValueForChannel(int ch) {
15071510
// is pin tied to this channel?
15081511
if (g_cfg.pins.channels[i] == ch) {
15091512
// is it PWM?
1510-
if (g_cfg.pins.roles[i] == IOR_PWM) {
1513+
if (g_cfg.pins.roles[i] == IOR_PWM || g_cfg.pins.roles[i] == IOR_PWM_ScriptOnly) {
15111514
return 100;
15121515
}
15131516
if (g_cfg.pins.roles[i] == IOR_PWM_n) {
@@ -1689,6 +1692,7 @@ int CHANNEL_GetRoleForOutputChannel(int ch) {
16891692
case IOR_LED_n:
16901693
case IOR_PWM_n:
16911694
case IOR_PWM:
1695+
case IOR_PWM_ScriptOnly:
16921696
return g_cfg.pins.roles[i];
16931697
case IOR_BridgeForward:
16941698
case IOR_BridgeReverse:
@@ -1951,7 +1955,7 @@ void PIN_ticks(void* param)
19511955
}
19521956

19531957
#if 1
1954-
if (g_cfg.pins.roles[i] == IOR_PWM) {
1958+
if (g_cfg.pins.roles[i] == IOR_PWM || g_cfg.pins.roles[i] == IOR_PWM_ScriptOnly) {
19551959
HAL_PIN_PWM_Update(i, g_channelValuesFloats[g_cfg.pins.channels[i]]);
19561960
}
19571961
else if (g_cfg.pins.roles[i] == IOR_PWM_n) {
@@ -2338,6 +2342,11 @@ void PIN_get_Relay_PWM_Count(int* relayCount, int* pwmCount, int* dInputCount) {
23382342
BIT_SET(pwmBits, g_cfg.pins.channels[i]);
23392343
//(*pwmCount)++;
23402344
break;
2345+
case IOR_PWM_ScriptOnly:
2346+
// DO NOT COUNT SCRIPTONLY PWM HERE!
2347+
// As in title - it's only for scripts.
2348+
// It should not generate lights!
2349+
break;
23412350
case IOR_DigitalInput:
23422351
case IOR_DigitalInput_n:
23432352
case IOR_DigitalInput_NoPup:
@@ -2377,6 +2386,12 @@ int h_isChannelPWM(int tg_ch) {
23772386
if (role == IOR_PWM || role == IOR_PWM_n) {
23782387
return true;
23792388
}
2389+
// DO NOT COUNT SCRIPTONLY PWM HERE!
2390+
// As in title - it's only for scripts.
2391+
// It should not generate lights!
2392+
//if (role == IOR_PWM_ScriptOnly) {
2393+
// return true;
2394+
//}
23802395
}
23812396
return false;
23822397
}

src/new_pins.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,13 @@ typedef enum ioRole_e {
560560
//iodetail:"file":"new_pins.h",
561561
//iodetail:"driver":""}
562562
IOR_DS1820_IO,
563+
//iodetail:{"name":"PWM_ScriptOnly",
564+
//iodetail:"title":"TODO",
565+
//iodetail:"descr":"",
566+
//iodetail:"enum":"PWM_ScriptOnly",
567+
//iodetail:"file":"new_pins.h",
568+
//iodetail:"driver":""}
569+
IOR_PWM_ScriptOnly,
563570
//iodetail:{"name":"Total_Options",
564571
//iodetail:"title":"TODO",
565572
//iodetail:"descr":"Current total number of available IOR roles",

0 commit comments

Comments
 (0)