Skip to content

Commit

Permalink
conserving just a few bytes of flash (8 with one sensor, 2 less then …
Browse files Browse the repository at this point in the history
…that per additional sensor)
  • Loading branch information
simonrupf committed Aug 1, 2017
1 parent 796fea6 commit 1b0b90e
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 11 deletions.
4 changes: 1 addition & 3 deletions libraries/MonSens/MonSens.cpp
Expand Up @@ -77,7 +77,6 @@ void IMonSens_Communicator::askSensors(const char* input) {
writeProgMem(MonSens_Usage);
for (uint8_t i = 0; i < sensorCount; ++i) {
writeProgMem(sensors[i]->getUsage());
writeProgMem(MonSens_EOL);
}
}

Expand All @@ -99,15 +98,14 @@ void IMonSens_Communicator::writeProgMem(const char* line) {
void IMonSens_Communicator::writeInt(const int16_t reading) {
// convert to unsigned
uint16_t n = (reading < 0) ? - (unsigned) reading : reading;
uint16_t n10 = 10 * n;
// make this the same order of magnitude as MAX_INT for your integer type
uint16_t digit = 10000;

if (0 == n) {
write('0' + 0);
} else {
// reduce size of digit to match the magnitude of given reading
while (digit > n10) {
while (digit > (10 * n)) {
digit /= 10;
}
// write digits until we reach floor(1 / 10) = 0 (int division rounds down)
Expand Down
2 changes: 1 addition & 1 deletion libraries/MonSens/MonSens_BME280.h
Expand Up @@ -64,7 +64,7 @@
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

const char MonSens_BME280_Usage[] PROGMEM = {
"C - temperature in Celsius\r\nK - temperature in Kelvin\r\nhPa - barometric pressure in hekto Pascal\r\nm - altitude in meters above sealevel\r\nRH - relative humidity in percents"
"C - temperature in Celsius\r\nK - temperature in Kelvin\r\nhPa - barometric pressure in hekto Pascal\r\nm - altitude in meters above sealevel\r\nRH - relative humidity in percents\r\n"
};

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/MonSens/MonSens_BMP280.h
Expand Up @@ -64,7 +64,7 @@
//Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK); // software SPI

const char MonSens_BMP280_Usage[] PROGMEM = {
"C - temperature in Celsius\r\nK - temperature in Kelvin\r\nhPa - barometric pressure in hekto Pascal\r\nm - altitude in meters above sealevel"
"C - temperature in Celsius\r\nK - temperature in Kelvin\r\nhPa - barometric pressure in hekto Pascal\r\nm - altitude in meters above sealevel\r\n"
};

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/MonSens/MonSens_DallasTemperature.h
Expand Up @@ -35,7 +35,7 @@
#include <DallasTemperature.h>

const char MonSens_DallasTemperature_Usage[] PROGMEM = {
"C - temperature in Celsius\r\nK - temperature in Kelvin"
"C - temperature in Celsius\r\nK - temperature in Kelvin\r\n"
};

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/MonSens/MonSens_Photoresistor.h
Expand Up @@ -33,7 +33,7 @@
#include <MonSens.h>

const char MonSens_Photoresistor_Usage[] PROGMEM = {
"R - resistance relative to light level"
"R - resistance relative to light level\r\n"
};

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/MonSens/MonSens_Si7021.h
Expand Up @@ -40,7 +40,7 @@
#include <Adafruit_Si7021.h>

const char MonSens_Si7021_Usage[] PROGMEM = {
"C - temperature in Celsius\r\nK - temperature in Kelvin\r\nRH - relative humidity in percents"
"C - temperature in Celsius\r\nK - temperature in Kelvin\r\nRH - relative humidity in percents\r\n"
};

/**
Expand Down
Expand Up @@ -31,7 +31,7 @@
#include <MonSens.h>

const char MonSens_DigiSpark_Temperature_Usage[] PROGMEM = {
"C - temperature inside the ATTiny85 in Celsius"
"C - temperature inside the ATTiny85 in Celsius\r\n"
};

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/MonSens_DigiSpark/MonSens_DigiSpark_Vcc.h
Expand Up @@ -31,7 +31,7 @@
#include <MonSens.h>

const char MonSens_DigiSpark_Vcc_Usage[] PROGMEM = {
"V - voltage at the DigiSpark chip"
"V - voltage at the ATtiny85 chip\r\n"
};

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/MonSens_ESP8266/MonSens_ESP8266_Vcc.h
Expand Up @@ -32,7 +32,7 @@
#include <MonSens.h>

const char MonSens_ESP8266_Vcc_Usage[] PROGMEM = {
"V - voltage at the ESP8266 chip"
"V - voltage at the ESP8266 chip\r\n"
};

/**
Expand Down

0 comments on commit 1b0b90e

Please sign in to comment.