Fix TM1638 compile error

Fix TM1638 compile error (#3212)
This commit is contained in:
Theo Arends 2018-07-14 12:10:13 +02:00
parent bee95c5b56
commit ea2357375a
5 changed files with 9 additions and 9 deletions

View File

@ -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

View File

@ -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)

View File

@ -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);
}

View File

@ -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. */

View File

@ -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);