Skip to content

Commit

Permalink
Small changes allowing the use of C++11 std::function. (#1353)
Browse files Browse the repository at this point in the history
* Small changes allowing the use of C++11 std::function.
  • Loading branch information
slaff authored Apr 11, 2018
1 parent 6f3bf3e commit ed0ca30
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sming/Libraries/ArduCAM/ArduCAMStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ uint16_t ArduCAMStream::readMemoryBlock(char* data, int bufSize) {

}

int bytesread = min(len, bufSize);
int bytesread = min(len, (unsigned int)bufSize);

ACAM_DEBUG("ArduCAMStream::readMemoryBlock [%d] (%d bytes) remaining (%d bytes)\n", bcount++, bytesread, len);

Expand Down
2 changes: 1 addition & 1 deletion Sming/Libraries/I2Cdev/I2Cdev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
// smaller chunks instead of all at once
for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {
for (uint8_t k = 0; k < length; k += min((unsigned int)length, (unsigned int)BUFFER_LENGTH)) {
Wire.beginTransmission(devAddr);
Wire.write(regAddr);
Wire.endTransmission();
Expand Down
2 changes: 1 addition & 1 deletion Sming/SmingCore/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void SPIClass::transfer(uint8 *buffer, size_t numberBytes) {
while (blocks--) {

// get full BLOCKSIZE or number of remaining bytes
bufLenght = min(numberBytes-bufIndx, BLOCKSIZE);
bufLenght = min(numberBytes-bufIndx, (unsigned int)BLOCKSIZE);

#ifdef SPI_DEBUG
debugf("Write/Read Block %d total %d bytes", total-blocks, bufLenght);
Expand Down
5 changes: 5 additions & 0 deletions Sming/SmingCore/SmingCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

#define SMING_VERSION "3.5.1" // Major Minor Sub

#include <functional>

#define min(A, B) std::min(A, B)
#define max(A, B) std::max(A, B)

#include "../Wiring/WiringFrameworkIncludes.h"

#include "Delegate.h"
Expand Down
4 changes: 4 additions & 0 deletions Sming/Wiring/WConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@

#define sq(x) ((x)*(x))
//#define abs(x) ((x)>0?(x):-(x))
#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef max
#define max(a,b) ((a)>(b)?(a):(b))
#endif
//#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
Expand Down
7 changes: 7 additions & 0 deletions Sming/appinit/user_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ extern "C" uint32 ICACHE_FLASH_ATTR __attribute__((weak)) user_rf_cal_sector_se

return rf_cal_sec;
}

namespace std {
void __attribute__((weak)) __throw_bad_function_call()
{
while(1);
};
}

0 comments on commit ed0ca30

Please sign in to comment.