Skip to content

warning: control reaches end of non-void function at MoonPhase.cpp in line 67 and 77. #2

Description

@spellbinder103

indeed Arduino IDE can ignore the warning and continue compile with board Arduino UNO, but will end in error when compile with ESP8266.

start at line 54 in file MoonPhase.cpp
`int MoonPhase::GetType(float phaseval){

if(phaseval < 0.5){

        //waxing
        return 1;
  
} else if(phaseval > 0.5){

        return 2; // waning

}

}`

how about if value of variable phaseval is 0.5? no more no less, what int number should to return?

so be as start at line 69 in file MoonPhase.cpp
`int MoonPhase::GetPercentage(float phaseval){

if(phaseval < 0.5){
    return (phaseval-0.0)/(0.5-0.0) * 100; //(value-min)/(max-min)
} else if(phaseval > 0.5){
    return (1.0-((phaseval-0.5)/(1.0-0.5))) * 100; //(value-min)/(max-min) // flip for waning
}

}`

there are same issue too.

shall i edit code like this?
`int MoonPhase::GetPercentage(float phaseval){

if(phaseval < 0.5){
    return (phaseval-0.0)/(0.5-0.0) * 100; //(value-min)/(max-min)
} else { // <-- i edit here
    return (1.0-((phaseval-0.5)/(1.0-0.5))) * 100; //(value-min)/(max-min) // flip for waning
}

}`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions