Removing some warning and potential undefined behaviours

pull/34/head
Eric Doughty-Papassideris 2021-03-09 23:42:51 +01:00
parent 4abc401509
commit 0ed0d0922e
3 changed files with 6 additions and 7 deletions

View File

@ -104,7 +104,7 @@ void Watchy7SEG::drawWeather(){
display.getTextBounds(String(temperature), 100, 150, &x1, &y1, &w, &h);
display.setCursor(155 - w, 150);
display.println(temperature);
display.drawBitmap(165, 110, TEMP_UNIT == "metric" ? celsius : fahrenheit, 26, 20, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.drawBitmap(165, 110, strcmp(TEMP_UNIT, "metric") == 0 ? celsius : fahrenheit, 26, 20, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
const unsigned char* weatherIcon;
//https://openweathermap.org/weather-conditions
@ -124,6 +124,7 @@ void Watchy7SEG::drawWeather(){
weatherIcon = rain;
}else if(weatherConditionCode >=200){//Thunderstorm
weatherIcon = rain;
}
}else
return;
display.drawBitmap(145, 158, weatherIcon, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
}

View File

@ -116,7 +116,7 @@ class StarryHorizon : public Watchy {
display.setTextColor(GxEPD_WHITE);
display.setTextWrap(false);
char* dateStr;
asprintf(&dateStr, "%s %s %d", dayOfWeek, monthStr, currentTime.Day);
asprintf(&dateStr, "%s %s %d", dayOfWeek.c_str(), monthStr.c_str(), currentTime.Day);
drawCenteredString(dateStr, 100, 140, true);
free(dateStr);
}

View File

@ -163,7 +163,7 @@ void Watchy::showMenu(byte menuIndex, bool partialRefresh){
uint16_t w, h;
int16_t yPos;
char *menuItems[] = {"Check Battery", "Vibrate Motor", "Show Accelerometer", "Set Time", "Setup WiFi", "Update Firmware"};
const char *menuItems[] = {"Check Battery", "Vibrate Motor", "Show Accelerometer", "Set Time", "Setup WiFi", "Update Firmware"};
for(int i=0; i<MENU_LENGTH; i++){
yPos = 30+(MENU_HEIGHT*i);
display.setCursor(0, yPos);
@ -240,8 +240,6 @@ void Watchy::setTime(){
int8_t setIndex = SET_HOUR;
int16_t x1, y1;
uint16_t w, h;
int8_t blink = 0;
pinMode(DOWN_BTN_PIN, INPUT);
@ -509,7 +507,7 @@ weatherData Watchy::getWeatherData(){
btStop();
}else{//No WiFi, use RTC Temperature
uint8_t temperature = RTC.temperature() / 4; //celsius
if(TEMP_UNIT == "imperial"){
if(strcmp(TEMP_UNIT, "imperial") == 0){
temperature = temperature * 9. / 5. + 32.; //fahrenheit
}
currentWeather.temperature = temperature;