stoduk / PingSerial

Arduino library for using serial enabled ultrasonic distance modules (eg. US-100)
MIT License
16 stars 9 forks source link

does not compile for ESP8266 #1

Closed BlitzSSS closed 7 years ago

BlitzSSS commented 7 years ago

ESP8266 Arduino core 2.3.0

Arduino: 1.6.12 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 4M (1M SPIFFS), ck, Disabled, None"

Build options changed, rebuilding all C:\Users\pc\Documents\Arduino\libraries\PingSerial-master\PingSerial.cpp:12:1: error: prototype for 'void PingSerial::Init(uint16_t, uint16_t)' does not match any in class 'PingSerial'

PingSerial::Init (uint16_t min_mm_distance,

^

In file included from C:\Users\pc\Documents\Arduino\libraries\PingSerial-master\PingSerial.cpp:7:0:

C:\Users\pc\Documents\Arduino\libraries\PingSerial-master\PingSerial.h:91:12: error: candidate is: void PingSerial::Init(unsigned int, unsigned int)

   void Init(unsigned int min_mm_distance, unsigned int max_mm_distance);

        ^

exit status 1 Error compiling for board Generic ESP8266 Module

stoduk commented 7 years ago

I didn't realise anyone else used this library! OOI - where did you hear of it?

Can you try changing Init() in PingSerial.h:91 from "unsigned int" to "uint16_t" (twice)? As a comment says elsewhere, a uint16_t is plenty for the distances we'll care about - on most Arduinos "unsigned int" and "uint16_t" are the same, but on newer boards it will be a four byte value (ie. uint32_t), so we should be explicit/consistent.

BlitzSSS commented 7 years ago

Hi, and thanks. I came across your comment searching in general for the US-100 and its serial mode from this site: https://arduibots.wordpress.com/2014/10/12/us-100-ultrasonic-sensor-in-serial-mode/

Looks like this now compiles with the changes you suggested - thanks again.

stoduk commented 7 years ago

Glad it fixed it. Not sure what introduced the warning being an error, probably the newer Arduino version you have.

I fixed another warning I spotted, but that was harmless.