Skip to content

Commit

Permalink
Merge pull request #1118 from mcspr/1101-warnings
Browse files Browse the repository at this point in the history
Fix compiler warnings
  • Loading branch information
xoseperez authored Aug 8, 2018
2 parents 97617d8 + 17d12cd commit 4fa1c9d
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 24 deletions.
2 changes: 1 addition & 1 deletion code/espurna/config/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@

#define IR_BUTTON_COUNT 24

const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
const uint32_t IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {

{ 0xFF906F, IR_BUTTON_MODE_BRIGHTER, 1 },
{ 0xFFB847, IR_BUTTON_MODE_BRIGHTER, 0 },
Expand Down
10 changes: 10 additions & 0 deletions code/espurna/config/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -2629,6 +2629,11 @@
#define MANUFACTURER "TravisCI"
#define DEVICE "Virtual board 02"

// Some buttons - pin 0
#define BUTTON1_PIN 0
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1

// A bit of CSE7766 - pin 1
#ifndef CSE7766_SUPPORT
#define CSE7766_SUPPORT 1
Expand Down Expand Up @@ -2696,6 +2701,11 @@
#define MANUFACTURER "TravisCI"
#define DEVICE "Virtual board 03"

// Some buttons - pin 0
#define BUTTON1_PIN 0
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1

// MY9231 Light - pins 1,2
#define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
#define LIGHT_PROVIDER LIGHT_PROVIDER_MY92XX
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/eeprom.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ EEPROM MODULE

// -----------------------------------------------------------------------------

bool eepromRotate(bool value) {
void eepromRotate(bool value) {
// Enable/disable EEPROM rotation only if we are using more sectors than the
// reserved by the memory layout
if (EEPROMr.size() > EEPROMr.reserved()) {
Expand Down
4 changes: 2 additions & 2 deletions code/espurna/i2c.ino
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ uint16_t i2c_read_uint16(uint8_t address, uint8_t reg) {
void i2c_read_buffer(uint8_t address, uint8_t * buffer, size_t len) {
Wire.beginTransmission((uint8_t) address);
Wire.requestFrom(address, (uint8_t) len);
for (int i=0; i<len; i++) buffer[i] = Wire.read();
for (size_t i=0; i<len; i++) buffer[i] = Wire.read();
Wire.endTransmission();
}

Expand Down Expand Up @@ -332,7 +332,7 @@ unsigned char i2cFind(size_t size, unsigned char * addresses) {
unsigned char i2cFindAndLock(size_t size, unsigned char * addresses) {
unsigned char start = 0;
unsigned char address = 0;
while (address = i2cFind(size, addresses, start)) {
while ((address = i2cFind(size, addresses, start))) {
if (i2cGetLock(address)) break;
start++;
}
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/ir.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void _irProcessCode(unsigned long code) {

for (unsigned char i = 0; i < IR_BUTTON_COUNT ; i++) {

unsigned long button_code = pgm_read_dword(&IR_BUTTON[i][0]);
uint32_t button_code = pgm_read_dword(&IR_BUTTON[i][0]);
if (code == button_code) {

unsigned long button_mode = pgm_read_dword(&IR_BUTTON[i][1]);
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/relay.ino
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void _relayProviderStatus(unsigned char id, bool status) {
if (_relays.size() == lightChannels()) {
lightState(id, status);
lightState(true);
} else if (_relays.size() == lightChannels() + 1) {
} else if (_relays.size() == (lightChannels() + 1u)) {
if (id == 0) {
lightState(status);
} else {
Expand Down
12 changes: 5 additions & 7 deletions code/espurna/sensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ void _sensorConfigure() {
double value;
EmonAnalogSensor * sensor = (EmonAnalogSensor *) _sensors[i];

if (value = getSetting("pwrExpectedP", 0).toInt()) {
if ((value = getSetting("pwrExpectedP", 0).toInt())) {
sensor->expectedPower(0, value);
setSetting("pwrRatioC", sensor->getCurrentRatio(0));
}
Expand Down Expand Up @@ -819,17 +819,17 @@ void _sensorConfigure() {
double value;
CSE7766Sensor * sensor = (CSE7766Sensor *) _sensors[i];

if (value = getSetting("pwrExpectedC", 0).toFloat()) {
if ((value = getSetting("pwrExpectedC", 0).toFloat())) {
sensor->expectedCurrent(value);
setSetting("pwrRatioC", sensor->getCurrentRatio());
}

if (value = getSetting("pwrExpectedV", 0).toInt()) {
if ((value = getSetting("pwrExpectedV", 0).toInt())) {
sensor->expectedVoltage(value);
setSetting("pwrRatioV", sensor->getVoltageRatio());
}

if (value = getSetting("pwrExpectedP", 0).toInt()) {
if ((value = getSetting("pwrExpectedP", 0).toInt())) {
sensor->expectedPower(value);
setSetting("pwrRatioP", sensor->getPowerRatio());
}
Expand Down Expand Up @@ -1111,13 +1111,11 @@ void sensorLoop() {
current = _magnitudeProcess(magnitude.type, current);
_magnitudes[i].current = current;

unsigned char decimals = _magnitudeDecimals(magnitude.type);

// Debug
#if SENSOR_DEBUG
{
char buffer[64];
dtostrf(current, 1-sizeof(buffer), decimals, buffer);
dtostrf(current, 1-sizeof(buffer), _magnitudeDecimals(magnitude.type), buffer);
DEBUG_MSG_P(PSTR("[SENSOR] %s - %s: %s%s\n"),
magnitude.sensor->slot(magnitude.local).c_str(),
magnitudeTopic(magnitude.type).c_str(),
Expand Down
10 changes: 5 additions & 5 deletions code/espurna/sensors/BaseSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ class BaseSensor {
virtual void post() {}

// Descriptive name of the sensor
virtual String description() {}
virtual String description() = 0;

// Address of the sensor (it could be the GPIO or I2C address)
virtual String address(unsigned char index) {}
virtual String address(unsigned char index) = 0;

// Descriptive name of the slot # index
virtual String slot(unsigned char index) {};
virtual String slot(unsigned char index) = 0;

// Type for slot # index
virtual unsigned char type(unsigned char index) {}
virtual unsigned char type(unsigned char index) = 0;

// Current value for slot # index
virtual double value(unsigned char index) {}
virtual double value(unsigned char index) = 0;

// Retrieve current instance configuration
virtual void getConfig(JsonObject& root) {};
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/DHTSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class DHTSensor : public BaseSensor {

}

unsigned long _signal(int usTimeOut, bool state) {
unsigned long _signal(unsigned long usTimeOut, bool state) {
unsigned long uSec = 1;
while (digitalRead(_gpio) == state) {
if (++uSec > usTimeOut) return 0;
Expand Down
6 changes: 3 additions & 3 deletions code/espurna/sensors/EmonSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ class EmonSensor : public I2CSensor {
#endif
}

virtual unsigned int readADC(unsigned char channel) {}
virtual unsigned int readADC(unsigned char channel) = 0;

void calculateFactors(unsigned char channel) {

_current_factor[channel] = _current_ratio[channel] * _reference / _adc_counts;

unsigned int s = 1;
unsigned int i = 1;
unsigned int m = s * i;
unsigned int multiplier;
unsigned int m = 1;
unsigned int multiplier = 1;
while (m * _current_factor[channel] < 1) {
multiplier = m;
i = (i == 1) ? 2 : (i == 2) ? 5 : 1;
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/ssdp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void ssdpSetup() {

char response[strlen_P(_ssdp_template) + 100];
snprintf_P(response, sizeof(response), _ssdp_template,
WiFi.localIP().toString().c_str(), // ip
ip.toString().c_str(), // ip
webPort(), // port
SSDP_DEVICE_TYPE, // device type
getSetting("hostname").c_str(), // friendlyName
Expand Down
5 changes: 4 additions & 1 deletion code/extra_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import distutils.spawn

Import("env")
Import("env", "projenv")

# ------------------------------------------------------------------------------
# Utils
Expand Down Expand Up @@ -86,6 +86,9 @@ def check_size(source, target, env):
# Hooks
# ------------------------------------------------------------------------------

# Always show warnings for project code
projenv.ProcessUnFlags("-w")

remove_float_support()

env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_size)

0 comments on commit 4fa1c9d

Please sign in to comment.