From ea2357375a28ea897ce53a03c42b5474b24f97eb Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Sat, 14 Jul 2018 12:10:13 +0200 Subject: [PATCH] Fix TM1638 compile error Fix TM1638 compile error (#3212) --- sonoff/_releasenotes.ino | 1 + sonoff/sonoff.h | 2 ++ sonoff/xplg_ws2812.ino | 7 +++---- sonoff/xsns_22_sr04.ino | 6 ++---- sonoff/xsns_28_tm1638.ino | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 0635beae8..e5c92d8e8 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,4 +1,5 @@ /* 6.1.0a + * Fix TM1638 compile error (#3212) * Add TM1638 switch support (#2226) * Fix invalid response using more than 4 switches and domoticz * Update sensor drivers to provide instant results diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 2cc9fa8e6..d27951a80 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -116,6 +116,8 @@ typedef unsigned long power_t; // Power (Relay) type #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) */ +#define tmin(a,b) ((a)<(b)?(a):(b)) +#define tmax(a,b) ((a)>(b)?(a):(b)) #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) diff --git a/sonoff/xplg_ws2812.ino b/sonoff/xplg_ws2812.ino index 2e576bfc8..0d8846550 100644 --- a/sonoff/xplg_ws2812.ino +++ b/sonoff/xplg_ws2812.ino @@ -126,7 +126,6 @@ int mod(int a, int b) return ret; } -#define cmin(a,b) ((a)<(b)?(a):(b)) void Ws2812UpdatePixelColor(int position, struct WsColor hand_color, float offset) { @@ -140,9 +139,9 @@ void Ws2812UpdatePixelColor(int position, struct WsColor hand_color, float offse color = strip->GetPixelColor(mod_position); float dimmer = 100 / (float)Settings.light_dimmer; - color.R = cmin(color.R + ((hand_color.red / dimmer) * offset), 255); - color.G = cmin(color.G + ((hand_color.green / dimmer) * offset), 255); - color.B = cmin(color.B + ((hand_color.blue / dimmer) * offset), 255); + color.R = tmin(color.R + ((hand_color.red / dimmer) * offset), 255); + color.G = tmin(color.G + ((hand_color.green / dimmer) * offset), 255); + color.B = tmin(color.B + ((hand_color.blue / dimmer) * offset), 255); strip->SetPixelColor(mod_position, color); } diff --git a/sonoff/xsns_22_sr04.ino b/sonoff/xsns_22_sr04.ino index 59781cb0e..775ea93c9 100644 --- a/sonoff/xsns_22_sr04.ino +++ b/sonoff/xsns_22_sr04.ino @@ -25,8 +25,6 @@ * References: * - https://www.dfrobot.com/wiki/index.php/Weather-proof_Ultrasonic_Sensor_SKU_:_SEN0207 \*********************************************************************************************/ -#define max(a,b) ((a)>(b)?(a):(b)) -#define min(a,b) ((a)<(b)?(a):(b)) uint8_t sr04_echo_pin = 0; uint8_t sr04_trig_pin = 0; @@ -42,7 +40,7 @@ uint8_t sr04_trig_pin = 0; #define PING_OVERHEAD 5 // Conversion from uS to distance (round result to nearest cm or inch). -#define EchoConvert(echoTime, conversionFactor) (max(((unsigned int)echoTime + conversionFactor / 2) / conversionFactor, (echoTime ? 1 : 0))) +#define EchoConvert(echoTime, conversionFactor) (tmax(((unsigned int)echoTime + conversionFactor / 2) / conversionFactor, (echoTime ? 1 : 0))) /********************************************************************************************/ @@ -74,7 +72,7 @@ uint16_t Sr04Ping(uint16_t max_cm_distance) uint16_t duration = 0; uint16_t maxEchoTime; - maxEchoTime = min(max_cm_distance + 1, (uint16_t) MAX_SENSOR_DISTANCE + 1) * US_ROUNDTRIP_CM; + maxEchoTime = tmin(max_cm_distance + 1, (uint16_t) MAX_SENSOR_DISTANCE + 1) * US_ROUNDTRIP_CM; /* The following trigPin/echoPin cycle is used to determine the distance of the nearest object by bouncing soundwaves off of it. */ diff --git a/sonoff/xsns_28_tm1638.ino b/sonoff/xsns_28_tm1638.ino index 01f2f21a5..a81344880 100644 --- a/sonoff/xsns_28_tm1638.ino +++ b/sonoff/xsns_28_tm1638.ino @@ -155,7 +155,7 @@ void TmInit() digitalWrite(tm1638_clock_pin, HIGH); Tm16XXSendCommand(0x40); - Tm16XXSendCommand(0x80 | (tm1638_active_display ? 8 : 0) | min(7, tm1638_intensity)); + Tm16XXSendCommand(0x80 | (tm1638_active_display ? 8 : 0) | tmin(7, tm1638_intensity)); digitalWrite(tm1638_strobe_pin, LOW); Tm16XXSend(0xC0);